.eh_frame for unwinding crate itself missing?
Hi @nbdd0121, thanks for writing this great project. I've tried to integrate this crate as the native unwinder for a riscv bare metal project. I'm kind of new to these dwarf and stack unwinding stuff. Feel free to correct me.
My current way of using this repo is: I defined a #[panic_handler] in my original project, which invokes the unwinding::panic::begin_panic(#some random payload). I found out that with this use pattern, the unwinder always fails immediately, by which I mean it can not even unwind the first stack. The call stack looks like:
panic_handler -> panic::begin_panic -> panicking::begin_panic -> _Unwind_RaiseException -> with_context
the first stack frame unwinding is initiated from with_context. FdeFinder (in my case a static one) then tries to search for the pc within all the fde entries (i've doubled check the pc indeed falls into with_context). However, it always fails to find this exact pc.
The dumped .eh_frame section shows that the all the text address is well covered except those associated this unwinding crate. (the union of pc range from each fde entry is almost consecutive except a blob associated with unwinding is missing). Because of this, our FdeFinder always fails on the first request. Is there anything missing here or I'm totally misusing this crate.
Here is my configure:
default features are turned off, "unwinder", "panic", "fde-static", "personality" are opted in. global_allocator is provided and #[eh_personality] lang is not registered by my original project. linker script is well set up according to the README.
I'm doing cross compile, the target is riscv64gc-unknown-none-elf
rustc 1.80.0-nightly (f705de596 2024-04-30)
binary: rustc
commit-hash: f705de59625bb76067a5d102edc1575ff23b8845
commit-date: 2024-04-30
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
just added -C force-unwind-tables as part of rustc flags when building. The missing pieces (unwind info for unwinding crate) can be found. Any idea why by default cargo discard this part of info?
I think for riscv64gc-unknown-none-elf panic=abort is the default?
Prior to setting the rustc flags, I've tried to force panic=unwind in my Cargo.toml profile section. It is weird that this won't work
We just can not override panic-strategy compiler spec to unwind for those target only supports abort. This is built-in as part of rustc compiler. But it's alright to do it other way around (turning off unwind by setting panic=abort ).
We can custom our target if necessary, some references: compiler-dev-guide and theseus-os. There are some options relevant with unwinding to play with, for example panic-strategy, eh-frame-header.