Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mach-O file LC_FUNCTION_STARTS load command

Tags:

macos

dyld

mach-o

Does anyone know what the format of the data pointed to by the Mach-O LC_FUNCTION_STARTS command is?

The most information I could find is in the loader.h header file:

#define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses */

I see the dyldinfo tool has a -function_starts option which analyzes this data and the tool is open source, but the latest released version of the tool doesn't contain the support:

http://opensource.apple.com/source/ld64/ld64-97.2/src/other/dyldinfo.cpp

Does anyone know where I can get the source for the latest version of dyldinfo, or where I can get more information on this load command?

Thanks!

like image 598
Locksleyu Avatar asked Mar 07 '12 13:03

Locksleyu


1 Answers

It's used by tools that need to symbolicate addresses in crash logs, samples, spindumps, etc. to determine if a given address falls inside a function. It could also be useful to debuggers to help them more quickly find the bounds of the function that a given address is within.

The data within this section is formatted as a zero-terminated sequence of DWARF-style ULEB128 values. The first value is the offset from the start of the __TEXT segment to the start of the first function. The remaining values is the offset to the start of the next function.

like image 69
bdash Avatar answered Sep 21 '22 10:09

bdash