Solved

Understanding ldd output

Posted on 2007-03-17
14
2,511 Views
Last Modified: 2011-10-03
HI,

      Can anyone explain me the output of ldd command. For example, when I run the ldd command on iptables executeable, I understand iptables is using  libdl.so.2 and  libc.so.6 shared libraries. But I am looking for a good explanation on the addresses mentioned just beside each shared objects.

Please explain what that addresses indicate....

#     ldd /sbin/iptables
        libdl.so.2 => /lib/libdl.so.2 (0x40034000)
        libc.so.6 => /lib/i686/libc.so.6 (0x40037000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)


Thanks
0
Comment
Question by:expertblr
  • 6
  • 5
14 Comments
 
LVL 14

Accepted Solution

by:
sjm_ee earned 250 total points
Comment Utility
The addresses are those at which the shared library will be loaded in the process memory map. Compare with the output of pmap.
0
 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 250 total points
Comment Utility
For more information about the iptables command (including output), you can always use :

    man iptables
0
 

Author Comment

by:expertblr
Comment Utility
Thanks.

can anyone explain me with an example on how the address relocation will happen when shared libraries are used.  I did get some links on google, but it is very difficult to understand.
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
This is a quite technical article on the subject :

http://www.securityfocus.com/infocus/1872

Have you already read that ?

It is not an easy subject, so finding an easy way to explain it is not trivial.
0
 

Author Comment

by:expertblr
Comment Utility
I read that article....Its quite difficult to understand.  I will really appriciate if someone can explain me the concept of address relocation with a simple example.


Thanks
0
 

Author Comment

by:expertblr
Comment Utility
Hi sjm_ee,


  You've said: The addresses are those at which the shared library will be loaded in the process    memory map.

what if those addresses are already used by some other process?


Thanks.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:expertblr
Comment Utility
any update on this?
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
First of all, I just noticed that I mistyped earlier ... it should have been

     man ldd

To find out more about the ldd output of course :)


>> I will really appriciate if someone can explain me the concept of address relocation with a simple example.

I assume you read the "How it works" part of the article I posted ?

The addresses listed in the ldd output are the addresses where the respective libraries can be found in memory (absolute addresses). Or in other words, they are the versions of the libraries that were found at the moment ldd was run.
The libraries are loaded at that (virtual) address by the dynamic loader ld-linux.so.2.

How does ldd work, you might add ? Well, it runs the application in a special mode. This mode only prints out the dynamic libraries used by the application, along with the version of the library it found (using LD_LIBRARY_PATH). Some versions of ldd (like yours) also print out the address in memory where that library can be found.

Does this answer your question ? If not, can you tell me what you don't understand ?
0
 

Author Comment

by:expertblr
Comment Utility
Thanks infinity.

So that means,  the ldd command on an executable will  show the memory at which the library
is currently loaded, am I right?

so, the address relocation will happen based on the address at which the  shared library is loaded?


Thanks
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
>> so, the address relocation will happen based on the address at which the  shared library is loaded?

Yes.
0
 

Author Comment

by:expertblr
Comment Utility
Thanks you very much.

One more question:

    Suppose if the shared library is not loaded to memory and if we run ldd comand on an executable (assuming the shared libray of this executable is not in memory)  what will the ldd command  output will show?


0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
The ldd command is gonna start the executable in the special mode I mentioned. The executable is gonna load the missing library in memory, and is gonna output which version it picked, and at what address in memory it placed it.
However, since that library had to be loaded in memory by the application, it's probably gonna be removed from memory again when the ldd command ends. So, the address listed has not much meaning.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now