From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12570 invoked by alias); 5 Sep 2005 17:20:28 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 12554 invoked by uid 22791); 5 Sep 2005 17:20:27 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 05 Sep 2005 17:20:27 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j85HKQwm022792 for ; Mon, 5 Sep 2005 13:20:26 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j85HKQV21859 for ; Mon, 5 Sep 2005 13:20:26 -0400 Received: from livre.oliva.athome.lsd.ic.unicamp.br (vpn50-57.rdu.redhat.com [172.16.50.57]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id j85HKOBl022093 for ; Mon, 5 Sep 2005 13:20:25 -0400 Received: from livre.oliva.athome.lsd.ic.unicamp.br (livre.oliva.athome.lsd.ic.unicamp.br [127.0.0.1]) by livre.oliva.athome.lsd.ic.unicamp.br (8.13.4/8.13.4) with ESMTP id j85HKMKb008358 for ; Mon, 5 Sep 2005 14:20:22 -0300 Received: (from aoliva@localhost) by livre.oliva.athome.lsd.ic.unicamp.br (8.13.4/8.13.4/Submit) id j85HKLuV008291; Mon, 5 Sep 2005 14:20:21 -0300 To: libc-hacker@sources.redhat.com Subject: If configure compile&link test has -shared, use -fPIC as well From: Alexandre Oliva Date: Mon, 05 Sep 2005 17:20:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2005-09/txt/msg00003.txt.bz2 --=-=-= Content-length: 1234 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=glibc-configure-use-PIC-for-shared.patch Content-length: 3377 Index: ChangeLog 2005-09-05 Alexandre Oliva * configure.in: Compile source test file with -fPIC for -shared. * configure: Rebuilt. Index: configure.in =================================================================== RCS file: /cvs/glibc/libc/configure.in,v retrieving revision 1.442 diff -u -p -r1.442 configure.in --- configure.in 19 Jul 2005 15:34:30 -0000 1.442 +++ configure.in 5 Sep 2005 17:07:31 -0000 @@ -1238,7 +1238,7 @@ EOF libc_cv_have_sdata_section, [echo "int i;" > conftest.c libc_cv_have_sdata_section=no - if ${CC-cc} $LDFLAGS -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ + if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \ | grep '\.sdata' >/dev/null; then libc_cv_have_sdata_section=yes fi @@ -1297,7 +1297,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodelete 1>&AS_MESSAGE_LOG_FD]) then @@ -1314,7 +1314,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,nodlopen 1>&AS_MESSAGE_LOG_FD]) then @@ -1331,7 +1331,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostartfiles -nostdlib -Wl,--enable-new-dtags,-z,initfirst 1>&AS_MESSAGE_LOG_FD]) then @@ -1363,7 +1363,7 @@ EOF int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-Bgroup -nostdlib 1>&AS_MESSAGE_LOG_FD]) then libc_cv_Bgroup=yes @@ -1380,7 +1380,7 @@ int main (void) { return 0; } EOF changequote(,)dnl libc_cv_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ - -shared -shared-libgcc -o conftest.so \ + -fPIC -shared -shared-libgcc -o conftest.so \ conftest.c -v 2>&1 >/dev/null \ | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` changequote([,])dnl @@ -1393,7 +1393,7 @@ changequote([,])dnl int main (void) { return 0; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -lgcc_s$libc_cv_libgcc_s_suffix -Wl,--as-needed -nostdlib 1>&AS_MESSAGE_LOG_FD]) then @@ -1434,7 +1434,7 @@ extern int mumble; int foo (void) { return bar (mumble); } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -nostdlib -nostartfiles -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD]) then @@ -1463,7 +1463,7 @@ dnl look for a section named .rel.dyn. int _start (void) { return 42; } EOF if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS - -shared -o conftest.so conftest.c + -fPIC -shared -o conftest.so conftest.c -Wl,-z,execstack -nostdlib 1>&AS_MESSAGE_LOG_FD]) then --=-=-= Content-length: 188 -- 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} --=-=-=--