fix(firmware): prevent LTO from eliminating the ISR vector table#7369
Conversation
With LTO (-flto), the linker can discard the _isr_vector[] array because no C code references it directly (the hardware uses it via the VTOR register). KEEP() in the linker script prevents gc-sections from removing it, but LTO operates before that stage and can eliminate the symbol entirely, resulting in an empty .isr_vector section. Adding 'used' to ISR_VECTOR matches the same fix already applied to the BOOTSTRAP macro and init_hooks() in system_init.c. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe ISR vector table macro is updated to retain ISR entries in the final binary by adding the ChangesISR Vector Attribute Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
|
Tested ok on T14. |
|
tested on my FrSky X9D Plus 2019 and it now boots |
raphaelcoeffic
left a comment
There was a problem hiding this comment.
LGTM, I hope you verified it ;-)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
-flto) enabled (currently used for X9D+2019 builds), the linker discards_isr_vector[]because no C code references it directly — the hardware reads it via theVTORregister.KEEP()in the linker script prevents gc-sections from removing it, but LTO operates before that stage and eliminates the symbol entirely, resulting in an empty.isr_vectorsection..fwversiondata(the version string) placed at the application start offset (BOOTLOADER_SIZE) instead of the ARM vector table, soisFirmwareStart()reads ASCII bytes instead of valid stack/ISR pointers and rejects the file asFC_ERROR.usedto theISR_VECTORmacro incortex_m_isr.h, matching the same pattern already applied toBOOTSTRAPandinit_hooks()insystem_init.cas part of the LTO work.Test plan
.isr_vectorsection is non-empty infirmware.map🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes