* req_cpu_type: The required cpu type.
* mask_bits: Bits to mask from the sub-image type when
* grading it vs. the req_cpu_type
+* imgp: Image params
* archret (out): Pointer to fat_arch structure to hold
* the results.
*
**********************************************************************/
static load_return_t
fatfile_getarch(
- vm_offset_t data_ptr,
- vm_size_t data_size,
- cpu_type_t req_cpu_type,
- cpu_type_t mask_bits,
- struct fat_arch *archret)
+ vm_offset_t data_ptr,
+ vm_size_t data_size,
+ cpu_type_t req_cpu_type,
+ cpu_type_t mask_bits,
+ struct image_params *imgp,
+ struct fat_arch *archret)
{
load_return_t lret;
struct fat_arch *arch;
/*
* Get the grade of the cpu subtype (without feature flags)
*/
- grade = grade_binary(testtype, testsubtype);
+ grade = grade_binary(testtype, testsubtype, TRUE);
/*
* Remember it if it's the best we've seen.
}
}
+ /* On X86_64, allow 32 bit exec only for simulator binaries.
+ * Failing here without re-running the grading algorithm is safe because i386
+ * has the lowest possible grade value (so there can't be a lower best grade
+ * that would be allowed if this check denied the i386 slice). */
+ if (best_arch != NULL &&
+ validate_potential_simulator_binary(OSSwapBigToHostInt32(best_arch->cputype),
+ imgp, OSSwapBigToHostInt32(best_arch->offset),
+ OSSwapBigToHostInt32(best_arch->size)) != LOAD_SUCCESS) {
+ best_arch = NULL;
+ best_grade = 0;
+ }
+
/*
* Return our results.
*/
fatfile_getbestarch(
vm_offset_t data_ptr,
vm_size_t data_size,
+ struct image_params *imgp,
struct fat_arch *archret)
{
/*
* Ignore all architectural bits when determining if an image
* in a fat file should be skipped or graded.
*/
- return fatfile_getarch(data_ptr, data_size, cpu_type(), CPU_ARCH_MASK, archret);
+ return fatfile_getarch(data_ptr, data_size, cpu_type(), CPU_ARCH_MASK, imgp, archret);
}
load_return_t
cpu_type_t cputype,
vm_offset_t data_ptr,
vm_size_t data_size,
+ struct image_params *imgp,
struct fat_arch *archret)
{
/*
* Scan the fat_arch array for exact matches for this cpu_type_t only
*/
- return fatfile_getarch(data_ptr, data_size, cputype, 0, archret);
+ return fatfile_getarch(data_ptr, data_size, cputype, 0, imgp, archret);
}
/**********************************************************************
load_return_t
fatfile_getarch_with_bits(
integer_t archbits,
- vm_offset_t data_ptr,
+ vm_offset_t data_ptr,
vm_size_t data_size,
struct fat_arch *archret)
{
* Scan the fat_arch array for matches with the requested
* architectural bits set, and for the current hardware cpu CPU.
*/
- return fatfile_getarch(data_ptr, data_size, (archbits & CPU_ARCH_MASK) | (cpu_type() & ~CPU_ARCH_MASK), 0, archret);
+ return fatfile_getarch(data_ptr, data_size, (archbits & CPU_ARCH_MASK) | (cpu_type() & ~CPU_ARCH_MASK), 0, NULL, archret);
}
/*