#include <libkern/kernel_mach_header.h>
#include <libkern/prelink.h>
+#if CONFIG_EMBEDDED
+extern uuid_t kernelcache_uuid;
+#endif
}
#include <libkern/version.h>
static int __whereIsAddr(vm_offset_t theAddr, unsigned long * segSizes, vm_offset_t *segAddrs, int segCount );
-#define PLK_SEGMENTS 11
+#define PLK_SEGMENTS 12
static const char * plk_segNames[] = {
"__TEXT",
"__PLK_TEXT_EXEC",
"__PRELINK_DATA",
"__PLK_DATA_CONST",
+ "__PLK_LLVM_COV",
"__PLK_LINKEDIT",
"__PRELINK_INFO",
NULL
OSDictionary * prelinkInfoDict = NULL; // do not release
OSString * errorString = NULL; // must release
OSKext * theKernel = NULL; // must release
+#if CONFIG_EMBEDDED
+ OSData * kernelcacheUUID = NULL; // do not release
+#endif
kernel_segment_command_t * prelinkTextSegment = NULL; // see code
kernel_segment_command_t * prelinkInfoSegment = NULL; // see code
ramDiskBoot = IORamDiskBSDRoot();
#endif /* NO_KEXTD */
+#if CONFIG_EMBEDDED
+ /* Copy in the kernelcache UUID */
+ kernelcacheUUID = OSDynamicCast(OSData,
+ prelinkInfoDict->getObject(kPrelinkInfoKCIDKey));
+ if (!kernelcacheUUID) {
+ bzero(&kernelcache_uuid, sizeof(kernelcache_uuid));
+ } else if (kernelcacheUUID->getLength() != sizeof(kernelcache_uuid)) {
+ panic("kernelcacheUUID length is %d, expected %lu", kernelcacheUUID->getLength(),
+ sizeof(kernelcache_uuid));
+ } else {
+ memcpy((void *)&kernelcache_uuid, (const void *)kernelcacheUUID->getBytesNoCopy(), kernelcacheUUID->getLength());
+ }
+#endif /* CONFIG_EMBEDDED */
infoDictArray = OSDynamicCast(OSArray,
prelinkInfoDict->getObject(kPrelinkInfoDictionaryKey));
/* Create dictionary of excluded kexts
*/
+#ifndef CONFIG_EMBEDDED
OSKext::createExcludeListFromPrelinkInfo(infoDictArray);
+#endif
/* Create OSKext objects for each info dictionary.
*/
for (i = 0; i < infoDictArray->getCount(); ++i) {
OSNumber *lengthNum = OSDynamicCast(OSNumber,
infoDict->getObject(kPrelinkExecutableSizeKey));
if (addressNum && lengthNum) {
+#if __arm__ || __arm64__
+ vm_offset_t data = (vm_offset_t) ((addressNum->unsigned64BitValue()) + vm_kernel_slide);
+ vm_size_t length = (vm_size_t) (lengthNum->unsigned32BitValue());
+ ml_static_mfree(data, length);
+#else
#error Pick the right way to free prelinked data on this arch
+#endif
}
infoDictArray->removeObject(i--);
int badSlideAddr = 0;
int badSlideTarget = 0;
- kaslrPackedOffsets * myOffsets = NULL;
- myOffsets = (kaslrPackedOffsets *) kaslrOffsets->getBytesNoCopy();
+ const kaslrPackedOffsets * myOffsets = NULL;
+ myOffsets = (const kaslrPackedOffsets *) kaslrOffsets->getBytesNoCopy();
for (uint32_t j = 0; j < myOffsets->count; j++) {
/* Create dictionary of excluded kexts
*/
+#ifndef CONFIG_EMBEDDED
OSKext::createExcludeListFromBooterData(propertyDict, keyIterator);
+#endif
keyIterator->reset();
while ( ( deviceTreeName =