I have a mach-o file loaded in memory (via mmap
) and need to get the address in the binary corresponding to a symbol, say mySym
. I found a function called NSLookupSymbolInImage
and thought I could use that and then use NSAddressOfSymbol
to get the actual address, but there are some issues with that:
- These functions are deprecated
- While looking at the source of
NSLookupSymbolInImage
, it appears that themach_header
passed in must already be loaded by dyld. Since I loaded the binary myself, this method probably won't work.
Now, I know that if I must, I can parse the mach_header
myself and find the symbol that way, but I would like to think that there is an better way of doing this.
Basically, I want to know if there is an easier method to get the address of a symbol from a mach-o file not loaded by dyld than doing it manually.