To find the dyld address mapping of __TEXT and __DATA for my mach-o executable I set the environment va开发者_如何转开发riable DYLD_PRINT_SEGMENTS=1. This logs on the console where in memory the executable is mapped.
However, I need to find the address mapping of __TEXT and __DATA internally from within my executable. Is there some API for elegantly obtaining this information?
You can obtain this information with the getsectbyname()
function from the <mach-o/getsect.h>
header.
精彩评论