Q: ld scripts for multisegment ELF dynamic executables?

Basile STARYNKEVITCH basile.starynkevitch@wanadoo.fr
Sun Feb 25 05:06:00 GMT 2001


>>>>> "Alan" == Alan Modra <alan@linuxcare.com.au> writes:

    Alan> On Sun, 25 Feb 2001, Basile STARYNKEVITCH wrote:
    >> Any clues or hints?

    Alan> "readelf -l" on a normally linked program, and on one linked
    Alan> by your ldscript will show you the problem.

I already knew about readelf (and prefers the more verbose -a option,
BTW).   


However, I still cannot find the problem. I hacked my ldscript a
bit. Now readelf -l gives on my faulty executable

Elf file type is EXEC (Executable file)
Entry point 0x8048790
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00100 0x00100 R   0x4
  INTERP         0x000134 0x08048134 0x08048134 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x01d60 0x01d60 R E 0x1000
  LOAD           0x002a00 0x08049a00 0x08049a00 0x00104 0x002c8 RW  0x1000
  DYNAMIC        0x002a60 0x08049c20 0x08049c20 0x000a8 0x000a8 RW  0x4
  NOTE           0x001cc8 0x08049cc8 0x08049cc8 0x00098 0x00098 R   0x4
  LOAD           0x003000 0x60000000 0x60000000 0x00010 0x00010 R E 0x1000
  LOAD           0x004000 0x70000000 0x70000000 0x00004 0x00004 RWE 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.got .rel.bss .rel.plt .init .plt .text .fini .rodata .data .eh_frame .ctors .dtors .got .bss .dynamic .note 
   03     .data .eh_frame .ctors .dtors .got .bss .dynamic 
   04     .dynamic 
   05     .note 
   06     TEXTHEAP 
   07     DATAHEAP 

this file still core dumps.

When linking normally (with plain cc, and without my ld script) I get
a good executable:


Elf file type is EXEC (Executable file)
Entry point 0x80484f0
There are 6 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x000c0 0x000c0 R E 0x4
  INTERP         0x0000f4 0x080480f4 0x080480f4 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x00760 0x00760 R E 0x1000
  LOAD           0x000760 0x08049760 0x08049760 0x00104 0x002e0 RW  0x1000
  DYNAMIC        0x0007bc 0x080497bc 0x080497bc 0x000a8 0x000a8 RW  0x4
  NOTE           0x000108 0x08048108 0x08048108 0x00020 0x00020 R   0x4

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.got .rel.bss .rel.plt .init .plt .text .fini .rodata 
   03     .data .eh_frame .ctors .dtors .got .dynamic .bss 
   04     .dynamic 
   05     .note.ABI-tag 

I do not see essential differences.

Does anyone have other clues?

(this is perhaps off topic, but perhaps I would need to know how to
compile a *debugging* version of /lib/ld-linux.so.2 from a
glibc2.2.2. Any hints?) 

 --

Basile STARYNKEVITCH -- http://perso.wanadoo.fr/starynkevitch/basile/
email: basile dot starynkevitch at wanadoo dot fr (France)
alias: basile at tunes dot org       host: http://lesours.dyndns.org/
8, rue de la Faïencerie, 92340 Bourg La Reine, phone: 1.46.65.45.53



More information about the Binutils mailing list