I'm trying to develop an application with Rust on an RTOS. I'm using armv7a-none-eabi as the target, but I've found that the compiled output always has a lot of ARM.exidx segments, which is related to unwind. I set panic = abort, and as expected, there should be no unwind-related segments in the compiled output.
This also caused my compilation results to be extremely bloated. Only a static library with the simplest add function had a binary size of 900kb.
If you are using the cortex-m-rt crate an appropriate linker script should be generated automatically and it can be enabled by passing -C link-arg=-Tlink.x to rustc. It may not be appropriate for use with an RTOS though. If your RTOS provides a linker script for applications to use, make sure to pass it to the linker and add the DISCARD block if it isn't there already.
So It can't be done by rustc automatically by passing some arguments? Do you think it sounds great to implement a similar mechanism in Rust? I think this is an implicit behavior and should be replaced by a more explicit behavior.
The target specification for armv7a-none-eabi declares panic=abort and doesn't force unwind tables, so it seems to be LLVM which decided to emit unwind tables despite nothing forcing them to be present.
I found a discussion here : [llvm-dev] Is it possible to remove ARM.exidx section?. It seems that pass arguments -fno-exceptions -fno-unwind-tables -Os can remove ARM.exidx section, but I can't find out such a way to pass it to llvm in rust