Using GNU Binary Utilities237
7.7.8Using the strings Utility
The
strings
utility displays printable strings in an object file. By default it displays
strings only in initialized and loaded sections of the object file. The object file may be a library
file as well. The following command displays strings in the
a.out
file.
[root@boota]# strings a.out
/lib/ld-linux.so.2
__gmon_start__
libc.so.6
printf
__cxa_finalize
__deregister_frame_info
_IO_stdin_used
__libc_start_main
__register_frame_info
GLIBC_2.1.3
GLIBC_2.0
PTRh
QVh`
Hello world
[root@boota]#
A complete list of all strings in a file can be displayed with the –
a
option on the command
line. Multiple filenames or wild cards can be used on the command line. Using the –
f
option in
this case will display each filename associated with a symbol.
7.7.9Using the addr2line Utility
The
addr2line
utility maps an address in the object file to a line in the source code file.
Consider the following output section of the “
objdump –S a.out
” command that shows
addresses and source codes.
08048460
:
#include
main()
{
8048460:55 push %ebp
8048461:89 e5 mov %esp,%ebp
8048463:83 ec 08 sub $0x8,%esp
printf ("Hello world\n");
8048466:83 ec 0c sub $0xc,%esp
8048469:68 e8 84 04 08 push $0x80484e8
804846e:e8 c9 fe ff ff call 804833c <_init+0x58>
8048473:83 c4 10 add $0x10,%esp
}
The
a.out
file is generated from the following
a.c
file.
1 #include
Next Page >>
<< Previous Page
Back to the Table of Contents