问题
Looking at the manuals, objdump
and nm
have overlapping features.
When would you use each one? What was the original purpose of each command?
回答1:
They have no similar parameters.
nm
lists file symbols, while objdump
can show a lot of different information about files. objdump
can shows symbols too, and it is explicitly noted in the manpage that "This is similar to the information provided by the nm program, although the display format is different."
回答2:
It seems like nm is posix, so available in non-gnu platforms.
http://pubs.opengroup.org/onlinepubs/000095399/utilities/nm.html
I see for example that OSX doesn't come by default with objdump, but provides "otool" , which offers some of the same features "objdump" offers on linux.
So I guess you would use nm if really all you want is look at symbol tables or similar tasks, and you care about portability of your script. For some other tasks, such as looking into the debug info of a file, objdump might be more appropriate.
来源:https://stackoverflow.com/questions/7219845/difference-between-nm-and-objdump