If configure compile&link test has -shared, use -fPIC as well

Alexandre Oliva aoliva@redhat.com
Mon Sep 5 17:20:00 GMT 2005


My x86_64-*-linux-gnu build of glibc wasn't passing all tests.  One of
the reason for failures was that the test for --as-needed as broken:
it compiled a source file without -fPIC, then attempted to include it
in a shared library.  The relocations emitted in the eh_frame and
debugging sections caused the file to be rejected by the linker.  A
number of other tests that used to fail because of this mistake pass
after installing the following patch.

Please check it in.  I haven't included the changes autoconf made to
the configure script, only configure.in.


For the record, the failure mode was that tests such as tst-cancelx4
aborted.  That was because the main executable ended up linked with
libgcc_eh.a, taking a number of functions from it, whereas libpthread
dlopen()ed libgcc_s.so.1 to obtain such functions for thread
cancellation.  The shared-library copy initialized its dwarf reg sizes
table correctly, per libpthread's request, whereas the other didn't
get it initialized at all.  However, the dynamic loader resolved the
personality function in the main executable to the copy in the main
executable, and that called _Unwind_SetGR in the main executable as
well, thus using the uninitialized table and abort()ing.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: glibc-configure-use-PIC-for-shared.patch
Type: text/x-patch
Size: 3377 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-hacker/attachments/20050905/017c0ec2/attachment.bin>
-------------- next part --------------

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


More information about the Libc-hacker mailing list