10.2.1 Mapping Input Sections to Output Sections

Input sections are grouped and mapped into output sections, according to the section map. When an output section contains several different input sections, the exact ordering of input sections may be important. For example, consider the following output section definition:

/* Code Sections */
.text ORIGIN(kseg0_program_mem)  :
{
   *(.text .stub .text.* .gnu.linkonce.t.*)
   *(.mips16.fn.*)
   *(.mips16.call.*)
} >kseg0_program_mem =0

Here the output section named .text is defined. Notice that the contents of this section are specified within curly braces { }. After the closing brace, >kseg0_program_mem indicates that this output section should be assigned to memory region kseg0_program_mem.

The contents of output section .text may be interpreted as follows:

  • Input sections named .text and .stub and input sections that match the wildcard patterns .text.* and .gnu.linkonce.t.* are collected and mapped into the output section. Grouping these sections ensures locality of reference.
  • Input sections that match the wildcard pattern .mips16.fn.* are collected and mapped into the output section.
  • Input sections that match the wildcard pattern .mips16.call.* are collected and mapped into the output section.