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
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 ;
&= += -= *= /=
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)
QUAD
is only supported when
using a 64 bit host or target.
Multiple-byte quantities are represented in whatever byte order is
appropriate for the output file format (see section BFD).
FILL(expression)
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.