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


Section Definitions

The most frequently used statement in the SECTIONS command is the section definition, which specifies the properties of an output section: its location, alignment, contents, fill pattern, and target memory region. Most of these specifications are optional; the simplest form of a section definition is

SECTIONS { ...
  secname : {
    contents
  }
... }

secname is the name of the output section, and contents a specification of what goes there--for example, a list of input files or sections of input files (see section Section Placement). The whitespace around secname is required, so that the section name is unambiguous. The other whitespace shown is optional. You do need the colon `:' and the braces `{}', however. secname must meet the constraints of your output format. In formats which only support a limited number of sections, such as a.out, the name must be one of the names supported by the format (a.out, for example, allows only .text, .data or .bss). If the output format supports any number of sections, but with numbers and not names (as is the case for Oasys), the name should be supplied as a quoted numeric string. A section name may consist of any sequence of characters, but any name which does not conform to the standard ld symbol name syntax must be quoted. See section Symbol Names. The special secname `/DISCARD/' may be used to discard input sections. Any sections which are assigned to an output section named `/DISCARD/' are not included in the final link output. The linker will not create output sections which do not have any contents. This is for convenience when referring to input sections that may or may not exist. For example,

.foo { *(.foo) }

will only create a `.foo' section in the output file if there is a `.foo' section in at least one input file.


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