Search code examples
iosobjective-cunixllvm-clang

Query .o file symbols


I have an issue with recursive git submodules in my Xcode workspace. I think that llvm is picking up the wrong .m file.

I'd like to confirm this by showing the methods available in the object binary.

I know that I can use ar -t myarchive.a to show the .o files in a static library. Is there any way to drill down deeper and show the method symbols available on a specific .o?


Solution

  • Use can use the nm command to show the symbols within .o or .a file. See the nm manpage for details.

    $ nm build/IoEvent.o
    

    (clipped)

    ---------------- T __ZN9ChessCore18ChessCoreExceptionC1EPKcz
    ---------------- T __ZN9ChessCore18ChessCoreExceptionD0Ev
    ---------------- T __ZN9ChessCore18ChessCoreExceptionD1Ev
    ---------------- D __ZN9ChessCore7IoEvent11m_classnameE
    ---------------- T __ZN9ChessCore7IoEvent3setEv
    ---------------- T __ZN9ChessCore7IoEvent5resetEv
    ---------------- T __ZN9ChessCore7IoEventC1Ei
    ---------------- T __ZN9ChessCore7IoEventC1Ev
    ---------------- T __ZN9ChessCore7IoEventC2Ei
    ---------------- T __ZN9ChessCore7IoEventC2Ev
    ---------------- T __ZN9ChessCore7IoEventD0Ev
    ---------------- T __ZN9ChessCore7IoEventD1Ev
    ---------------- T __ZN9ChessCore7IoEventD2Ev
    ---------------- T __ZNK9ChessCore18ChessCoreException4whatEv
    

    If you're using C++ (I know you're not) then you can use c++filt to demangle those symbol names:

    $ c++filt  __ZN9ChessCore7IoEvent5resetEv
    ChessCore::IoEvent::reset()