diff --git a/Library/OcAppleKernelLib/KernelCollection.c b/Library/OcAppleKernelLib/KernelCollection.c index 1e7d08e2..ea856baf 100644 --- a/Library/OcAppleKernelLib/KernelCollection.c +++ b/Library/OcAppleKernelLib/KernelCollection.c @@ -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; } diff --git a/Library/OcAppleKernelLib/PrelinkedContext.c b/Library/OcAppleKernelLib/PrelinkedContext.c index 9f357cdb..3479bfa9 100644 --- a/Library/OcAppleKernelLib/PrelinkedContext.c +++ b/Library/OcAppleKernelLib/PrelinkedContext.c @@ -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, diff --git a/Library/OcAppleKernelLib/PrelinkedKext.c b/Library/OcAppleKernelLib/PrelinkedKext.c index 669c22ec..25afa047 100644 --- a/Library/OcAppleKernelLib/PrelinkedKext.c +++ b/Library/OcAppleKernelLib/PrelinkedKext.c @@ -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,