Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge #294
Browse files Browse the repository at this point in the history
294: add CFI and size info r=jonas-schievink a=japaric

like it was done in rust-embedded/cortex-m#216 and rust-embedded/cortex-m#212

Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
  • Loading branch information
bors[bot] and japaric authored Sep 7, 2020
2 parents 427705f + 61acfb2 commit 046c8f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Various fixes to the linker script ([#265], [#286]).
- Use the correct ABI for the `main` symbol ([#278]).
- Add barriers after FPU enabling ([#279]).
- (ARMv6-M) Set LR value to a known value on reset (as the ARM spec requires)
- Added CFI and size info to external assembly subroutines (`HardFaultTrampoline` and `FpuTrampoline`)

[#265]: https://github.com/rust-embedded/cortex-m-rt/pull/265
[#278]: https://github.com/rust-embedded/cortex-m-rt/pull/278
Expand Down
11 changes: 11 additions & 0 deletions asm.s
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
.cfi_sections .debug_frame

# LLD requires that the section flags are explicitly set here
.section .HardFaultTrampoline, "ax"
.global HardFaultTrampoline
# .type and .thumb_func are both required; otherwise its Thumb bit does not
# get set and an invalid vector table is generated
.type HardFaultTrampoline,%function
.thumb_func
.cfi_startproc
HardFaultTrampoline:
# depending on the stack mode in EXC_RETURN, fetch stack pointer from
# PSP or MSP
Expand All @@ -17,13 +20,16 @@ HardFaultTrampoline:
0:
mrs r0, PSP
b HardFault
.cfi_endproc
.size HardFaultTrampoline, . - HardFaultTrampoline

.section .text.FpuTrampoline, "ax"
.global FpuTrampoline
# .type and .thumb_func are both required; otherwise its Thumb bit does not
# get set and an invalid vector table is generated
.type FpuTrampoline,%function
.thumb_func
.cfi_startproc
# This enables the FPU and jumps to the main function.
FpuTrampoline:
# Address of SCB.CPACR.
Expand All @@ -40,6 +46,8 @@ FpuTrampoline:
# Hand execution over to `main`.
bl main
# Note: `main` must not return. `bl` is used only because it has a wider range than `b`.
.cfi_endproc
.size FpuTrampoline, . - FpuTrampoline

# ARMv6-M leaves LR in an unknown state on Reset
# this trampoline sets LR before it's pushed onto the stack by Reset
Expand All @@ -49,8 +57,11 @@ FpuTrampoline:
# get set and an invalid vector table is generated
.type PreResetTrampoline,%function
.thumb_func
.cfi_startproc
PreResetTrampoline:
# set LR to the initial value used by the ARMv7-M (0xFFFF_FFFF)
ldr r0,=0xffffffff
mov lr,r0
b Reset
.cfi_endproc
.size PreResetTrampoline, . - PreResetTrampoline

0 comments on commit 046c8f5

Please sign in to comment.