]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/kernel_mach_header.c
xnu-3789.1.32.tar.gz
[apple/xnu.git] / libkern / kernel_mach_header.c
index ebef5b5ab5bea6ed3d768593c7f2dd60f5ee8894..5794024740253e19801ff2795015d69ea6838fe7 100644 (file)
@@ -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