X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/316670eb35587141e969394ae8537d66b9211e80..9d749ea394c01276fa19e397e70f46858e849c76:/libkern/kernel_mach_header.c diff --git a/libkern/kernel_mach_header.c b/libkern/kernel_mach_header.c index ebef5b5ab..579402474 100644 --- a/libkern/kernel_mach_header.c +++ b/libkern/kernel_mach_header.c @@ -138,6 +138,29 @@ getsectdatafromheader( return result; } +/* + * This routine returns the offset for the named section in the + * named segment if it exist in the mach header passed to it. Otherwise + * it returns zero. + * + * This routine can operate against any kernel mach header. + */ +uint32_t +getsectoffsetfromheader( + kernel_mach_header_t *mhp, + const char *segname, + const char *sectname) +{ + const kernel_section_t *sp; + + sp = getsectbynamefromheader(mhp, segname, sectname); + if(sp == (kernel_section_t *)0){ + return(0); + } + + return sp->offset; +} + /* * This routine returns the a pointer to the data for the named segment * if it exist in the mach header passed to it. Also it returns