2

From where can I download readelf and objdump binaries for OS X? I'm trying to get the list of exported functions from an NDK .so library and neither nm nor otool worked for me. I've read that the library might be in elf format and that readelf or objdump might work.

I was able to find the source code for those utilities but I would like the binaries. Surely they've been compiled by someone already.

There was a lot of information in this SO article: How do I list the symbols in a .so file It is there that readelf and objdump are recommended when nm did not work for me.

Community
  • 1
  • 1
Alyoshak
  • 2,696
  • 10
  • 43
  • 70
  • Those are _Linux_ tools. Even [MacPorts](https://www.macports.org) doesn't have them. _OSX_ (at least _Yosemite_) has the nice native `otool`. – CristiFati Nov 12 '15 at 23:18
  • 1
    otool has not worked for me (as mentioned in the question). If you can recommend the correct use of it go ahead. Most of the time I get "libMylib.so is not an object file" but sometimes I get nothing at all. Man page help is cryptic. I just need the exported function names. – Alyoshak Nov 12 '15 at 23:44
  • Yes, sorry for not paying attention, a good chance to find such utilities, is [MacPorts](https://www.macports.org/). – CristiFati Nov 13 '15 at 00:01
  • Will readelf and objdump work on OS X? – Alyoshak Nov 13 '15 at 00:07
  • If they are part of _MacPorts_ (or better to say if someone spent time to make them work (which is terribly difficult, and sometimes impossible), yes; but I seriously doubt (I don't have my _MAC_ machine in front of me, there I use `otool`); there are separate sets of binaries that don't work cross platforms (same thing when a _Linux_ executable is attempted to be run on _Windows_). – CristiFati Nov 13 '15 at 00:16

1 Answers1

7

These tools are available as part of the NDK. You'll find them in the toolchains subdirectory within the NDK, e.g. android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objdump. There's also a version of the nm utility there which will understand your ELF .so files, arm-linux-androideabi-nm in the same path as above.

mstorsjo
  • 12,983
  • 2
  • 39
  • 62
  • Found 'em indeed (listed as an "Alias" in Finder) in darwin-x86_64/arm-linux-androideabi/bin. But when I ran nm -g libMylib.so nothing happened -- at all. When I ran objdump -TC libMylib.so I got: objdump: command not found. Then I saw the arm-linux-androideabi-nm and arm-linux-androideabi-objdump files (listed as "Unix Executable File" in Finder) in the darwin-x86_64/bin dir. The attempt to use both of them resulted in "command not found". I placed libMylib.so right in the very folder with the utility I'm trying to run. – Alyoshak Nov 13 '15 at 17:08
  • It is clear you have correctly answered my question of how to obtain these binaries even though I cannot yet use them to get the symbols. I need to mark this as the correct answer for others, and will post a new question for my problems. Perhaps you can help me use these utilities successfully. – Alyoshak Nov 13 '15 at 17:21