Skip to content

Commit

Permalink
OcAppleKernelLib: Only locate __PRELINK_INFO for prelinkedkernel
Browse files Browse the repository at this point in the history
  • Loading branch information
mhaeuser committed Jul 7, 2022
1 parent 3762c42 commit f3cd35a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Include/Acidanthera/Library/OcAppleKernelLib.h
Expand Up @@ -200,7 +200,9 @@ typedef struct {
//
MACH_SECTION_ANY *PrelinkedInfoSection;
//
// Pointer to PRELINK_TEXT_SEGMENT.
// Pointer to PRELINK_TEXT_SEGMENT (for prelinkedkernel, NULL for KC).
// As of macOS 13 Developer Beta 3, this segment may have corrupted
// information.
//
MACH_SEGMENT_COMMAND_ANY *PrelinkedTextSegment;
//
Expand Down
34 changes: 17 additions & 17 deletions Library/OcAppleKernelLib/PrelinkedContext.c
Expand Up @@ -292,23 +292,6 @@ PrelinkedContextInit (
return Status;
}

Context->PrelinkedTextSegment = MachoGetSegmentByName (
&Context->PrelinkedMachContext,
PRELINK_TEXT_SEGMENT
);
if (Context->PrelinkedTextSegment == NULL) {
return EFI_NOT_FOUND;
}

Context->PrelinkedTextSection = MachoGetSectionByName (
&Context->PrelinkedMachContext,
Context->PrelinkedTextSegment,
PRELINK_TEXT_SECTION
);
if (Context->PrelinkedTextSection == NULL) {
return EFI_NOT_FOUND;
}

if (Context->IsKernelCollection) {
//
// Additionally process special entries for KC.
Expand Down Expand Up @@ -337,6 +320,23 @@ PrelinkedContextInit (
if (Context->LinkEditSegment == NULL) {
return EFI_NOT_FOUND;
}
} else {
Context->PrelinkedTextSegment = MachoGetSegmentByName (
&Context->PrelinkedMachContext,
PRELINK_TEXT_SEGMENT
);
if (Context->PrelinkedTextSegment == NULL) {
return EFI_NOT_FOUND;
}

Context->PrelinkedTextSection = MachoGetSectionByName (
&Context->PrelinkedMachContext,
Context->PrelinkedTextSegment,
PRELINK_TEXT_SECTION
);
if (Context->PrelinkedTextSection == NULL) {
return EFI_NOT_FOUND;
}
}

Context->PrelinkedInfo = Context->Is32Bit ?
Expand Down

0 comments on commit f3cd35a

Please sign in to comment.