]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/c++/OSKext.cpp
xnu-2050.22.13.tar.gz
[apple/xnu.git] / libkern / c++ / OSKext.cpp
index 1e4395043950b4168bb28550988eca9f5504ac29..73d92b9f99f078825b035fab013a7e9e83836e28 100644 (file)
@@ -7822,15 +7822,16 @@ OSKext::copyInfo(OSArray * infoKeys)
                 lcp = (struct load_command *) (temp_kext_mach_hdr + 1);
                 for (i = 0; i < temp_kext_mach_hdr->ncmds; i++) {
                     if (lcp->cmd == LC_SEGMENT_KERNEL) {
-                        kernel_segment_command_t *  scp;
+                        kernel_segment_command_t *  segp;
+                        kernel_section_t *          secp;
                         
-                        scp = (kernel_segment_command_t *) lcp;
+                        segp = (kernel_segment_command_t *) lcp;
                         // 10543468 - if we jettisoned __LINKEDIT clear size info
                         if (flags.jettisonLinkeditSeg) {
-                            if (strncmp(scp->segname, SEG_LINKEDIT, sizeof(scp->segname)) == 0) {
-                                scp->vmsize = 0;
-                                scp->fileoff = 0;
-                                scp->filesize = 0;
+                            if (strncmp(segp->segname, SEG_LINKEDIT, sizeof(segp->segname)) == 0) {
+                                segp->vmsize = 0;
+                                segp->fileoff = 0;
+                                segp->filesize = 0;
                             }
                         }
 #if 0
@@ -7838,11 +7839,15 @@ OSKext::copyInfo(OSArray * infoKeys)
                                   kOSKextLogErrorLevel |
                                   kOSKextLogGeneralFlag,
                                   "%s: LC_SEGMENT_KERNEL segname '%s' vmaddr 0x%llX 0x%lX vmsize %llu nsects %u",
-                                  __FUNCTION__, scp->segname, scp->vmaddr, 
-                                  VM_KERNEL_UNSLIDE(scp->vmaddr), 
-                                  scp->vmsize, scp->nsects);
+                                  __FUNCTION__, segp->segname, segp->vmaddr,
+                                  VM_KERNEL_UNSLIDE(segp->vmaddr),
+                                  segp->vmsize, segp->nsects);
 #endif
-                        scp->vmaddr = VM_KERNEL_UNSLIDE(scp->vmaddr);
+                        segp->vmaddr = VM_KERNEL_UNSLIDE(segp->vmaddr);
+
+                        for (secp = firstsect(segp); secp != NULL; secp = nextsect(segp, secp)) {
+                            secp->addr = VM_KERNEL_UNSLIDE(secp->addr);
+                        }
                     }
                     lcp = (struct load_command *)((caddr_t)lcp + lcp->cmdsize);
                 }