LMA and file offsets in gold

Eugene Leviant evgeny.leviant@gmail.com
Wed Sep 21 19:23:00 GMT 2016


I'm wondering what algorithm is used by gold when assigning file
offsets for sections in ELF image. At a very first glance it looks
like following:

- Normally file offset in equal to LMA modulo page size (unless
section has AT specifier LMA is equal to VMA).

- Things change when two or more sections with non-zero LMA offset
share the same PT_LOAD. This can be achieved using the following
linker script:

PHDRS {
  all PT_LOAD;
}

SECTIONS {
  .foo 0x800000 : AT(0) { *(.foo) } : all
  .bar 0x900000 ; { *(,bar) } : all
}

In such case file offset of output section .bar is file offset of .foo
+ (0x900000 - 0x800000).
Does anyone know how exactly those offsets are computed ?



More information about the Binutils mailing list