Can we move location counter backwards?

H. J. Lu hjl@lucon.org
Tue Aug 22 18:04:00 GMT 2006


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?


H.J.



More information about the Binutils mailing list