Subject: Binutils 2.10 and Dynamic Loader

From: Shay Deloya <[email-masked]>
Date: Thu, 17 May 2001 10:18:51 +0300

Hi,

I'm trying to use binutils 2.10 (BU) , and compiling x.c file that depend on
 libx.so file that I've created ( both files don't use glibc). The shared
 object has only two variables both initialized of type  int and char*
 ("Welcome").

When compiling the SO with BU 2.8 I see that the <data> section (see below) is
 created for the string with "pointing" to the <.rodata> section, loading the
 file with ld.so.1 makes the relocation OK , by adding the shared library
 address to this offset.

However , compiling the SO with BU 2.10 I see that the <data> section (see
 below) is created for the string without pointing to the <.rodata> section,
 and letting the loader to make 'complicated' relocation using the
 relocation table (elf header). Since rodata is a section , the dynamic
 loader ld.so.1 only adds the offset to that symbol , and there for the
 relocation is done in wrong way. Is it a problem of the 2.10 ld  , or a
 problem of the dynamic loader (libc.2.0.6) ?  does anyone had the same
 problem before ?

BTW , the  copile flags are : 
for the so : -Wl,-dynamic-linker,"/lib/ld.so.1" -nostdlib  -Wl,-e,main  
 	and the mips-linux-ld libx.o -share libx.so
and for the x.c : -nostdlib

Thanks , Shay

2.10
=====
000000005ffe0540 <.rodata>:
    5ffe0540:	57656c63 	0x57656c63
    5ffe0544:	6f6d6500 	0x6f6d6500
	...

0000000060020570 <.data>:
    60020570:	0000000a 	0xa
	...

from readelf on the .so file:

Relocation section '.rel.dyn' at offset 0x550 contains 3 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  00000000  00000 R_MIPS_NONE
  60020574  01f03 R_MIPS_REL32          60020570  num
  60020578  00703 R_MIPS_REL32          5ffe0540  .rodata

2.8
====

000000005ffe04d0 <.rodata>:
    5ffe04d0:	57656c63 	0x57656c63
    5ffe04d4:	6f6d6500 	0x6f6d6500
	...

0000000060020510 <.data>:
    60020510:	0000000a 	0xa
    60020518:	5ffe04d0 	0x5ffe04d0
    6002051c:	00000000 	nop

fro readelf on the .so file:

Relocation section '.rel.dyn' at offset 0x4e0 contains 3 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  00000000  00000 R_MIPS_NONE
  60020514  00003 R_MIPS_REL32
  60020518  00003 R_MIPS_REL32