Suppose we have a shared library named libtest.so, there is one function "foo" in it
use the strip to discards all symbols from libtest.so
$strip libtest.so
so ,now if we use:
$nm libtest.so
it will print out:
nm: libtest.so: no symbols
but if we use :
$readelf -s libtest.so
foo function still can be seen from its result:
...
10: 000005dc 5 FUNC GLOBAL DEFAULT 12 _Z3foov
...
we also can use command strings to check it:
$strings libtest.so
...
_Z3foov
...
here is my question ,why nm give no result for striped libtest.so?
Thanks
This option causes readelf to print each section header resp. each segment one a single line, which is far more readable on terminals wider than 80 columns. Display the command line options understood by readelf . Read command-line options from file. The options read are inserted in place of the original @ file option.
1 Answer 1 ActiveOldestVotes 64 why nm give no result for striped libtest.so There are twosymbol tables in the original libtest.so: a "regular" one (in .symtaband .strtabsections) and a dynamic one (in .dynsymand .dynstrsections).
Don’t break output lines to fit into 80 columns. By default readelf breaks section header and segment listing lines for 64-bit ELF files, so that they fit into 80 columns. This option causes readelf to print each section header resp. each segment one a single line, which is far more readable on terminals wider than 80 columns.
By default readelf breaks section header and segment listing lines for 64-bit ELF files, so that they fit into 80 columns. This option causes readelf to print each section header resp. each segment one a single line, which is far more readable on terminals wider than 80 columns. Display the command line options understood by readelf .
why nm give no result for striped libtest.so
There are two symbol tables in the original libtest.so
: a "regular" one (in .symtab
and .strtab
sections) and a dynamic one (in .dynsym
and .dynstr
sections).
If strip
removed both symbol tables, you library would be completely useless: the dynamic loader couldn't resolve any symbols in it. So strip
does the only thing that makes sense: removes the "regular" symbol table, leaving the dynamic one intact.
You can see symbols in the dynamic symbol table with nm -D
or readelf -s
.
The "regular" symbol table is useful only for debugging (for example, it contains entries for static functions, which are not exported by the library, and do not show up in the dynamic symbol table).
But the dynamic loader never looks at the "regular" symbol table (which is not in a format suitable for fast symbol lookups); only at the dynamic one. So the "regular" symbol table is not needed for correct program operation, but the dynamic one is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With