问题
I am working on some diagnostic tools to help locate memory issues on an embedded ARM platform. Due to memory constraints, I can't load all symbols for all libraries on the unit itself. What information do I need to save to be able to resolve symbols later on a different machine?
The machine where I will resolve the symbols is an x86 machine that has a cross toolchain and gdb with all the symbol packages needed. What would I use to resolve the symbols in a batch from this information I've saved in my diagnostic output? Is there a library or API for doing the resolving?
回答1:
The following information is related to Android. Some of it parts are also compiled into ELF files for ARM architecture so it may be useful in your case.
Building process looks like this:
- Everything is compiled with debug information (
gcc -g ...
) - Then all binaries are stripped and packed into system image. But original not-stripped version for every binary file remains in a build directory.
- System image is flashed on the target device.
So to resolve symbols from diagnostic output you can use arm-linux-androideabi-addr2line
. Example:
${CROSS_COMPILE}addr2line --demangle -f -e PATH_TO_NOT_STRIPPED_BINARY ADDRESS
Additional information can be found it this question: How to use addr2line.
I also prepared a very simple python script which automates this process: decode_callstack.py (it works with Android diagnostic output and you need to change PREFIX variable before use)
来源:https://stackoverflow.com/questions/14402248/delayed-symbol-resolving