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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

238 Chapter 7 • Miscellaneous Tools<br />

2 main()<br />

3 {<br />

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

5 }<br />

Now you can display the line number of the source code file corresponding to address<br />

8048466 in the object file with the following comm<strong>and</strong>:<br />

[root@boota]# addr2line -e a.out 8048466<br />

/root/chap-07/ltrace/a.c:4<br />

[root@boota]#<br />

This is the line where the printf function is called in a.c file. <strong>The</strong> add2line comm<strong>and</strong><br />

is useful in debuggers where you need to map addresses to a line in source code file.<br />

7.8 <strong>Using</strong> the ldd Utility<br />

<strong>The</strong> ldd utility is very useful in finding out the dependencies of an executable on shared libraries.<br />

This is necessary when you are copying executable files from one computer to another to<br />

make sure that required libraries are present on the destination computer also. <strong>The</strong> following<br />

comm<strong>and</strong> shows that libc.so.6 must be present to execute a.out file on a computer.<br />

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

libc.so.6 => /lib/i686/libc.so.6 (0x4002c000)<br />

/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)<br />

[root@boota]#<br />

So if you copy a.out to another computer, make sure that this library is also present on<br />

the destination computer.<br />

7.9 References <strong>and</strong> Resources<br />

1. GNU web site at http://www.gnu.org/<br />

2. <strong>The</strong> cbrowser home page at http://cbrowser.sourceforge.net<br />

3. <strong>The</strong> cscope home page at http://cscope.sourceforge.net

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

Saved successfully!

Ooh no, something went wrong!