Widely Vision

  • Real History of Israel

  • Poll

  • Get a PDF version

  • Follow This Blog

  • February 2010
    S M T W T F S
     123456
    78910111213
    14151617181920
    21222324252627
    28  

Deeper in Libraries With GCC(4)

Posted by aboelnour on February 19, 2010

peace be upon you:

After making your library you will need to edit it or just read it’s Contents.
—————————-
Listing Symbols Names in Object Files:
The nm utility can be used to list all the symbols defined in (or referenced from) an object file, a static archive library, or a shared library. If no file is named on the command line, the file name a.out is assumed

run:

nm libc.a

look the man page for more info about options.
——————-
Removing Unused Information from Object Files:
The strip utility removes the debugging symbol table information from the object file or files named on the command line. The object file can be a static library, a shared library, or a .o file produced by the compiler. Depending on how much debugging information has been included in the file, stripping can dramatically reduce the size of the file.

run:

strip main.o libglom.a

this command will strip all debugging information
from the object file main.o and all the object files in the library libglom.a

The strip utility replaces the existing file with the stripped version, so if you want to be able to restore the original unstripped versions, you will need to save the files before stripping them or use the -o option to produce the output in a different file.
——————-
Listing Shared Library Dependencies:
The ldd utility reads through the object files in the binary executable or shared library named on the command line and lists all the shared library dependencies.

For example,the following command lists the shared libraries used by the bash shell program on a Linux system:

ldd /bin/bash

output:

linux-gate.so.1 =>  (0xb8022000)
libncurses.so.5 => /lib/libncurses.so.5 (0xb7fc3000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7fbf000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e60000)
/lib/ld-linux.so.2 (0xb8008000)

this is the shared objects which the bash use it the ldd utility determine the library and it’s path on your hard.
—————————-

that’s the end of our series.I hope that any one find it helpful. Any question is welcomed.

regards,

aboelnour.

2 Responses to “Deeper in Libraries With GCC(4)”

  1. sigtermer said

    Thanks for this series. It’s been a long while since I learned something new about gcc and linux development.

    I would ask you for your reason behind not writing the series in arabic but I have a feeling I know what your reason is. Until a few months ago, I too didn’t write technical articles in arabic and in fact apposed the idea. but I realized something that changed how I see things.

    anyways, thanks again for the great series, and keep up the good work 🙂

    • aboelnour said

      great that you like it 🙂
      For writing in Arabic, I love my mother tongue, but to write posts like this in Arabic it might take some extra time.
      I believe that we can use Arabic in scientific subjects, but my main language in the collage is English.
      thanks

Leave a reply to aboelnour Cancel reply