This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld -lgen -ladm causes assert failure in gnu ld 2.12.1 and 2.13 under Solaris 2.7 or 2.8


Hi Andrew,

> What's going on is that there is a second, presumably unrelated, 
> problem, the existence of which I had forgotten.  Following is a
> shell script that reproduces the problem.  When I execute it under
> binutils 2.13, with or without the patch, it dumps core;
> under binutils 2.12, it doesn't.
> 
> I wonder ... can you reproduce it on your end?

> $CC $CFLAGS $SHFLAGS dyn.c -o dyn.so
> $CC $CFLAGS main.c -o main -ldl
> 
> ./main || exit $?

Well yes and no.  I can run the script, but it works.  But then it
uses the installed gcc (2.95.2) and linker (Software Generation
Utilities - Solaris-ELF (4.0)) not a binutils 2.13 one.  (I only build
toolchains - I do not install them).

So I tried extracting the files from the script and building them by
hand.  I used the installed gcc (2.95.2) to compile main.o and dyn.so
and then I used my newly built binutils-from-CVS-repository linker to
create main:

  bash-2.01$ ../ld/ld-new -Y P,/usr/ccs/lib:/usr/lib -Qy -o main
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crt1.o
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crti.o
    /usr/ccs/lib/values-Xa.o
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtbegin.o
    -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2 -L/usr/ccs/bin
    -L/usr/ccs/lib -L/usr/local/lib main.o -ldl -lgcc -lc -lgcc
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtend.o
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtn.o

However this produced a version of 'main' that worked.

  bash-2.01$ uname -a
  SunOS tomorrow 5.7 Generic_106541-17 sun4u sparc SUNW,Ultra-30

  bash-2.01$ ../ld/ld-new -V
  GNU ld version 2.13.90 20020917
    Supported emulations:
     elf32_sparc
     elf64_sparc

  bash-2.01$ ./main
  calling dlopen
  calling dlsym
  calling sym
  in sym
  done

So then I tried to create a dyn.so dynamic object from a compiled but
unlinked dyn.o object file, using the new linker:

  bash-2.01$ ../ld/ld-new -G -dy -z text -Y P,/usr/ccs/lib:/usr/lib
    -Qy -o dyn.so
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crti.o
    /usr/ccs/lib/values-Xa.o
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtbegin.o
    -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2 -L/usr/ccs/bin
    -L/usr/ccs/lib -L/usr/local/lib dyn.o -lgcc -lgcc
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtend.o
    /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/crtn.o

and..

  bash-2.01$ ./main
  calling dlopen
  Segmentation Fault (core dumped)

bingo.

Using readelf -H to look at the secontions of the good dyn,so I see:

  There are 25 section headers, starting at offset 0x111c:

  Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .hash             HASH            00000094 000094 000074 04   A  2   0  4
  [ 2] .dynsym           DYNSYM          00000108 000108 0000e0 10   A  3   1  4
  [ 3] .dynstr           STRTAB          000001e8 0001e8 0000eb 00   A  0   0  1
  [ 4] .rela.data        RELA            000002d4 0002d4 00000c 0c   A  2   e  4
  [ 5] .rela.got         RELA            000002e0 0002e0 000060 0c   A  2   b  4
  [ 6] .rela.plt         RELA            00000340 000340 000024 0c   A  2   c  4
  [ 7] .text             PROGBITS        00000364 000364 0001bc 00  AX  0   0  4
  [ 8] .init             PROGBITS        00000520 000520 00001c 00  AX  0   0  4
  [ 9] .fini             PROGBITS        0000053c 00053c 000014 00  AX  0   0  4
  [10] .rodata           PROGBITS        00000550 000550 00000f 00   A  0   0  8
  [11] .got              PROGBITS        00010560 000560 000024 04  WA  0   0  4
  [12] .plt              PROGBITS        00010584 000584 000058 0c WAX  0   0  4
  [13] .dynamic          DYNAMIC         000105dc 0005dc 0000c0 08  WA  3   0  4
  [14] .data             PROGBITS        0001069c 00069c 000008 00  WA  0   0  4
  [15] .ctors            PROGBITS        000106a4 0006a4 000008 00  WA  0   0  4
  [16] .dtors            PROGBITS        000106ac 0006ac 000008 00  WA  0   0  4
  [17] .eh_frame         PROGBITS        000106b8 0006b8 000004 00  WA  0   0  8
  [18] .bss              NOBITS          000106c0 0006c0 000018 00  WA  0   0 16
  [19] .symtab           SYMTAB          00000000 0006bc 000490 10     20  3c  4
  [20] .strtab           STRTAB          00000000 000b4c 000281 00      0   0  1
  [21] .stab.index       PROGBITS        00000000 000dd0 000024 0c      0   0  4
  [22] .comment          PROGBITS        00000000 000df4 0000f1 00      0   0  1
  [23] .shstrtab         STRTAB          00000000 000ee5 0000c4 00      0   0  1
  [24] .stab.indexstr    STRTAB          00000000 000fa9 000171 00      0   0  1

whereas for the bad one I see:

  There are 24 section headers, starting at offset 0xaf4:

  Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .hash             HASH            00000094 000094 0000d4 04   A  2   0  4
  [ 2] .dynsym           DYNSYM          00000168 000168 000220 10   A  3  15  4
  [ 3] .dynstr           STRTAB          00000388 000388 0000a2 00   A  0   0  1
  [ 4] .rela.dyn         RELA            0000042c 00042c 00006c 0c   A  2   0  4
  [ 5] .rela.plt         RELA            00000498 000498 000024 0c   A  2   f  4
  [ 6] .init             PROGBITS        000004bc 0004bc 00001c 00  AX  0   0  4
  [ 7] .text             PROGBITS        000004d8 0004d8 0001bc 00  AX  0   0  4
  [ 8] .fini             PROGBITS        00000694 000694 000014 00  AX  0   0  4
  [ 9] .rodata           PROGBITS        000006a8 0006a8 00000f 00   A  0   0  8
  [10] .data             PROGBITS        000106b8 0006b8 000008 00  WA  0   0  4
  [11] .eh_frame         PROGBITS        000106c0 0006c0 000004 00  WA  0   0  8
  [12] .dynamic          DYNAMIC         000106c4 0006c4 0000a0 08  WA  3   0  4
  [13] .ctors            PROGBITS        00010764 000764 000008 00  WA  0   0  4
  [14] .dtors            PROGBITS        0001076c 00076c 000008 00  WA  0   0  4
  [15] .plt              PROGBITS        00010774 000774 000058 0c WAX  0   0  4
  [16] .got              PROGBITS        000107cc 0007cc 000024 04  WA  0   0  4
  [17] .bss              NOBITS          000107f0 0007f0 000018 00  WA  0   0 16
  [18] .stab.index       PROGBITS        00000000 0007f0 000024 0c     19   0  4
  [19] .stab.indexstr    STRTAB          00000000 000814 000171 00      0   0  1
  [20] .comment          PROGBITS        00000000 000985 0000bb 00      0   0  1
  [21] .shstrtab         STRTAB          00000000 000a40 0000b4 00      0   0  1
  [22] .symtab           SYMTAB          00000000 000eb4 000450 10     23  38  4
  [23] .strtab           STRTAB          00000000 001304 000223 00      0   0  1

Which is completely different, and the ".rela.got" section has gone
missing!

Not sure where to go from here.  I will try to find time to
investigate some more next week - but right now I am swamped.  If you
have any insights, please post them to the list.

Cheers
        Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]