Go to the first, previous, next, last section, table of contents.


Section Data Expressions

The foregoing statements arrange, in your output file, data originating from your input files. You can also place data directly in an output section from the link command script. Most of these additional statements involve expressions (see section Expressions). Although these statements are shown separately here for ease of presentation, no such segregation is needed within a section definition in the SECTIONS command; you can intermix them freely with any of the statements we've just described.

CREATE_OBJECT_SYMBOLS
Create a symbol for each input file in the current section, set to the address of the first byte of data written from that input file. For instance, with a.out files it is conventional to have a symbol for each input file. You can accomplish this by defining the output .text section as follows:
SECTIONS {
  .text 0x2020 :
     {
    CREATE_OBJECT_SYMBOLS
    *(.text)
    _etext = ALIGN(0x2000);
    }
  ...
}
If sample.ld is a file containing this script, and a.o, b.o, c.o, and d.o are four input files with contents like the following---
/* a.c */

afunction() { }
int adata=1;
int abss;
`ld -M -T sample.ld a.o b.o c.o d.o' would create a map like this, containing symbols matching the object file names:
00000000 A __DYNAMIC
00004020 B _abss
00004000 D _adata
00002020 T _afunction
00004024 B _bbss
00004008 D _bdata
00002038 T _bfunction
00004028 B _cbss
00004010 D _cdata
00002050 T _cfunction
0000402c B _dbss
00004018 D _ddata
00002068 T _dfunction
00004020 D _edata
00004030 B _end
00004000 T _etext
00002020 t a.o
00002038 t b.o
00002050 t c.o
00002068 t d.o
symbol = expression ;
symbol f= expression ;
symbol is any symbol name (see section Symbol Names). "f=" refers to any of the operators &= += -= *= /= which combine arithmetic and assignment. When you assign a value to a symbol within a particular section definition, the value is relative to the beginning of the section (see section Assignment: Defining Symbols). If you write
SECTIONS {
  abs = 14 ;
  ...
  .data : { ... rel = 14 ; ... }
  abs2 = 14 + ADDR(.data);
  ...
}
abs and rel do not have the same value; rel has the same value as abs2.
BYTE(expression)
SHORT(expression)
LONG(expression)
QUAD(expression)
SQUAD(expression)
By including one of these four statements in a section definition, you can explicitly place one, two, four, eight unsigned, or eight signed bytes (respectively) at the current address of that section. When using a 64 bit host or target, QUAD and SQUAD are the same. When both host and target are 32 bits, QUAD uses an unsigned 32 bit value, and SQUAD sign extends the value. Both will use the correct endianness when writing out the value. Multiple-byte quantities are represented in whatever byte order is appropriate for the output file format (see section BFD).
FILL(expression)
Specify the "fill pattern" for the current section. Any otherwise unspecified regions of memory within the section (for example, regions you skip over by assigning a new value to the location counter `.') are filled with the two least significant bytes from the expression argument. A FILL statement covers memory locations after the point it occurs in the section definition; by including more than one FILL statement, you can have different fill patterns in different parts of an output section.


Go to the first, previous, next, last section, table of contents.