Cross linking dynamic executables
Andrew STUBBS
andrew.stubbs@st.com
Wed Dec 15 14:40:00 GMT 2004
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)
-------------- next part --------------
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;
More information about the Binutils
mailing list