Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be worth an explanation, as it's not something you often come across in ARM asm.

Maybe link to https://sourceware.org/binutils/docs/as/CFI-directives.html, or include their note:

.cfi_def_cfa defines a rule for computing CFA as: take address from register and add offset to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment and link

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
Expand Down
14 changes: 7 additions & 7 deletions assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified bin/thumbv6m-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv7em-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv7em-none-eabihf.a
Binary file not shown.
Binary file modified bin/thumbv7m-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.base-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.main-none-eabi.a
Binary file not shown.
Binary file modified bin/thumbv8m.main-none-eabihf.a
Binary file not shown.
8 changes: 3 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down