?
Solved

Understanding ldd output

Posted on 2007-03-17
14
Medium Priority
?
2,722 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 1000 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 1000 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
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

 
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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