This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Can we move location counter backwards?
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Tue, 22 Aug 2006 10:35:55 -0700
- Subject: Re: Can we move location counter backwards?
- References: <20060822172252.GA5212@lucon.org>
On Tue, Aug 22, 2006 at 10:22:52AM -0700, H. J. Lu wrote:
> The linker manual says "The location counter may never be moved
> backwards." But in the same manual, there are
>
> Note that the `OVERLAY' command is just syntactic sugar, since
> everything it does can be done using the more basic commands. The
> above example could have been written identically as follows.
>
> .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
> __load_start_text0 = LOADADDR (.text0);
> __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
> .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
> __load_start_text1 = LOADADDR (.text1);
> __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
> . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
>
> It moves the location counter backwards implicitly. It is the same as
>
> .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
> __load_start_text0 = LOADADDR (.text0);
> __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
> . = 0x1000;
> .text1 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
> __load_start_text1 = LOADADDR (.text1);
> __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
> . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));
>
> Given that linker does allow/support moving the location counter
> backwards, should we remove "The location counter may never be moved
> backwards." from the linker manual?
Nevermind. The linker manual has been updated.
H.J.