OcAppleKernelLib: Support trailing exec-less kexts
@@ -33,6 +33,7 @@ PrelinkedFindLastLoadAddress (
)
{
UINT32 KextCount;
+ UINT32 KextIndex;
UINT32 FieldIndex;
UINT32 FieldCount;
XML_NODE *LastKext;
@@ -47,9 +48,11 @@ PrelinkedFindLastLoadAddress (
}
//
- // Here we make an assumption that last kext has the highest load address.
+ // Here we make an assumption that last kext has the highest load address,
+ // yet there might be an arbitrary amount of trailing executable-less kexts.
//
- LastKext = PlistNodeCast (XmlNodeChild (KextList, KextCount - 1), PLIST_NODE_TYPE_DICT);
+ for (KextIndex = 1; KextIndex <= KextCount; ++KextIndex) {
+ LastKext = PlistNodeCast (XmlNodeChild (KextList, KextCount - KextIndex), PLIST_NODE_TYPE_DICT);
if (LastKext == NULL) {
return 0;
}
@@ -83,6 +86,11 @@ PrelinkedFindLastLoadAddress (
return 0;
}
+ if (LoadAddress != 0) {
+ break;
+ }
+ }
+
return LoadAddress;
}
