aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2021-11-23 15:40:29 +0000
committerGravatar GitHub <noreply@github.com> 2021-11-23 15:40:29 +0000
commitecf840b80bcc52b426afe93dba9b6d563adbbfce (patch)
treea9a74e96193739b331c5e6778a407abbe210b64c /cortex-m-rt
parent008fd73a1bb8e3d6f635b8aeeb96c57621e52c54 (diff)
parentb38af9d1b6ddd90e2d9a427179bd54e19095d8f6 (diff)
downloadcortex-m-ecf840b80bcc52b426afe93dba9b6d563adbbfce.tar.gz
cortex-m-ecf840b80bcc52b426afe93dba9b6d563adbbfce.tar.zst
cortex-m-ecf840b80bcc52b426afe93dba9b6d563adbbfce.zip
Merge #337
337: Fix unwinding through `Reset` r=thejpster a=jonas-schievink Unwinders may detect the end of the program by seeing `0xFFFFFFFF` in `lr`, which is why code to ensure that it has that value was added in https://github.com/rust-embedded/cortex-m-rt/pull/293. However, the `bl main` overwrites that value with the current program counter. This PR saves the old `lr` value on the stack, and adds debuginfo entries to allow an external unwinder to restore the value. This fixes https://github.com/knurling-rs/probe-run/issues/277 Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Diffstat (limited to 'cortex-m-rt')
-rw-r--r--cortex-m-rt/asm.S8
-rwxr-xr-xcortex-m-rt/assemble.sh14
-rw-r--r--cortex-m-rt/bin/thumbv6m-none-eabi.abin1618 -> 2738 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7em-none-eabi.abin1598 -> 2746 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7em-none-eabihf.abin1622 -> 2778 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7m-none-eabi.abin1598 -> 2746 bytes
-rw-r--r--cortex-m-rt/bin/thumbv8m.base-none-eabi.abin1622 -> 2742 bytes
-rw-r--r--cortex-m-rt/bin/thumbv8m.main-none-eabi.abin1602 -> 2750 bytes
-rw-r--r--cortex-m-rt/bin/thumbv8m.main-none-eabihf.abin1626 -> 2782 bytes
-rw-r--r--cortex-m-rt/build.rs8
10 files changed, 18 insertions, 12 deletions
diff --git a/cortex-m-rt/asm.S b/cortex-m-rt/asm.S
index 6254129..0d078b3 100644
--- a/cortex-m-rt/asm.S
+++ b/cortex-m-rt/asm.S
@@ -94,6 +94,14 @@ Reset:
#endif
4:
+ # Preserve `lr` and emit debuginfo that lets external tools restore it.
+ # This fixes unwinding past the `Reset` handler.
+ # See https://sourceware.org/binutils/docs/as/CFI-directives.html for an
+ # explanation of the directives.
+.cfi_def_cfa sp, 0
+ push {lr}
+.cfi_offset lr, 0
+
# Jump to user main function. We use bl for the extended range, but the
# user main function may not return.
bl main
diff --git a/cortex-m-rt/assemble.sh b/cortex-m-rt/assemble.sh
index b914fed..9b1f15c 100755
--- a/cortex-m-rt/assemble.sh
+++ b/cortex-m-rt/assemble.sh
@@ -9,25 +9,25 @@ crate=cortex-m-rt
# remove existing blobs because otherwise this will append object files to the old blobs
rm -f bin/*.a
-arm-none-eabi-gcc -c -march=armv6s-m asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv6s-m asm.S -o bin/$crate.o
ar crs bin/thumbv6m-none-eabi.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv7-m asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv7-m asm.S -o bin/$crate.o
ar crs bin/thumbv7m-none-eabi.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv7e-m asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv7e-m asm.S -o bin/$crate.o
ar crs bin/thumbv7em-none-eabi.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv7e-m asm.S -DHAS_FPU -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv7e-m asm.S -DHAS_FPU -o bin/$crate.o
ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv8-m.base asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv8-m.base asm.S -o bin/$crate.o
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv8-m.main asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv8-m.main asm.S -o bin/$crate.o
ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o
-arm-none-eabi-gcc -c -march=armv8-m.main -DHAS_FPU asm.S -o bin/$crate.o
+arm-none-eabi-gcc -g -c -march=armv8-m.main -DHAS_FPU asm.S -o bin/$crate.o
ar crs bin/thumbv8m.main-none-eabihf.a bin/$crate.o
rm bin/$crate.o
diff --git a/cortex-m-rt/bin/thumbv6m-none-eabi.a b/cortex-m-rt/bin/thumbv6m-none-eabi.a
index 3ac0777..c145cc6 100644
--- a/cortex-m-rt/bin/thumbv6m-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv6m-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7em-none-eabi.a b/cortex-m-rt/bin/thumbv7em-none-eabi.a
index d38ee46..2d6b6a1 100644
--- a/cortex-m-rt/bin/thumbv7em-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv7em-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7em-none-eabihf.a b/cortex-m-rt/bin/thumbv7em-none-eabihf.a
index a782dce..aa765ea 100644
--- a/cortex-m-rt/bin/thumbv7em-none-eabihf.a
+++ b/cortex-m-rt/bin/thumbv7em-none-eabihf.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7m-none-eabi.a b/cortex-m-rt/bin/thumbv7m-none-eabi.a
index 038af9f..3d1783c 100644
--- a/cortex-m-rt/bin/thumbv7m-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv7m-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv8m.base-none-eabi.a b/cortex-m-rt/bin/thumbv8m.base-none-eabi.a
index ad383aa..a9fb434 100644
--- a/cortex-m-rt/bin/thumbv8m.base-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv8m.base-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv8m.main-none-eabi.a b/cortex-m-rt/bin/thumbv8m.main-none-eabi.a
index ef6e77a..40a5c51 100644
--- a/cortex-m-rt/bin/thumbv8m.main-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv8m.main-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv8m.main-none-eabihf.a b/cortex-m-rt/bin/thumbv8m.main-none-eabihf.a
index 44380fb..6c523af 100644
--- a/cortex-m-rt/bin/thumbv8m.main-none-eabihf.a
+++ b/cortex-m-rt/bin/thumbv8m.main-none-eabihf.a
Binary files differ
diff --git a/cortex-m-rt/build.rs b/cortex-m-rt/build.rs
index 6758d9e..96a8560 100644
--- a/cortex-m-rt/build.rs
+++ b/cortex-m-rt/build.rs
@@ -19,12 +19,10 @@ fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
if target.starts_with("thumbv") {
- fs::copy(
- format!("bin/{}.a", target),
- out_dir.join("libcortex-m-rt.a"),
- )
- .unwrap();
+ let lib_path = format!("bin/{}.a", target);
+ fs::copy(&lib_path, out_dir.join("libcortex-m-rt.a")).unwrap();
println!("cargo:rustc-link-lib=static=cortex-m-rt");
+ println!("cargo:rerun-if-changed={}", lib_path);
}
// Put the linker script somewhere the linker can find it