Filling Holes

When a hole exists in an initialized output section, the linker must supply raw data to fill it. The linker fills holes with a 32-bit fill value that is replicated through memory until it fills the hole. The linker determines the fill value as follows:

  1. If the hole is formed by combining an uninitialized section with an initialized section, you can specify a fill value for the uninitialized section. Follow the section name with an = sign and a 32-bit constant. For example:
  2. SECTIONS { outsect: { file1.c.obj(.text) file2.c.obj(.bss)= 0xFF00FF00 /* Fill this hole with 0xFF00FF00 */ } }
  3. You can also specify a fill value for all the holes in an output section by supplying the fill value after the section definition:
  4. SECTIONS { outsect:fill = 0xFF00FF00 /* Fills holes with 0xFF00FF00 */ { . += 0x0010; /* This creates a hole */ file1.c.obj(.text) file1.c.obj(.bss) /* This creates another hole */ } }
  5. If you do not specify an initialization value for a hole, the linker fills the hole with the value specified with the --fill_value option (see Section 8.4.14). For example, suppose the command file link.cmd contains the following SECTIONS directive:
  6. SECTIONS { .text: { .= 0x0100; } /* Create a 100 word hole */ }

    Now invoke the linker with the --fill_value option:

    armcl --run_linker --fill_value=0xFFFFFFFF link.cmd

    This fills the hole with 0xFFFFFFFF.

  7. If you do not invoke the linker with the --fill_value option or otherwise specify a fill value, the linker fills holes with 0s.

Whenever a hole is created and filled in an initialized output section, the hole is identified in the link map along with the value the linker uses to fill it.