diff options
| author | Frédéric Desbiens <[email protected]> | 2026-09-15 16:24:54 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-09-15 16:24:54 -0400 |
| commit | 201cc046092a8751cdf88cc8614b7cf4a7595838 (patch) | |
| tree | 809fbe8421b6a90fec15242276f84016ffcc8195 /common_modules/module_lib/src/txm_module_object_pointer_get.c | |
| parent | 3e5a16c95bff3086cc28fecec292894a4f94a34d (diff) | |
Applied R_ARM_RELATIVE relocations at GNU ThreadX module startup (#731)
Fixes #230
`gcc_setup.s` rebases the GOT and copies initialized data into the module data
area, but never applies the relocations the linker records for words inside that
data. A global initialized with a link-time constant -- `char *pBuffer = buffer;`,
a function pointer, a struct member holding a string literal's address -- kept
its link address and pointed outside the loaded module.
`gcc_setup.s` now walks `.rel.dyn` after the data copy and adjusts every
`R_ARM_RELATIVE` entry targeting the module data area, reusing the GOT loop's
base arithmetic and skip rules, and reloading the flash base first because
`crt0_memory_copy` clobbers `r3`.
The table is only emitted with `-pie`, so the example build scripts now pass
`-pie --no-dynamic-linker` and the example linker scripts discard `.dynamic`,
which `-pie` would otherwise place at address zero and inflate the image to
nearly 200 KB. Without `-pie` the table is empty and the loop is a no-op.
Covers Cortex-M3, M4, M7, M33 and M0+. Cortex-M23 ships no module linker or
build script and AArch64 uses a different relocation format; both left for a
follow-up.
Verified on `qemu-system-arm` with a module linked at one address and loaded at
another: char, function, string and struct-member pointers all resolve to the
loaded addresses, and the same module built without `-pie` still runs.
Assisted-by: Copilot (Opus 5) <[email protected]>
Diffstat (limited to 'common_modules/module_lib/src/txm_module_object_pointer_get.c')
0 files changed, 0 insertions, 0 deletions
