gcc and /usr/lib/*.ld files
William Roberts
liam at cs.qmw.ac.uk
Fri Nov 30 03:43:36 AEST 1990
A further problem has surfaced with the latest gcc from John
Coolidge (gcc-1.37.94), when used with those funny
/usr/lib/*.ld files to achieve extra control over the layout of
the COFF binary produced by the final ld.
Imagine a file foo.c containing the usual "hello world"
program, and compile it to get foo.o. We used to be able to say
gcc -N foo.o /usr/lib/unshared.ld
and get a working binary: using the previous version of gcc
that produced junk binaries if you tried to use shared
libraries.
Now we get the following effect:
% gcc -v -N foo.o /usr/lib/unshared.ld
gcc version 1.37.94
ld -L/usr/local/lib -L/usr/local/Gnu/lib -N
/lib/crt1.o /lib/crt2.o foo.o /usr/lib/unshared.ld
/usr/lib/gcc-gnulib /usr/lib/gcc-gnulib -lc /lib/crtn.o
/usr/lib/gcc-gnulib /usr/lib/shlib.ld
ld warning: Sections .text .data or .bss not found.
Optional header may be useless
% size a.out
Size of a.out: 0x23fc
Section Size Physical Address Virtual Address
.text 0x00001d00 0x00000000 0x00000000
.data 0x0000058c 0x00001d00 0x00001d00
.bss 0x00000170 0x0000228c 0x0000228c
.text 0x00000000 0x000023fc 0x000023fc
.data 0x00000000 0x00400000 0x00400000
.bss 0x00000000 0x00400000 0x00400000
% a.out
Segmentation fault (core dumped)
%
There are two separate problems:
1) The presence on an explicit *.ld file does not prevent gcc from
putting /usr/lib/shlib.ld on the end. Using the real A/UX cc instead
produces
% /bin/cc -v -N foo.o /usr/lib/unshared.ld
/bin/ld /lib/crt1.o /lib/crt2.o -N foo.o /usr/lib/unshared.ld -lc
%
2) The unshared.ld should be linked with /lib/crt0.o instead of
/lib/crt1.o and /lib/crt2.0 - A/UX cc gets this wrong as well!
I don't know what the correct answer should be: /usr/lib/unshared.ld itself
looks out of date (mentions obselete magic numbers, for instance).
What is correct System V semantics for all this?
The work-around is to do the ld explicitly if you need the
extra functionality that the *.ld files provide.
--
William Roberts ARPA: liam at cs.qmw.ac.uk
Queen Mary & Westfield College UUCP: liam at qmw-cs.UUCP
Mile End Road AppleLink: UK0087
LONDON, E1 4NS, UK Tel: 071-975 5250 (Fax: 081-980 6533)
More information about the Comp.unix.aux
mailing list