Help needed - defining the output section order

Simon Kissel scamp@untergrund.net
Mon Aug 22 22:27:00 GMT 2005


Hi Nick,

NC> Which turns into:

NC> PHDRS
NC> {
NC>    headers PT_PHDR PHDRS ;
NC>    interp PT_INTERP ;
NC>    text PT_LOAD FILEHDR ;
NC>    data PT_LOAD ;
NC>    dynamic PT_DYNAMIC ;
NC>    note PT_NOTE ;
NC>    gnu_eh_frame  0xa74e550 ;
NC>    gnu_stack 0xa74e551 ;
NC>    extra PT_LOAD ;
NC> }

Ok, so I tried this.

Here is the script:

SECTIONS
{
  /* Read-only sections, merged into text segment: */
  PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
[...etc, the copied default ld script for elf_i386]
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /DISCARD/ : { *(.note.GNU-stack) }
  fpc.ressym    : { *(fpc.ressym) }   :extra
  fpc.resstr    : { *(fpc.resstr) }   :extra
  fpc.reshash   : { *(fpc.reshash) }  :extra
  fpc.resdata   : { *(fpc.resdata) }  :extra
  fpc.resspare  : { *(fpc.resspare) } :extra
}

PHDRS
{
   headers PT_PHDR PHDRS ;
   interp PT_INTERP ;
   text PT_LOAD FILEHDR ;
   data PT_LOAD ;
   dynamic PT_DYNAMIC ;
   extra PT_LOAD ;
}
SEARCH_DIR(.\)
[...and so on]
INPUT(
[...and so on]
)

Well, it works. Sort of. The resulting executable now is >130 MB in
size, and completely broken:

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00001034 0x00000000 0x000c0 0x000c0 R   0x4
  INTERP         0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4
      [Requesting program interpreter: ¦ELF???]
  LOAD           0x000000 0x00000000 0x00000000 0x000f4 0x000f4 R   0x1000
  LOAD           0x0000f4 0x00000000 0x00000000 0x00000 0x00000     0x1000
  DYNAMIC        0x000000 0x00000000 0x00000000 0x00000 0x00000     0x4readelf:
Warning: the .dynamic section is not contained within the dynamic segment
  LOAD           0x001098 0x00000098 0x00000098 0x807d738 0x8080510 RWE 0x1000

Hrmm?! ;)

Simon




More information about the Binutils mailing list