Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why nm libc.so reports no symbols?

Tags:

gcc

libc

nm

I've built a simple program like this:

g++ application.cpp -o application.exe

and then executed the command;

ldd application.exe
...
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 
...

I want to list all the symbols of the libc library:

nm /lib/x86_64-linux-gnu/libc.so.6
nm: /lib/x86_64-linux-gnu/libc.so.6: no symbols

nm --defined-only /lib/x86_64-linux-gnu/libc.so.6
nm: /lib/x86_64-linux-gnu/libc.so.6: no symbols

Why nm reports no symbols? If libc.so.6 is not a library, but a some kind of a link to the actual library, then how can I find the actual library?

like image 662
Alexey Avatar asked Jan 05 '19 13:01

Alexey


People also ask

What does the output of nm mean?

The nm commands provides information on the symbols being used in an object file or executable file. The default information that the 'nm' command provides is : Virtual address of the symbol. A character which depicts the symbol type.

How do I see the symbol table in Linux?

nm displays the symbol table that is associated with an object, archive library of objects, or executable files. By default, nm lists the symbols in file in alphabetical order by name and provides the following information about each: File or object name (if you specified -A). Symbol name.

How do I view a .so file?

Instead, they're just placed in an appropriate folder and used automatically by other programs via Linux's dynamic link loader. However, you might be able to read the SO file as a text file by opening it in a text editor like Leafpad, gedit, KWrite, or Geany if you're on Linux, or Notepad++ on Windows.

How do you use nm command?

nm (name mangling) is a Unix command used to dump the symbol table and their attributes from a binary executable file (including libraries, compiled object modules, shared-object files, and standalone executables). The output from nm distinguishes between various symbol types.


1 Answers

By default, nm reads the .symtab section in ELF objects, which is optional in non-relocatable objects. With the -D/--dynamic option, you can instruct nm to read the dynamic symbol table (which are the symbols actually used at run time). You may also want to use --with-symbol-versions because glibc uses symbol versioning extensively.

Alternatively, you can use eu-readelf --symbols=.dynsym or objdump -Tw. (readelf -sDW does not include symbol versioning information.)

like image 148
Florian Weimer Avatar answered Sep 24 '22 18:09

Florian Weimer