This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
LMA and file offsets in gold
- From: Eugene Leviant <evgeny dot leviant at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 21 Sep 2016 22:23:36 +0300
- Subject: LMA and file offsets in gold
- Authentication-results: sourceware.org; auth=none
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 ?