Use Addr2line to resolve the function address to the function name www. ibm. the comdeveloperworkscnlinuxl-graphvisAddr2line tool, which is part of the standard GNUBinutils, is a tool that converts the address and executable image of a command to a file name, function name, and number of lines of source code. This feature is applicable
Resolve the function address with Addr2line to the function name http://www.ibm.com/developerworks/cn/linux/l-graphvis/ Addr2line tool (which is part of the standard GNU Binutils) is a tool that converts the instruction address and executable image into a file name, function name, and source code line. This feature is applicable
Use Addr2line to resolve the function address to the function name
Http://www.ibm.com/developerworks/cn/linux/l-graphvis/
The Addr2line tool (which is part of the standard GNU Binutils) is a tool that converts the instruction address and executable image into a file name, function name, and number of lines of source code. This feature is great for converting tracking addresses into more meaningful content.
To understand how this process works, we can test a simple interactive example. (I operate directly from shell, because this is the easiest way to demonstrate this process, as shown in Listing 4 .) In this example, the C file (test. c) usescat
Implemented by a simple application (that is, the standard output text is redirected to a file ). Then use gcc to compile the file. It will pass some special options. First, you must-Wl
Option) notifies the linker to generate an image file and-g
Option) notifies the compiler to generate debugging symbols. Generate an executable fileTest. After obtaining a new executable application, you can usegrep
Find the tool in the Image Filemain
To find its address. Use this address and the Addr2line tool to determine the function name (main
), The source file (/home/mtj/test. c), and its row number in the source file (4 ).
Use the Addr2line Tool-e
Option to specify whether the executable image istest
. Use-f
Indicates the name of the output function.
$ cat >> test.c#include
int main(){ printf("Hello World\n"); return 0;}
$ gcc -Wl,-Map=test.map -g -o test test.c$ grep main test.map0x08048258__libc_start_main@@GLIBC_2.00x08048258main$ addr2line 0x08048258 -e test -fmain/home/mtj/test/test.c:4$