Cortex M - linking obj to exisiting elf

2026-07-18

Stack Overflow: View Question

Tags: gcc, linker, arm, elf

Score: 1 | Views: 52

The asker has a Cortex-M firmware image they build themselves, and they want to compile a separate standalone function that calls into the already-flashed functions by their existing absolute addresses. The new function will be flashed into its own page. Nothing gets relinked; the old ELF's symbols must be treated as fixed pins the new object binds against.

What makes this interesting is that it turns the linker inside out. Normally the linker resolves symbols by placing sections and computing addresses. Here, half the symbols already have addresses baked into ROM and cannot move. You need to tell the linker "trust me, foo lives at 0x0800_1234, don't allocate anything for it."

Approach

Gotchas

The challenge: You have to convince the linker that half your symbol table already lives at fixed ROM addresses while still producing position-correct code for a fresh flash page — a workflow the normal build system was never designed to support.

All newsletters