liveBook · Manning

Linker section

As explained in Embedded Software with Rust

A linker section is a named region of an object or executable image containing input or output data such as code, initialized data, or uninitialized data.

A linker section is a named group of program symbols, such as code, data, or vector-table entries. Rust’s `#[unsafe(link_section = "...")]` tags a symbol with a section name; the linker script—not the attribute—assigns that section to a physical memory region. section 5.4.4

In bare-metal Rust, named sections help organize firmware symbols for specific linker-script placement:

  • Place core exceptions and device interrupt handlers in order within the vector table in flash. section 4.2.3 section 4.5.4
  • Tag a buffer for a custom section and map it to DTCM for predictable data access. section 5.4.4
  • Reserve a section for defmt format strings and logging metadata; transport crates configure it automatically in normal use. section 6.3.3
MEMORY {
  ITCM     : ORIGIN = 0x00000000, LENGTH = 64K
  DTCM     : ORIGIN = 0x20000000, LENGTH = 64K
  FLASH    : ORIGIN = 0x08000000, LENGTH = 1M
}

SECTIONS {
  .tcm_data (NOLOAD) : ALIGN(4) {
    KEEP(*(.tcm_data*))
  } > DTCM
}

This linker-script example defines memory regions and maps the custom .tcm_data section into DTCM. section 5.4.4

How Embedded Software with Rust covers it

How deep it goes
Distinguishes symbol tagging from physical placement and demonstrates vector-table and TCM mappings.
Examples
Uses exception and interrupt tables in flash and a performance-critical buffer mapped into DTCM.
What you can do after
Configure Rust symbols for named sections and map those sections to physical memory with a linker script.
How it connects
Connects linker sections to linker scripts, vector tables, and memory regions such as DTCM.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.