I need to compile the Rust code with no_std, so backtrace is not natively available.
The project is compiled into a ELF, then use objcopy to get only the loadable segments,
then loaded inside Linux kernel by the kernel request_firmware() API.
How can I print the back trace of the program in Rust?
The backtrace should includes the symbol name and symbol address.
If you compile everything (including libcore through eg -Zbuild-std=core) with -Cforce-frame-pointers you can relatively easily get a backtrace by walking the frame pointers. If you have enough room to spare you can also try using the unwinding crate in combination with compiling everything with -Cforce-unwind-tables and ensuring that the .eh_frame section ends up on the device itself. Other than that attaching a debugger and using the backtrace command of the debugger may be the easiest method. You will need some way to attach a debugger for that though. (debug probe?)