On Jul 28, 2005, at 10:08 AM, D. Walsh wrote: is there a way with otool to display the functions in a shared library?
for example, I know that libz.dylib contains inflateEnd so how do I get otool to show me it and other functions?
If you just want to see the entry points, you can just use nm instead of otool:
$ nm -gfj /usr/lib/libz.dylib ___error _adler32 _clearerr _compress _compress2 _compressBound _crc32 _deflate _deflateBound _deflateCopy _deflateEnd _deflateInit2_ _deflateInit_ _deflateParams _deflatePrime _deflateReset _deflateSetDictionary ...
For C++ libraries you can pipe the results through c++filt to demangle them:
nm -gfj /usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libstdc++.dylib | c++filt --format=gnu-v3 __DefaultRuneLocale __Unwind_DeleteException __Unwind_GetDataRelBase __Unwind_GetIP __Unwind_GetLanguageSpecificData __Unwind_GetRegionStart __Unwind_GetTextRelBase __Unwind_RaiseException __Unwind_Resume __Unwind_Resume_or_Rethrow __Unwind_SetGR __Unwind_SetIP guard variable for __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>::_S_get_pool()::_S_pool guard variable for __gnu_cxx::free_list::_M_get_mutex()::_S_mutex guard variable for __gnu_cxx::free_list::_M_get_free_list()::_S_free_list __cxxabiv1::__terminate(void (*)()) ...
If you want to see the disassembled object code for a function, you will have to use otool:
$otool -Vt /usr/lib/libz.dylib /usr/lib/libz.dylib: (__TEXT,__text) section _gzopen: 910665b4 li r5,0xffff 910665b8 b _gz_open _gz_open: 910665bc stmw r24,0xffe0(r1) 910665c0 or. r27,r3,r3 910665c4 mfspr r0,lr 910665c8 bcl 20,31,0x910665cc 910665cc stw r0,0x8(r1) ...
The -p flag to otool lets you start at a given symbol (e.g. $otool -Vt -p _inflateEnd /usr/lib/libz.dylib ) but dumps to the end of the text section, not just the given routine.
Chris |