Node: Location Counter, Next: Operators, Previous: Symbols, Up: Expressions

### The Location Counter

The special linker variable dot `.` always contains the current output location counter. Since the `.` always refers to a location in an output section, it may only appear in an expression within a `SECTIONS` command. The `.` symbol may appear anywhere that an ordinary symbol is allowed in an expression.

Assigning a value to `.` will cause the location counter to be moved. This may be used to create holes in the output section. The location counter may never be moved backwards.

         SECTIONS
         {
           output :
             {
               file1(.text)
               . = . + 1000;
               file2(.text)
               . += 1000;
               file3(.text)
             } = 0x12345678;
         }

In the previous example, the `.text` section from `file1` is located at the beginning of the output section `output`. It is followed by a 1000 byte gap. Then the `.text` section from `file2` appears, also with a 1000 byte gap following before the `.text` section from `file3`. The notation `= 0x12345678` specifies what data to write in the gaps (see Output Section Fill).

Note: `.` actually refers to the byte offset from the start of the current containing object. Normally this is the `SECTIONS` statement, whose start address is 0, hence `.` can be used as an absolute address. If `.` is used inside a section description however, it refers to the byte offset from the start of that section, not an absolute address. Thus in a script like this:

         SECTIONS
         {
             . = 0x100
             .text: {
               *(.text)
               . = 0x200
             }
             . = 0x500
             .data: {
               *(.data)
               . += 0x600
             }
         }

The `.text` section will be assigned a starting address of 0x100 and a size of exactly 0x200 bytes, even if there is not enough data in the `.text` input sections to fill this area. (If there is too much data, an error will be produced because this would be an attempt to move `.` backwards). The `.data` section will start at 0x500 and it will have an extra 0x600 bytes worth of space after the end of the values from the `.data` input sections and before the end of the `.data` output section itself.