fix(firmware): prevent LTO from eliminating the ISR vector table#7369
Open
pfeerick wants to merge 1 commit into
Open
fix(firmware): prevent LTO from eliminating the ISR vector table#7369pfeerick wants to merge 1 commit into
pfeerick wants to merge 1 commit into
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 |
Collaborator
|
Tested ok on T14. |
1 task
|
tested on my FrSky X9D Plus 2019 and it now boots |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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