* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.2 (the
+ * are subject to the Apple Public Source License Version 2.0 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
nfat = fhp->nfat_arch;
swapped = 0;
} else if (fhp->magic == FAT_CIGAM) {
- nfat = NXSwapInt(fhp->nfat_arch);
+ nfat = OSSwapInt32(fhp->nfat_arch);
swapped = 1;
} else {
return -1;
for (; nfat > 0; nfat--, fap++) {
if (swapped) {
- fap->cputype = NXSwapInt(fap->cputype);
- fap->offset = NXSwapInt(fap->offset);
- fap->size = NXSwapInt(fap->size);
+ fap->cputype = OSSwapInt32(fap->cputype);
+ fap->offset = OSSwapInt32(fap->offset);
+ fap->size = OSSwapInt32(fap->size);
}
if (fap->cputype == CPU_TYPE_I386) {
unsigned int vmend = 0;
unsigned long cnt;
long ret = -1;
- unsigned int entry;
+ unsigned int entry = 0;
gBinaryAddress = (unsigned long)binary;
return -1;
}
-#if NOTDEF
+#if DEBUG
printf("magic: %x\n", (unsigned)mH->magic);
printf("cputype: %x\n", (unsigned)mH->cputype);
printf("cpusubtype: %x\n", (unsigned)mH->cpusubtype);
case LC_SEGMENT:
ret = DecodeSegment(cmdBase, &load_addr, &load_size);
- if (ret == 0 && load_size != 0) {
+ if (ret == 0 && load_size != 0 && load_addr >= KERNEL_ADDR) {
vmaddr = min(vmaddr, load_addr);
vmend = max(vmend, load_addr + load_size);
}
return 0;
}
-#if NOTDEF
+#if DEBUG
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCmd->nsects, (unsigned)segCmd->flags);
getc();
#endif
- if (vmaddr < KERNEL_ADDR ||
- (vmaddr + vmsize) > (KERNEL_ADDR + KERNEL_LEN)) {
+ if (! ((vmaddr >= KERNEL_ADDR &&
+ (vmaddr + vmsize) <= (KERNEL_ADDR + KERNEL_LEN)) ||
+ (vmaddr >= HIB_ADDR &&
+ (vmaddr + vmsize) <= (HIB_ADDR + HIB_LEN)))) {
stop("Kernel overflows available space");
}