strip vs. nm vs. readelf

Daniel Jacobowitz drow@false.org
Wed Dec 14 21:37:00 GMT 2005


On Wed, Dec 14, 2005 at 10:24:11PM +0100, Erik Leunissen wrote:
> L.S.
> 
> I stumble across some apparent contradictory behaviour of the 
> applications strip, nm and readelf.
> 
> This occurs when processing a shared lib "myLib.so" which has been 
> subjected to the strip application as follows:
> 
>     strip --strip-unneeded myLib.so

       --strip-unneeded
           Remove all symbols that are not needed for relocation processing.

... but leaves the dynamic symbol table; that is always necessary.

> Next, when I invoke:
> 
>     nm -a myLib.so
> 
> the output is (as expected):
> 
>     nm: myLib.so: no symbols

Try nm -D myLib.so.

> Finally, when doing:
> 
>     readelf -a myLib.so
> 
> a lot of information is emitted, including the names of symbols that I 
> believed to be removed by strip.

See which section it says they're in.  They'll be in .dynsym, which is
part of the executable image.

-- 
Daniel Jacobowitz
CodeSourcery, LLC



More information about the Binutils mailing list