Overlapping program headers/segments

Max Larsson max.larsson@gmx.de
Sun Sep 24 18:32:04 GMT 2023


Hi everyone,
 
I'm about to (re-)port binutils (mainly the the linker ld) to the amigaos ppc architecture using
elf format.
 
Now I've stumble over a problem, where I need to help, how to fix it.
 
What I have done so far, is to put the .rodata section in its own segment via defining a target
specific method for 'elf_backend_modify_segment'. How to do it, I copied/looked/adapted from
elfxx-mips.c:_bfd_mips_elf_modify_segment_map That works as expected.
 
But The result is that the program headers overlap. Like this:
 
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x10000000 0x10000000 0x02034 0x02034 R E 0x10000
  LOAD           0x020000 0x10010000 0x10010000 0x000f0 0x000f0 RW  0x10000
  DYNAMIC        0x020028 0x10010028 0x10010028 0x000b8 0x000b8 RW  0x4
  LOAD           0x012000 0x10002000 0x10002000 0x00031 0x00031 R   0x10000
 Section to Segment mapping:
  Segment Sections...
   00     .hash .dynsym .dynstr .rela.dyn .rela.got2 .rela.plt .text .plt
   01     .init_array .fini_array .got2 .dynamic .got
   02     .dynamic
   03     .rodata
 
You see, if you take the Virt-/PhysAddr and add the MemSize from the first
program header the result is 0x10002034, which is greater than the Virt-/PhysAddr
of the last program header   0x10002000.

So my question why do I get such a result, and how can I avoid it?

best regards

Max Larsson



More information about the Binutils mailing list