01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CH07.fm Page 237 Monday, October 7, 2002 9:12 PM<br />

<strong>Using</strong> GNU Binary Utilities 237<br />

7.7.8 <strong>Using</strong> the strings Utility<br />

<strong>The</strong> strings utility displays printable strings in an object file. By default it displays<br />

strings only in initialized <strong>and</strong> loaded sections of the object file. <strong>The</strong> object file may be a library<br />

file as well. <strong>The</strong> following comm<strong>and</strong> displays strings in the a.out file.<br />

[root@boota]# strings a.out<br />

/lib/ld-linux.so.2<br />

__gmon_start__<br />

libc.so.6<br />

printf<br />

__cxa_finalize<br />

__deregister_frame_info<br />

_IO_stdin_used<br />

__libc_start_main<br />

__register_frame_info<br />

GLIBC_2.1.3<br />

GLIBC_2.0<br />

PTRh<br />

QVh`<br />

Hello world<br />

[root@boota]#<br />

A complete list of all strings in a file can be displayed with the –a option on the comm<strong>and</strong><br />

line. Multiple filenames or wild cards can be used on the comm<strong>and</strong> line. <strong>Using</strong> the –f option in<br />

this case will display each filename associated with a symbol.<br />

7.7.9 <strong>Using</strong> the addr2line Utility<br />

<strong>The</strong> addr2line utility maps an address in the object file to a line in the source code file.<br />

Consider the following output section of the “objdump –S a.out” comm<strong>and</strong> that shows<br />

addresses <strong>and</strong> source codes.<br />

08048460 :<br />

#include <br />

main()<br />

{<br />

8048460:55 push %ebp<br />

8048461:89 e5 mov %esp,%ebp<br />

8048463:83 ec 08 sub $0x8,%esp<br />

printf ("Hello world\n");<br />

8048466:83 ec 0c sub $0xc,%esp<br />

8048469:68 e8 84 04 08 push $0x80484e8<br />

804846e:e8 c9 fe ff ff call 804833c <br />

8048473:83 c4 10 add $0x10,%esp<br />

}<br />

<strong>The</strong> a.out file is generated from the following a.c file.<br />

1 #include

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!