ricardgb opened a new pull request, #19401:
URL: https://github.com/apache/nuttx/pull/19401
## Summary
The pico-sdk-derived rp23xx linker scripts place `.got`/`.got.plt` as
**orphan
sections after the `.data` output section**, so the boot-time `.data` copy —
which runs to `_edata` — never copies the GOT into RAM. Any
position-independent
(`-fPIC`) object linked into an application then reads an **uninitialised
GOT full
of NULLs**: the first GOT-indirected access branches to 0 and the board
hardfaults
before `main()`.
This is not hypothetical — a `-fPIC` static library is enough. In my case a
NuttX
app linking a `-fPIC` `liboqs.a` (whose SHA3 dispatch reads its function
pointers
through the GOT) wedged the board deterministically on its first crypto call.
The fix folds `*(.got)`/`*(.got.plt)` into the `.data{}` section, before
`_edata`,
in all three boot-mode scripts (`memmap_default` / `memmap_copy_to_ram` /
`memmap_no_flash`) for every rp23xx board, so the GOT is initialised in RAM
by the
standard startup copy.
## Impact
- Fixes a boot-time hardfault for any `-fPIC` library linked into an rp23xx
app.
- **No effect on non-PIC images** — the GOT is empty, so the added sections
copy
zero bytes.
- Applies uniformly to `raspberrypi-pico-2`, `xiao-rp2350` and
`pimoroni-pico-2-plus`.
## Testing
Reproduced and fixed on a Raspberry Pi Pico 2 W. With the original scripts,
an app
linking a `-fPIC` `liboqs.a` hardfaulted on its first hardware crypto call
(traced
to a NULL GOT-indirected dispatch pointer; the ELF showed `.got` landing
exactly at
`_edata`, i.e. outside the copied range). After folding `.got` into `.data`,
the
GOT is populated in RAM and the same app runs correctly.
---
*Disclosure: this change was prepared by an AI agent (Claude Code) at the
direction
of the author, who root-caused and tested it on hardware before submission.*
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]