diff mbox

[rfc] Fix remote shared library tests (fwd)

Message ID 201107151414.p6FEEi9t031837@d06av02.portsmouth.uk.ibm.com
State Accepted
Headers show

Commit Message

Ulrich Weigand July 15, 2011, 2:14 p.m. UTC
http://sourceware.org/ml/gdb-patches/2011-07/msg00241.html

ChangeLog:

	* lib/gdb.exp (gdb_compile): Specify rpath if the *target* is
	a remote machine, not the host.
	(gdb_compile_shlib): Set soname if target is remote.
diff mbox

Patch

Index: gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.182
diff -u -p -r1.182 gdb.exp
--- gdb/testsuite/lib/gdb.exp	1 Jul 2011 00:19:25 -0000	1.182
+++ gdb/testsuite/lib/gdb.exp	7 Jul 2011 13:19:23 -0000
@@ -2168,7 +2168,7 @@  proc gdb_compile {source dest type optio
     # dynamically load one by basename, we must specify rpath.  If we
     # are using a remote host, DejaGNU will link to the shared library
     # using a relative path, so again we must specify an rpath.
-    if { $shlib_load || ($shlib_found && [is_remote host]) } {
+    if { $shlib_load || ($shlib_found && [is_remote target]) } {
 	if { ([istarget "*-*-mingw*"]
 	      || [istarget *-*-cygwin*]
 	      || [istarget *-*-pe*]
@@ -2383,7 +2383,17 @@  proc gdb_compile_shlib {sources dest opt
 		 || [istarget *-*-cygwin*]
 		 || [istarget *-*-pe*])} {
 	       lappend link_options "additional_flags=-Wl,--out-implib,${dest}.a"
-	   }
+	   } elseif [is_remote target] {
+	     # By default, we do not set the soname.  This causes the linker
+	     # on ELF systems to create a DT_NEEDED entry in the executable
+	     # refering to the full path name of the library.  This is a
+	     # problem in remote testing if the library is in a different
+	     # directory there.  To fix this, we set a soname of just the
+	     # base filename for the library, and add an appropriate -rpath
+	     # to the main executable (in gdb_compile).
+             set destbase [file tail $dest]
+             lappend link_options "additional_flags=-Wl,-soname,$destbase"
+           }
        }
        if {[gdb_compile "${objects}" "${dest}" executable $link_options] != ""} {
            return -1