custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning…
Linker script skill for embedded bare-metal targets. Use when writing or modifying GNU ld linker scripts, placing code and data in specific flash or RAM regions, understanding VMA vs LMA, configuring startup .bss/.data initialization, using MEMORY and SECTIONS commands, or
Claude Code
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill linker-scripts --agent claude-code
Codex
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a codex -y
Cursor
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a cursor -y
Gemini CLI
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a gemini-cli -y
GitHub Copilot
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a github-copilot -y
OpenCode
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a opencode -y
Windsurf
$ npx skills add mohitmishra786/low-level-dev-skills --skill linker-scripts -a windsurf -y
name: linker-scripts description: Linker script skill for embedded bare-metal targets. Use when writing or modifying GNU ld linker scripts, placing code and data in specific flash or RAM regions, understanding VMA vs LMA, configuring startup .bss/.data initialization, using MEMORY and SECTIONS commands, or debugging linker errors about regions. Activates on queries about linker scripts, MEMORY command, SECTIONS command, .bss init, VMA vs LMA, weak symbols, or placing functions in specific memory regions.
Guide agents through writing and modifying GNU ld linker scripts for embedded targets: MEMORY and SECTIONS commands, VMA vs LMA for code relocation, startup `.bss`/`.data` initialization, placing sections in specific regions, and using PROVIDE/KEEP/ALIGN directives.
/* Minimal Cortex-M linker script (works with newlib and C++) */
ENTRY(Reset_Handler) /* entry point symbol */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
}
SECTIONS
{
.text : /* code section */
{
KEEP(*(.isr_vector)) /* interrupt vector must be first */
*(.text)
*(.text.*)
*(.rodata)
*(.rodata.*)
KEEP(*(.init)) /* newlib/crt0 prologue/epilogue */
KEEP(*(.fini))
*(.ARM.extab* .gnu.linkonce.armextab.*) /* unwind data */
. = ALIGN(4);
} > FLASH
.ARM.exidx : /* unwind tables (C++ exceptions, backtraces) */
{
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} > FLASH
.init_array : /* static constructors, run by __libc_init_array() */
{
PROVIDE_HIDDEN(__preinit_array_start = .);
KEEP(*(.preinit_array*))
PROVIDE_HIDDEN(__preinit_array_end = .);
PROVIDE_HIDDEN(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array*))
PROVIDE_HIDDEN(__init_array_end = .);
PROVIDE_HIDDEN(__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array*))
PROVIDE_HIDDEN(__fini_array_end = .);
. = ALIGN(4);
_etext = .; /* end of flash code/constants */
} > FLASH
.data : /* VMA = RAM, LMA = FLASH */
{
_sdata = .;
*(.data)
*(.data.*)
. = ALIGN(4);
_edata = .;
} > RAM AT > FLASH
_sidata = LOADADDR(.data); /* LMA of .data, used by startup copy loop */
.bss (NOLOAD) :
{
_sbss = .;
__bss_start__ = _sbss; /* name newlib crt0 expects */
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = _ebss;
} > RAM
PROVIDE(end = _ebss); /* heap start for newlib _sbrk */
/* Stack at top of RAM */
_estack = ORIGIN(RAM) + LENGTH(RAM);
}The `.init`/`.fini`, `.ARM.exidx`/`.ARM.extab` and `.init_array` rules are needed as soon as newlib, libstdc++ or C++ exceptions are linked in. Without them those sections become orphans after `.text` and overlap the load address of `.data`. `__bss_start__`, `__bss_end__` and `end` are the names newlib's `crt0` and `_sbrk` expect.
For `.data`: stored in flash (LMA), copied to RAM at startup (VMA).
/* VMA in RAM, LMA in the next free spot of FLASH */
.data :
{
_sdata = .;
*(.data)
_edata = .;
} > RAM AT > FLASH
_sidata = LOADADDR(.data); /* where startup code copies from */Prefer `> RAM AT > FLASH` over `AT(_etext)` or `AT(ADDR(.text) + SIZEOF(.text))`. The region form puts the LMA after every section already placed in FLASH (`.ARM.exidx`, `.init_array`, ...). A fixed address ignores them, and they end up overlapping `.data`.
The C runtime must copy `.data` from flash to RAM and zero `.bss` before `main()`:
// startup.c or startup.s equivalent in C
extern uint32_t _sdata, _edata, _sidata; // _sidata = LMA of .data
extern uint32_t _sbss, _ebss;
void Reset_Handler(void) {
// Copy .data from flash to RAM
uint32_t *src = &_sidata;
uint32_t *dst = &_sdata;
while (dst < &_edata) *dst++ = *src++;
// Zero-initialize .bss
dst = &_sbss;
while (dst < &_ebss) *dst++ = 0;
// Call C++ constructors
// (call __libc_init_array() if using newlib)
main();
for (;;); // should never return
}The linker script provides `_sidata` with `_sidata = LOADADDR(.data);`, as in section 1.
/* Place time-critical code in RAM for faster execution */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
RAM (rwx): ORIGIN = 0x20000000, LENGTH = 128K
CCM (rw) : ORIGIN = 0x10000000, LENGTH = 64K /* STM32F4 CCM: data only */
}
.fast_code :
{
. = ALIGN(4);
_sfast = .;
*(.fast_code) /* sections marked __attribute__((section(".fast_code"))) */
. = ALIGN(4);
_efast = .;
} > RAM AT > FLASH /* runs from SRAM, stored in flash */
_sifast = LOADADDR(.fast_code);// Mark a function to go in fast_code section
__attribute__((section(".fast_code"), noinline)) /* noinline: keep it out of flash callers */
void critical_isr_handler(void) {
// runs from SRAM; startup must copy _sifast -> [_sfast, _efast) like .data
}On STM32F4
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning…
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using…
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT…
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting…
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided…
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.