LINK_SPEC question
Bo Thorsen
bo@suse.de
Tue Feb 26 03:11:00 GMT 2002
Hi,
I have a question about how collect2 gets it's arguments.
I have set LINK_SPEC to this:
#undef LINK_SPEC
#define LINK_SPEC "%{!m32:-m doesnnotworkelf_x86_64 -Y P,/usr/lib64} \
%{m32:-m elf_i386} \
%{shared:-shared} \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
%{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}} \
%{!m32:%{!dynamic-linker:-dynamic-linker
/lib64/ld-linux-x86-64.so.2}}}\ %{static:-static}}"
And this can be shown when running "gcc -dumpspecs":
*link:
%{!m32:-m doesnotworkelf_x86_64 -Y P,/usr/lib64} %{m32:-m elf_i386}
%{shared:-shared}
%{!shared:
%{!static:
%{rdynamic:-export-dynamic}
%{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}}
%{!m32:%{!dynamic-linker:-dynamic-linker/lib64/ld-linux-x86-64.so.2}}}
%{static:-static}}
But when collect2 is run, it does this:
/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/collect2 -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 crt1.o crti.o
/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/crtbegin.o
-L/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1 /tmp/ccey0qwF.o -lgcc -lc -lgcc
/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/crtend.o crtn.o
Related to this, I have tried to make the crt files have hardcoded paths like
sparc64 (for the same reason), but this also fails. I have set this:
#define STARTFILE_SPEC32 \
"%{!shared: \
%{pg:gcrt1.o} %{!pg:%{p:gcrt1.o} \
%{!p:%{profile:gcrt1.o} \
%{!profile:crt1.o}}}} \
crti.o %{static:crtbeginT.o}\
%{!static:%{!shared:crtbegin.o} %{shared:crtbeginS.o}}"
#define STARTFILE_SPEC64 \
"%{!shared: \
%{pg:/usr/lib64/gcrt1.o} %{!pg:%{p:/usr/lib64/gcrt1.o} \
%{!p:%{profile:/usr/lib64/gcrt1.o} \
%{!profile:/usr/lib64/crt1.o}}}} \
/usr/lib64/crti.o
%{static:/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/crtbeginT.o}\
%{!static:%{!shared:/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/crtbegin.o}
%{shared:/usr/lib64/gcc-lib/x86_64-unknown-linux/3.1/crtbeginS.o}}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "\
%{m32:" STARTFILE_SPEC32 "} \
%{!m32:" STARTFILE_SPEC64 "}"
And as you can see from the output, collect2 tries to call the linker without
these paths. And of course it's in gcc -dumpspecs.
The specs here are set in linux64.h, which is the last of the spec files:
config.gcc:
x86_64-*-linux*)
tm_file="${tm_file} i386/att.h dbxelf.h elfos.h svr4.h linux.h \
i386/x86-64.h i386/linux64.h"
tmake_file="t-slibgcc-elf-ver t-linux i386/t-crtstuff i386/t-linux64"
Any ideas?
Bo.
--
Bo Thorsen | Praestevejen 4
Free software developer | 5290 Marslev
SuSE Labs | Denmark
More information about the Gcc
mailing list