OcAppleKernelLib: Fix linking against injected kexts

This commit is contained in:
vit9696 2020-07-04 22:23:02 +03:00
parent 0ff97ad01c
commit ef8fdce8cd
3 changed files with 12 additions and 3 deletions

View File

@ -688,7 +688,7 @@ KcKextApplyFileDelta (
//
// Rebase the segment itself.
//
if (Segment->FileOffset != 0) {
if (Segment->FileOffset != 0 || Segment->FileSize != 0) {
Segment->FileOffset += Delta;
}
@ -741,5 +741,11 @@ KcKextApplyFileDelta (
}
}
//
// Update the container offset to make sure we can link against this
// kext later as well.
//
Context->ContainerOffset = Delta;
return EFI_SUCCESS;
}

View File

@ -892,9 +892,11 @@ PrelinkedInjectKext (
//
// For KC, our KEXTs have their own segment - do not mod __PRELINK_INFO.
// Integrate the KEXT into KC by indexing its fixups and rebasing.
// Note, we are no longer using ExecutableContext here, as the context
// ownership was transferred by InternalLinkPrelinkedKext.
//
KcKextIndexFixups (Context, &ExecutableContext);
Status = KcKextApplyFileDelta (&ExecutableContext, KextOffset);
KcKextIndexFixups (Context, &PrelinkedKext->Context.MachContext);
Status = KcKextApplyFileDelta (&PrelinkedKext->Context.MachContext, KextOffset);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_WARN,

View File

@ -215,6 +215,7 @@ InternalScanCurrentPrelinkedKextLinkInfo (
}
if (Kext->SymbolTable == NULL) {
DEBUG ((DEBUG_VERBOSE, "OCAK: Requesting SymbolTable for %a\n", Kext->Identifier));
Kext->NumberOfSymbols = MachoGetSymbolTable (
&Kext->Context.MachContext,
&Kext->SymbolTable,