Solved

Understanding ldd output

Posted on 2007-03-17
14
2,536 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
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
 
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINUX CENTOS + APACHE 9 61
linux installs 6 48
How to find Linux Server's last patch date 9 37
Linux Copy Command - All Files inc Directory 1 23
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

919 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

16 Experts available now in Live!

Get 1:1 Help Now