Bug 12343 - binutils 2.21.51.0.3 and .4 break building (e)glibc on x86_64-linux
Summary: binutils 2.21.51.0.3 and .4 break building (e)glibc on x86_64-linux
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 critical
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
: 12499 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-12-23 11:10 UTC by Bernhard Rosenkraenzer
Modified: 2014-05-28 19:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Rosenkraenzer 2010-12-23 11:10:50 UTC
Trying to build the (e)glibc 2.12.2 on an x86_64-linux box with gcc 4.5.2 and binutils 2.21.51.0.3 and .4 results in (build directory = /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux):

make[2]: Entering directory `/usr/src/ark/BUILD/eglibc-2.12/libc/sunrpc'
CPP='gcc -E -x c-header'    /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2 --library-path /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/math:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/dlfcn:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nss:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nis:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/rt:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/resolv:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/crypt:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nptl /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/xbootparam_prot.T
make[2]: *** [/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/xbootparam_prot.stmp] Segmentation fault
make[2]: Leaving directory `/usr/src/ark/BUILD/eglibc-2.12/libc/sunrpc'
make[1]: *** [sunrpc/others] Error 2
make[1]: Leaving directory `/usr/src/ark/BUILD/eglibc-2.12/libc'
make: *** [all] Error 2

Taking out enforcing the use of the newly built libs:

CPP='gcc -E -x c-header' /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/xbootparam_prot.T
and even
CPP='gcc -E -x c-header' /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2 /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/xbootparam_prot.T
and
CPP='gcc -E -x c-header'    /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2 --library-path /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/math:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/dlfcn:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nss:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nis:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/rt:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/resolv:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/crypt:/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/nptl /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/sunrpc/xbootparam_prot.T

(the latter just has /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux removed from the --library-path) all succeed, so the problem is with the newly built libc.

Also, something simple like
LD_PRELOAD=/usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/libc.so /bin/true

segfaults, so chances are something odd is going on in the startup code.

The backtrace looks like ld-linux-x86-64.so.2 is trying to jump straight at (void*)-1

$ gdb /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2
(gdb) set args --library-path /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux /bin/true
(gdb) r
Starting program: /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2 --library-path /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux /bin/true

Program received signal SIGSEGV, Segmentation fault.
0xffffffffffffffff in ?? ()
(gdb) bt
#0  0xffffffffffffffff in ?? ()
#1  0x00007ffff7fed80f in call_init ()
   from /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2
#2  0x00007ffff7fed907 in _dl_init_internal ()
   from /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2
#3  0x00007ffff7fdfaca in _dl_start_user ()
   from /usr/src/ark/BUILD/eglibc-2.12/libc/build-x86_64-linux/elf/ld-linux-x86-64.so.2
#4  0x00007fffffffea0a in ?? ()
#5  0x0000000000000001 in ?? ()
#6  0x00007fffffffea50 in ?? ()
#7  0x0000000000000000 in ?? ()
(gdb) 


It works with binutils 2.21.51.0.2.
Comment 1 Alan Modra 2010-12-24 00:10:11 UTC
Very likely a problem with putting .ctors into .init_array (top of .0.3 ChangeLogs have HJ's patch to do that).  To debug, I'd first look at DT_INIT_ARRAY and DT_INIT_ARRAY_SZ (readelf -d on the bad libc) to see if they make sense, ie. match the .init_array sections (readelf -S).  Next I'd dump out .init_array (objdump -s -j .init_array) to see whether it did in fact have a -1 pointer.  If so, build the library again asking for a linker map file so you can tell where the -1 comes from.
Comment 2 Bernhard Rosenkraenzer 2010-12-24 13:45:34 UTC
$ readelf -d libc.so

Dynamic section at offset 0x179b40 contains 28 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000000e (SONAME)             Library soname: [libc.so.6]
 0x000000000000000c (INIT)               0x1e870
 0x0000000000000019 (INIT_ARRAY)         0x376710
 0x000000000000001b (INIT_ARRAYSZ)       24 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x376730
 0x000000000000001c (FINI_ARRAYSZ)       32 (bytes)
 0x0000000000000004 (HASH)               0x172850
 0x000000006ffffef5 (GNU_HASH)           0x290
 0x0000000000000005 (STRTAB)             0x10618
 0x0000000000000006 (SYMTAB)             0x3bf8
 0x000000000000000a (STRSZ)              22001 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0x379fe8
 0x0000000000000002 (PLTRELSZ)           144 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x1e6f8
 0x0000000000000007 (RELA)               0x16f70
 0x0000000000000008 (RELASZ)             30600 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffc (VERDEF)             0x16ce8
 0x000000006ffffffd (VERDEFNUM)          17
 0x000000000000001e (FLAGS)              STATIC_TLS
 0x000000006ffffffe (VERNEED)            0x16f40
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x15c0a
 0x000000006ffffff9 (RELACOUNT)          1189
 0x0000000000000000 (NULL)               0x0

$ readelf -S libc.so
There are 71 section headers, starting at offset 0x17bcd8:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.ABI-tag     NOTE             0000000000000270  00000270
       0000000000000020  0000000000000000   A       0     0     4
  [ 2] .gnu.hash         GNU_HASH         0000000000000290  00000290
       0000000000003968  0000000000000000   A       3     0     8
  [ 3] .dynsym           DYNSYM           0000000000003bf8  00003bf8
       000000000000ca20  0000000000000018   A       4     3     8
  [ 4] .dynstr           STRTAB           0000000000010618  00010618
       00000000000055f1  0000000000000000   A       0     0     1
  [ 5] .gnu.version      VERSYM           0000000000015c0a  00015c0a
       00000000000010d8  0000000000000002   A       3     0     2
  [ 6] .gnu.version_d    VERDEF           0000000000016ce8  00016ce8
       0000000000000254  0000000000000000   A       4    17     8
  [ 7] .gnu.version_r    VERNEED          0000000000016f40  00016f40
       0000000000000030  0000000000000000   A       4     1     8
  [ 8] .rela.dyn         RELA             0000000000016f70  00016f70
       0000000000007788  0000000000000018   A       3     0     8
  [ 9] .rela.plt         RELA             000000000001e6f8  0001e6f8
       0000000000000090  0000000000000018   A       3    10     8
  [10] .plt              PROGBITS         000000000001e788  0001e788
       0000000000000070  0000000000000010  AX       0     0     4
  [11] .text             PROGBITS         000000000001e800  0001e800
       000000000010a140  0000000000000000  AX       0     0     32
  [12] __libc_freeres_fn PROGBITS         0000000000128940  00128940
       0000000000001683  0000000000000000  AX       0     0     16
  [13] __libc_thread_fre PROGBITS         0000000000129fd0  00129fd0
       00000000000002e2  0000000000000000  AX       0     0     16
  [14] .rodata           PROGBITS         000000000012a2c0  0012a2c0
       000000000001cd50  0000000000000000   A       0     0     32
  [15] .interp           PROGBITS         0000000000147010  00147010
       000000000000001c  0000000000000000   A       0     0     16
  [16] .eh_frame_hdr     PROGBITS         000000000014702c  0014702c
       00000000000063d4  0000000000000000   A       0     0     4
  [17] .eh_frame         PROGBITS         000000000014d400  0014d400
       0000000000024fdc  0000000000000000   A       0     0     8
  [18] .gcc_except_table PROGBITS         00000000001723dc  001723dc
       0000000000000471  0000000000000000   A       0     0     1
  [19] .hash             HASH             0000000000172850  00172850
       000000000000319c  0000000000000004   A       3     0     8
  [20] .tdata            PROGBITS         0000000000376700  00176700
       0000000000000010  0000000000000000 WAT       0     0     16
  [21] .tbss             NOBITS           0000000000376710  00176710
       0000000000000080  0000000000000000 WAT       0     0     16
  [22] .init_array       INIT_ARRAY       0000000000376710  00176710
       0000000000000018  0000000000000000  WA       0     0     16
  [23] .fini_array       FINI_ARRAY       0000000000376730  00176730
       0000000000000020  0000000000000000  WA       0     0     16
  [24] __libc_subfreeres PROGBITS         0000000000376750  00176750
       00000000000000e0  0000000000000000  WA       0     0     8
  [25] __libc_atexit     PROGBITS         0000000000376830  00176830
       0000000000000008  0000000000000000  WA       0     0     8
  [26] __libc_thread_sub PROGBITS         0000000000376838  00176838
       0000000000000020  0000000000000000  WA       0     0     8
  [27] .data.rel.ro      PROGBITS         0000000000376860  00176860
       00000000000032e0  0000000000000000  WA       0     0     32
  [28] .dynamic          DYNAMIC          0000000000379b40  00179b40
       0000000000000200  0000000000000010  WA       4     0     8
  [29] .got              PROGBITS         0000000000379d40  00179d40
       00000000000002a0  0000000000000008  WA       0     0     8
  [30] .got.plt          PROGBITS         0000000000379fe8  00179fe8
       0000000000000048  0000000000000008  WA       0     0     8
  [31] .data             PROGBITS         000000000037a040  0017a040
       0000000000000ea0  0000000000000000  WA       0     0     32
  [32] .bss              NOBITS           000000000037aee0  0017aee0
       0000000000005478  0000000000000000  WA       0     0     32
  [33] .gnu.warning.sigs PROGBITS         0000000000000000  0017aee0
       000000000000004d  0000000000000000           0     0     32
  [34] .gnu.warning.sigr PROGBITS         0000000000000000  0017af40
       000000000000003b  0000000000000000           0     0     32
  [35] .gnu.warning.sigg PROGBITS         0000000000000000  0017af80
       0000000000000039  0000000000000000           0     0     32
  [36] .gnu.warning.tmpn PROGBITS         0000000000000000  0017afc0
       0000000000000037  0000000000000000           0     0     32
  [37] .gnu.warning.tmpn PROGBITS         0000000000000000  0017b000
       0000000000000039  0000000000000000           0     0     32
  [38] .gnu.warning.temp PROGBITS         0000000000000000  0017b040
       0000000000000038  0000000000000000           0     0     32
  [39] .gnu.warning.sys_ PROGBITS         0000000000000000  0017b080
       0000000000000044  0000000000000000           0     0     32
  [40] .gnu.warning.sys_ PROGBITS         0000000000000000  0017b0e0
       0000000000000041  0000000000000000           0     0     32
  [41] .gnu.warning.gets PROGBITS         0000000000000000  0017b140
       0000000000000039  0000000000000000           0     0     32
  [42] .gnu.warning.__me PROGBITS         0000000000000000  0017b179
       000000000000005c  0000000000000000           0     0     1
  [43] .gnu.warning.getp PROGBITS         0000000000000000  0017b1e0
       000000000000003a  0000000000000000           0     0     32
  [44] .gnu.warning.re_m PROGBITS         0000000000000000  0017b220
       000000000000003d  0000000000000000           0     0     32
  [45] .gnu.warning.setl PROGBITS         0000000000000000  0017b260
       000000000000003a  0000000000000000           0     0     32
  [46] .gnu.warning.getw PROGBITS         0000000000000000  0017b2a0
       000000000000007a  0000000000000000           0     0     32
  [47] .gnu.warning.lchm PROGBITS         0000000000000000  0017b320
       0000000000000038  0000000000000000           0     0     32
  [48] .gnu.warning.sstk PROGBITS         0000000000000000  0017b360
       0000000000000036  0000000000000000           0     0     32
  [49] .gnu.warning.mkte PROGBITS         0000000000000000  0017b3a0
       0000000000000037  0000000000000000           0     0     32
  [50] .gnu.warning.gtty PROGBITS         0000000000000000  0017b3e0
       0000000000000036  0000000000000000           0     0     32
  [51] .gnu.warning.stty PROGBITS         0000000000000000  0017b420
       0000000000000036  0000000000000000           0     0     32
  [52] .gnu.warning.chfl PROGBITS         0000000000000000  0017b460
       0000000000000039  0000000000000000           0     0     32
  [53] .gnu.warning.fchf PROGBITS         0000000000000000  0017b4a0
       000000000000003a  0000000000000000           0     0     32
  [54] .gnu.warning.revo PROGBITS         0000000000000000  0017b4e0
       0000000000000038  0000000000000000           0     0     32
  [55] .gnu.warning.bdfl PROGBITS         0000000000000000  0017b520
       0000000000000039  0000000000000000           0     0     32
  [56] .gnu.warning.__ge PROGBITS         0000000000000000  0017b560
       0000000000000039  0000000000000000           0     0     32
  [57] .gnu.warning.inet PROGBITS         0000000000000000  0017b5a0
       000000000000003c  0000000000000000           0     0     32
  [58] .gnu.warning.inet PROGBITS         0000000000000000  0017b5e0
       000000000000003b  0000000000000000           0     0     32
  [59] .gnu.warning.inet PROGBITS         0000000000000000  0017b620
       000000000000003d  0000000000000000           0     0     32
  [60] .gnu.warning.inet PROGBITS         0000000000000000  0017b660
       000000000000003c  0000000000000000           0     0     32
  [61] .gnu.warning.inet PROGBITS         0000000000000000  0017b6a0
       000000000000003b  0000000000000000           0     0     32
  [62] .gnu.warning.inet PROGBITS         0000000000000000  0017b6e0
       000000000000003b  0000000000000000           0     0     32
  [63] .gnu.warning.getm PROGBITS         0000000000000000  0017b720
       0000000000000038  0000000000000000           0     0     32
  [64] .gnu.warning.putm PROGBITS         0000000000000000  0017b760
       0000000000000038  0000000000000000           0     0     32
  [65] .gnu.warning.fatt PROGBITS         0000000000000000  0017b7a0
       0000000000000039  0000000000000000           0     0     32
  [66] .gnu.warning.fdet PROGBITS         0000000000000000  0017b7e0
       0000000000000039  0000000000000000           0     0     32
  [67] .comment          PROGBITS         0000000000000000  0017b819
       0000000000000011  0000000000000001  MS       0     0     1
  [68] .shstrtab         STRTAB           0000000000000000  0017b82a
       00000000000004ad  0000000000000000           0     0     1
  [69] .symtab           SYMTAB           0000000000000000  0017ce98
       000000000002bfe0  0000000000000018          70   5355     8
  [70] .strtab           STRTAB           0000000000000000  001a8e78
       00000000000188e8  0000000000000000           0     0     1
$ objdump -s -j .init_array libc.so

libc.so:     file format elf64-x86-64

Contents of section .init_array:
 376710 ffffffff ffffffff 10cd0800 00000000  ................
 376720 00000000 00000000                    ........        


So .init_array does start with -1...
Comment 3 Bernhard Rosenkraenzer 2010-12-24 14:39:33 UTC
Building binutils with --disable-initfini-array "fixes" it
Comment 5 H.J. Lu 2011-02-21 18:13:42 UTC
*** Bug 12499 has been marked as a duplicate of this bug. ***
Comment 6 H.J. Lu 2011-03-17 02:52:38 UTC
*** Bug 12499 has been marked as a duplicate of this bug. ***
Comment 7 Jackie Rosen 2014-02-16 18:25:15 UTC Comment hidden (spam)