diff options
author | 2022-04-28 10:06:50 +0000 | |
---|---|---|
committer | 2022-04-28 10:06:50 +0000 | |
commit | 6c28c81661c67f7331929bb09066ddd49da837e7 (patch) | |
tree | 6f72e1e51ea7f32a7c6256f374d43bce00fe3f1e | |
parent | ec7f7c90e38e8900d368ea7279ee503075503624 (diff) | |
parent | 1606c8809118eafea42db264fc1bb4e0349fa015 (diff) | |
download | cortex-m-6c28c81661c67f7331929bb09066ddd49da837e7.tar.gz cortex-m-6c28c81661c67f7331929bb09066ddd49da837e7.tar.zst cortex-m-6c28c81661c67f7331929bb09066ddd49da837e7.zip |
Merge #434
434: rt: fix veneer limit position in linker script r=adamgreig a=luojia65
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 print `SG function stub region is at 0x10005fc0 .. 0x10005fe0` and runs successfully.
Co-authored-by: luojia65 <me@luojia.cc>
-rw-r--r-- | cortex-m-rt/link.x.in | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cortex-m-rt/link.x.in b/cortex-m-rt/link.x.in index deff376..4461646 100644 --- a/cortex-m-rt/link.x.in +++ b/cortex-m-rt/link.x.in @@ -144,8 +144,12 @@ SECTIONS __veneer_base = .; *(.gnu.sgstubs*) . = ALIGN(32); - __veneer_limit = .; } > FLASH + /* Place `__veneer_limit` outside the `.gnu.sgstubs` section because veneers are + * always inserted last in the section, which would otherwise be _after_ the `__veneer_limit` symbol. + */ + . = ALIGN(32); + __veneer_limit = .; /* ### .bss */ .bss (NOLOAD) : ALIGN(4) |