public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Cross linking dynamic executables
@ 2004-12-15 14:40 Andrew STUBBS
  2004-12-15 14:42 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew STUBBS @ 2004-12-15 14:40 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

When cross compiling a dynamic executable, the linker attempts to find
the dynamic linker in the 'standard places' (just as it does when
compiling nativly). This behaviour is rather irritating when the linker
tries to link an SH object file (in my case) against the x86 dynamic
linker on the build system.

I do not know whether my solution is acceptable to other people, but I
have attached a patch which attempts to solve the problem. It makes much
more sense to me that the linker should look for cross dynamic linkers
in the same place it looks for cross dynamic libraries. If it does not
find it with the libraries it still continues to look in the standard
places.

-- 
Andrew Stubbs
andrew.stubbs@st.com
(aka. andrew.stubbs@superh.com)

[-- Attachment #2: cross-link.patch --]
[-- Type: text/plain, Size: 1095 bytes --]

2004-12-15  Andrew Stubbs  <andrew.stubbs@st.com>

	* emultempl/elf32.em (gld*_after_open): Search for the dynamic linker in
	the library search path (as opposed to the 'standard' places) when cross
	compiling.

--- src/ld/emultempl/elf32.em	2004-11-22 20:33:33.000000000 +0000
+++ src/ld/emultempl/elf32.em	2004-12-14 11:33:23.000000000 +0000
@@ -880,8 +880,20 @@
 	    {
 	      char *filename;
 
+EOF
+if [ "x${host}" = "x${target}" ] ; then
+# When cross compiling the dynamic linker is unlikly to be in
+# the standard place - especially if the binutils were built and
+# then moved to somewhere else. In this case the best thing to do
+# is look for the dynamic linker in the same place as the libraries.
+# If compiling natively ignore the -L options on the command line
+# and always used the normal places.
+cat >>e${EMULATION_NAME}.c <<EOF
 	      if (search->cmdline)
 		continue;
+EOF
+fi
+cat >>e${EMULATION_NAME}.c <<EOF
 	      filename = (char *) xmalloc (strlen (search->name) + len + 2);
 	      sprintf (filename, "%s/%s", search->name, l->name);
 	      nn.name = filename;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-15 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-15 14:40 Cross linking dynamic executables Andrew STUBBS
2004-12-15 14:42 ` Daniel Jacobowitz
2004-12-15 17:12   ` Andrew STUBBS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).