Fix architecture handling in load_mach
This commit is contained in:
parent
2e9c586ba7
commit
612d5e6d65
@ -153,9 +153,9 @@ namespace detail {
|
|||||||
} else {
|
} else {
|
||||||
fat_index = 0;
|
fat_index = 0;
|
||||||
if(is_magic_64(magic)) {
|
if(is_magic_64(magic)) {
|
||||||
load_mach<64>(false);
|
load_mach<64>();
|
||||||
} else {
|
} else {
|
||||||
load_mach<32>(false);
|
load_mach<32>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,9 +393,7 @@ namespace detail {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
template<std::size_t Bits>
|
template<std::size_t Bits>
|
||||||
void load_mach(
|
void load_mach() {
|
||||||
bool allow_arch_mismatch
|
|
||||||
) {
|
|
||||||
static_assert(Bits == 32 || Bits == 64, "Unexpected Bits argument");
|
static_assert(Bits == 32 || Bits == 64, "Unexpected Bits argument");
|
||||||
bits = Bits;
|
bits = Bits;
|
||||||
using Mach_Header = typename std::conditional<Bits == 32, mach_header, mach_header_64>::type;
|
using Mach_Header = typename std::conditional<Bits == 32, mach_header, mach_header_64>::type;
|
||||||
@ -405,17 +403,6 @@ namespace detail {
|
|||||||
if(should_swap()) {
|
if(should_swap()) {
|
||||||
swap_mach_header(header);
|
swap_mach_header(header);
|
||||||
}
|
}
|
||||||
thread_local static struct LP(mach_header)* mhp = _NSGetMachExecuteHeader();
|
|
||||||
if(
|
|
||||||
header.cputype != mhp->cputype ||
|
|
||||||
static_cast<cpu_subtype_t>(mhp->cpusubtype & ~CPU_SUBTYPE_MASK) != header.cpusubtype
|
|
||||||
) {
|
|
||||||
if(allow_arch_mismatch) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
throw std::runtime_error("Mach-O file cpu type and subtype do not match current machine " + object_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cputype = header.cputype;
|
cputype = header.cputype;
|
||||||
cpusubtype = header.cpusubtype;
|
cpusubtype = header.cpusubtype;
|
||||||
filetype = header.filetype;
|
filetype = header.filetype;
|
||||||
@ -496,9 +483,9 @@ namespace detail {
|
|||||||
fat_index = best - fat_arches.data();
|
fat_index = best - fat_arches.data();
|
||||||
fprintf(stderr, "INDEX: %llu\n", to_ull(fat_index));
|
fprintf(stderr, "INDEX: %llu\n", to_ull(fat_index));
|
||||||
if(is_magic_64(magic)) {
|
if(is_magic_64(magic)) {
|
||||||
load_mach<64>(true);
|
load_mach<64>();
|
||||||
} else {
|
} else {
|
||||||
load_mach<32>(true);
|
load_mach<32>();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user