From 67f4ec5782f41224d2d6ff865f0ddc2ef24c7231 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Wed, 1 Sep 2021 15:05:08 +0200 Subject: [PATCH] satman: satisfied libunwind's demands, compiles --- default.nix | 10 ++++++---- src/satman/Cargo.toml | 1 + src/satman/src/main.rs | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index 6b80837d..0e7a29d6 100644 --- a/default.nix +++ b/default.nix @@ -36,12 +36,14 @@ let make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ${if variant == "satellite" then "satman" else "runtime"} ''; + # there's probably a better way to go around it installPhase = '' mkdir -p $out $out/nix-support - cp ../build/runtime.bin $out/runtime.bin - cp ../build/firmware/armv7-none-eabihf/release/runtime $out/runtime.elf - echo file binary-dist $out/runtime.bin >> $out/nix-support/hydra-build-products - echo file binary-dist $out/runtime.elf >> $out/nix-support/hydra-build-products + export FWTYPE=${if variant == "satellite" then "satman" else "runtime"} + cp ../build/$FWTYPE.bin $out/$FWTYPE.bin + cp ../build/firmware/armv7-none-eabihf/release/$FWTYPE $out/$FWTYPE.elf + echo file binary-dist $out/$FWTYPE.bin >> $out/nix-support/hydra-build-products + echo file binary-dist $out/$FWTYPE.elf >> $out/nix-support/hydra-build-products ''; doCheck = false; diff --git a/src/satman/Cargo.toml b/src/satman/Cargo.toml index 3b2b34d8..863dee0f 100644 --- a/src/satman/Cargo.toml +++ b/src/satman/Cargo.toml @@ -25,3 +25,4 @@ libconfig = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["ipv libboard_artiq = { path = "../libboard_artiq" } unwind = { path = "../libunwind" } +libc = { path = "../libc" } \ No newline at end of file diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index ac656fb3..7967411b 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -626,3 +626,28 @@ pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { loop {} } + +// linker symbols +extern "C" { + static __text_start: u32; + static __text_end: u32; + static __exidx_start: u32; + static __exidx_end: u32; +} + + +/// Called by llvm_libunwind +#[no_mangle] +extern fn dl_unwind_find_exidx(pc: *const u32, len_ptr: *mut u32) -> *const u32 { + let length; + let start: *const u32; + unsafe { + // lifted off runtime kernel/core1.rs + // and removed kernel image from there + // hope it works! + length = (&__exidx_end as *const u32).offset_from(&__exidx_start) as u32; + start = &__exidx_start; + *len_ptr = length; + } + start +}