Solved

Understanding ldd output

Posted on 2007-03-17
14
2,681 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
14 Comments
 
LVL 14

Accepted Solution

by:
sjm_ee earned 250 total points
ID: 18739824
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
ID: 18740422
For more information about the iptables command (including output), you can always use :

    man iptables
0
 

Author Comment

by:expertblr
ID: 18740741
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Infinity08
ID: 18740829
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
ID: 18742417
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
ID: 18742436
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
 

Author Comment

by:expertblr
ID: 18746423
any update on this?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 18746730
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
ID: 18754477
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
ID: 18756261
>> so, the address relocation will happen based on the address at which the  shared library is loaded?

Yes.
0
 

Author Comment

by:expertblr
ID: 18777325
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
ID: 18778072
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
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.

717 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