This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: LMA and file offsets in gold
- From: Cary Coutant <ccoutant at gmail dot com>
- To: Eugene Leviant <evgeny dot leviant at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Mon, 21 Nov 2016 14:32:01 -0800
- Subject: Re: LMA and file offsets in gold
- Authentication-results: sourceware.org; auth=none
- References: <CAG0L+yCsegOsVw8avUnUXaQe4c6u5bhvAKLUv+r3BasE6Yg78A@mail.gmail.com>
What you're observing may be a bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=20280
A patch has been proposed here, which I'm reviewing:
https://sourceware.org/ml/binutils/2016-10/msg00161.html
-cary
-cary
On Wed, Sep 21, 2016 at 12:23 PM, Eugene Leviant
<evgeny.leviant@gmail.com> wrote:
> 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 ?