ld -shared --eh-frame-hdr gives empty eh_frame_hdr

David Simms david.simms@bea.com
Fri Jul 16 13:40:00 GMT 2004


On Fri, 2004-07-16 at 13:00, Jakub Jelinek wrote:
> On Fri, Jul 16, 2004 at 03:11:05PM +0200, David Simms wrote:
> > Gidday,
> > 
> > So I was trying compile a small shared library (on x86 with: gcc
3.3.4 +
> > binutils 2.15) without -fpic:
> > 
> >   $ gcc -c -funwind-tables -o foo.o foo.c
> >   $ ld --eh-frame-hdr -shared -o foo.so foo.o
> 
> You should never use ld directly to link programs, use gcc instead.
> It knows all the details how to link a program or a shared library
properly.
> Particularly, you haven't put in crt files, which means that .eh_frame
> is likely not zero terminated as it is required to be.
> 

Okidoki, but I still get the same problem with:

$ gcc -c -funwind-tables -o foo.o foo.c
$ gcc -v -shared -o foo.so -o foo.so foo.o
Reading specs from
/localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs
Configured with: ../configure
--prefix=/localhome/buildtools/linux32_sdk_2004_07a
--with-local-prefix=/localhome/buildtools/linux32_sdk_2004_07a
--with-as=/localhome/buildtools/linux32_sdk_2004_07/bin/as
--with-ld=/localhome/buildtools/linux32_sdk_2004_07/bin/ld
--enable-threads --enable-languages=c,objc,c++ --with-dwarf2
Thread model: posix
gcc version 3.3.4

/localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/collect2 --eh-frame-hdr -m elf_i386 -shared -o foo.so -o foo.so /usr/lib/crti.o /localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/crtbeginS.o -L/localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4 -L/localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/../../../../i686-pc-linux-gnu/lib -L/localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/../../.. foo.o -lgcc -lc -lgcc /localhome/buildtools/linux32_sdk_2004_07a/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/crtendS.o /usr/lib/crtn.o

$ readelf -l foo.so | grep FRAME
  GNU_EH_FRAME   0x0006d0 0x000006d0 0x000006d0 0x00008 0x00008 R   0x4

Still empty.

So is it possible /usr/lib/crtn.o or /usr/lib/crti.o are to blame ? Or
there another reason ?



More information about the Binutils mailing list