Shared memory between two elf files

2026-05-27

Stack Overflow: View Question

Tags: linker, ld, elf, bare-metal

Score: 1 | Views: 99

The asker has two bare-metal ELF images that will be co-resident in physical memory and wants them to share a region containing both data and code. Their instinct is to drop my_object_file.o(.data) into a fixed-address section (.my_section 0x10000) in both linker scripts and hope the resulting symbols line up.

Why it's tricky: two independent link invocations are exactly that — independent. Even with the same object file and the same address, the linker is free to:

So "include the same .o in the same fixed section" is necessary but not sufficient. You need the addresses, not the inputs, to be the contract between the two ELFs.

A more robust approach:

Gotchas:

The challenge: Two independent linker invocations can't be coerced into producing matching symbol addresses by accident — the shared layout must be linked once and then imported as addresses into both ELFs.

All newsletters