Subject: Re: bad libc from build on netbsd-1-5 branch on sparc
To: None <netbsd-users@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: netbsd-users
Date: 06/05/2003 19:51:10
Apologies if I failed to find this in the archives; I found some
things about sparc64 ABI issues, but I think that's separate.

On a pretty vanilla Sparc 20 with netbsd-1-5, I built libc.so and
found that it would not work:

24 /usr/obj/usr/ANONCVS/src/lib/libc > LD_LIBRARY_PATH=. ldd /usr/bin/more
/usr/bin/more:
         -ltermcap.0 => /usr/lib/libtermcap.so.0
         -lc.12 => ./libc.so.12
25 /usr/obj/usr/ANONCVS/src/lib/libc > LD_LIBRARY_PATH=. /usr/bin/more /etc/services
./libc.so.12: Undefined symbol "" (reloc type = 12, symnum = 7)
26 /usr/obj/usr/ANONCVS/src/lib/libc > ls -l libc.so*
lrwxr-xr-x  1 gdt  wheel      15 Jun  5 17:30 libc.so -> libc.so.12.62.1
lrwxr-xr-x  1 gdt  wheel      15 Jun  5 17:30 libc.so.12 -> libc.so.12.62.1
-rwxr-xr-x  1 gdt  wheel  724566 Jun  5 17:30 libc.so.12.62.1
30 /usr/obj/usr/ANONCVS/src/lib/libc > ls -l /usr/lib/libc.so*
lrwxr-xr-x  1 root  wheel      15 May 29 16:40 /usr/lib/libc.so -> libc.so.12.62.1
lrwxr-xr-x  1 root  wheel      15 May 29 16:40 /usr/lib/libc.so.12 -> libc.so.12.62.1
-r--r--r--  1 root  wheel  728338 Nov 18  2002 /usr/lib/libc.so.12.62.1
-r--r--r--  1 root  wheel  728338 Nov 18  2002 /usr/lib/libc.so.12.62.1-SAVE
-r--r--r--  1 root  wheel  724854 May 29 16:40 /usr/lib/libc.so.12.62.1.ng

(.ng is from a recent build, and also does not work.  The older one
(note larger size; not sure if that means anything) is from last fall.

I ran 'nm -u' and found nothing interesting.  I then ran objdump --sym
on the new (bad) and old (working) libc.so files.  Note that the 7th
symbol in the bad library is not present in the working library.

32 /usr/obj/usr/ANONCVS/src/lib/libc > objdump --sym /usr/lib/libc.so.12.62.1 | head -20

/usr/lib/libc.so.12.62.1:     file format elf32-sparc

SYMBOL TABLE:
000000b4 l    d  .hash  00000000 
00002f10 l    d  .dynsym        00000000 
0000a7f0 l    d  .dynstr        00000000 
0000fb60 l    d  .rela.data     00000000 
00012998 l    d  .rela.got      00000000 
000170b4 l    d  .rela.plt      00000000 
00018dc4 l    d  .init  00000000 
00018ee0 l    d  .text  00000000 
000873cc l    d  .fini  00000000 
00087478 l    d  .rodata        00000000 
0008f470 l    d  .note.netbsd.ident     00000000 
0009f488 l    d  .data  00000000 
000a14f0 l    d  .eh_frame      00000000 
000a14f4 l    d  .ctors 00000000 
000a14fc l    d  .dtors 00000000 
000a1504 l    d  .plt   00000000 

sunpal7 gdt 33 /usr/obj/usr/ANONCVS/src/lib/libc > objdump --sym libc.so.12.62.1 | head -20

libc.so.12.62.1:     file format elf32-sparc

SYMBOL TABLE:
000000b4 l    d  .hash  00000000 
00002f10 l    d  .dynsym        00000000 
0000a7f0 l    d  .dynstr        00000000 
0000fb60 l    d  .rela.data     00000000 
00012998 l    d  .rela.got      00000000 
00017060 l    d  .rela.init     00000000 
00017108 l    d  .rela.fini     00000000 
00017168 l    d  .rela.plt      00000000 
00018ea8 l    d  .init  00000000 
00018f90 l    d  .text  00000000 
00086e94 l    d  .fini  00000000 
00086f18 l    d  .rodata        00000000 
0008ef10 l    d  .note.netbsd.ident     00000000 
0009ef28 l    d  .data  00000000 
000a0f90 l    d  .eh_frame      00000000 
000a0f94 l    d  .ctors 00000000 

Note the two extra symbols, .rela.init and .rela.fini.

Linking the library is straightforward:

  ld -x -shared -soname libc.so.12 -o libc.so.12.62.1  /usr/lib/crtbeginS.o  --whole-archive libc_pic.a --no-whole-archive   /usr/lib/crtendS.o

Looking in libc_pic.a with objdump (which seems to handle archives
just fine), I find no .rela.* symbols.

I do find something in /usr/lib/crtbeginS.o, but without the .rela,
and this file matches another sparc 20 with nearly the same software
(whose libc is ok; I have not updated it yet as it is more critical).

38 /usr/obj/usr/ANONCVS/src/lib/libc > objdump --sym /usr/lib/crtbeginS.o

/usr/lib/crtbeginS.o:     file format elf32-sparc

SYMBOL TABLE:
00000000 l    d  .init  00000000 
00000000 l    d  *ABS*  00000000 
00000000 l    d  .text  00000000 
00000000 l    d  .fini  00000000 
00000000 l    d  *ABS*  00000000 
00000000 l    d  .data  00000000 
00000000 l    d  .eh_frame      00000000 
00000000 l    d  .ctors 00000000 
00000000 l    d  .dtors 00000000 
00000000 l    d  .bss   00000000 
00000000 l    d  .comment       00000000 
00000000 l    d  .note.netbsd.ident     00000000 
00000000 l    d  *ABS*  00000000 
00000000 l    d  *ABS*  00000000 
00000000 l    d  *ABS*  00000000 
00000080 g     F .init  00000058 _init
00000000  w      *UND*  00000000 __deregister_frame_info
0000003c g     F .fini  00000038 _fini
00000000  w      *UND*  00000000 __register_frame_info

crtendS.o is similar.

So, can anyone shed light on the meaning of .rela.init and .rela.fini,
and why they are showing up in libc.so.12.62.1?

I know I should upgrade to 1.6.  I was trying to get current on 1.5
before jumping branches - this is a remote machine that I only have
access to by asking someone to type over the phone.  BTW I did
successfully bring an i386 box from 1.5-stable to 1.6.1ish via
build.sh by remote login and reboot only, with no console access, so
hats off to the build.sh crew!

  Greg Troxel <gdt@ir.bbn.com>