-
Notifications
You must be signed in to change notification settings - Fork 171
rt: fix veneer limit position in linker script #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thalesfragoso (or someone else) soon. Please see the contribution instructions for more information. |
Looks good to me. Second opinion? |
Related issue, which explains why this workaround is necessary: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, how weird. I think this is fine then but we should leave a comment behind for the benefit of future readers, something like this?
BTW, I'm not even sure it's a linker bug. The linker puts the veneer directly into the output section For verification, this linker script still works:
Whereas this causes an error
As far as I can tell, there is no way to specify at which location within the section the veneer will be placed. What can be observed is that the linker places the veneer at the very end of the section. So if Conclusion: This pull request seems to be the correct solution. (And |
Ah, I guess that explains it! OK, perfect, I think this PR is fine then. Thanks for explaining. The comment should perhaps reflect that instead, just because otherwise someone might try and move it back inside one day. We could also add a comment to |
Hello! I accepted change from @adamgreig and I'm afraid that everyone have to review this pull request again before it's getting merged on GitHub :) |
add description and hints on linker behavior at symbol `__veneer_limit` Co-authored-by: Adam Greig <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
bors r+
This pull request fixes a CMSE related bug. If we define
#[cmse_nonsecure_call]
segments it would generate functions in.gnu.sgstubs
, but we would eventually found out that for unknown reason__veneer_base
==__veneer_limit
, where SAU configuration to this segment would be impossible.The reason for this bug is unknown, but after this pull request it would link into correct limit value.
I wrote an example for this fix: https://github.com/IoTS-P/trustzone-m-rs/tree/sgstub-fixed . Before this pull request, this project builds but it would print like
SG function stub region is at 0x10005fc0 .. 0x10005fc0
, resulting in secure fault. After this pull request, it would printSG function stub region is at 0x10005fc0 .. 0x10005fe0
and runs successfully.