aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/link.x.in
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-26 23:04:03 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-10-26 23:28:45 +0200
commit98eb7ea7816e17b38f03c39173804358adb15a7c (patch)
tree72640c733b9968e6bbdbb47f6fd258c93c7e9011 /cortex-m-rt/link.x.in
parent3d4361409a94774c960e4c95007a8740d558506b (diff)
downloadcortex-m-98eb7ea7816e17b38f03c39173804358adb15a7c.tar.gz
cortex-m-98eb7ea7816e17b38f03c39173804358adb15a7c.tar.zst
cortex-m-98eb7ea7816e17b38f03c39173804358adb15a7c.zip
`b UserHardFault`
this commit replaces the `bl UserHardFault` instruction in HardFault with `b UserHardFault`. This lets us drop the prologue (`push {r0,lr}`) while preserving the ability to unwind the stack using GDB. To prevent linker errors about relocations when UserHardFault and HardFault end up far away from each other and the target is ARMv6-M (where the `b` instruction only supports offsets of +/- 2KB) we use two *input* sections: .HardFault and .UserHardFault. HardFault is placed in the .HardFault section and UserHardFault is placed in the .UserHardFault section. The .HardFault input section is placed in the output .text section after all the input .text sections, and the .UserHardFault input section is placed after the .HardFault section. This causes the two symbols to always appear next to each other in the output binary, furthermore UserHardFault *always* appears after HardFault so the branch offset of `b UserHardFault` is always a few bytes. It should be noted that neither .HardFault or .UserHardFault will appear in the output of the `size -A` command as they are input sections that get merged into the output .text section. IOW, the sizes of HardFault and UserHardFault will continue to be reported under the .text section.
Diffstat (limited to 'cortex-m-rt/link.x.in')
-rw-r--r--cortex-m-rt/link.x.in2
1 files changed, 2 insertions, 0 deletions
diff --git a/cortex-m-rt/link.x.in b/cortex-m-rt/link.x.in
index fde4e70..e6e0d3b 100644
--- a/cortex-m-rt/link.x.in
+++ b/cortex-m-rt/link.x.in
@@ -86,6 +86,8 @@ SECTIONS
.text _stext :
{
*(.text .text.*);
+ *(.HardFault);
+ *(.UserHardFault);
} > FLASH
/* ### .rodata */