Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a tool to obtain info on a particular symbol in an ELF .o or executable file?

I'm looking for a convenient way (for use in a build testing script) to query individual symbols in an object file. Is there a tool that can answer the question (preferably by its exit status) "does symbol X exist in file Y?" or do I just need to parse the output of nm(1), e.g. with grep and an appropriate regex? Even better would be if such a tool could give detailed information on the symbol (size, type, value, ...).

like image 320
R.. GitHub STOP HELPING ICE Avatar asked Oct 23 '25 16:10

R.. GitHub STOP HELPING ICE


1 Answers

For an executable/shared library, give readelf or Objdump a look over, they can dump a binaries symbols (mangled or unmangled), which you should be able to grep.

Their source is easily obtainable, so you could probably taloir them down into simpler tools for the task at hand or directly import their code base (not that you really need to, you could just load the binary with in question with dlopen and use dlsym to check if the symbol is there).

Objdump is geared towards binaries, nm and readelf will read elf object files.

like image 200
Necrolis Avatar answered Oct 25 '25 04:10

Necrolis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!