From 8880afb7624e4f84b92b64c4d7e8455d11fd63ab Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Mon, 20 Mar 2017 16:03:55 -0400 Subject: [PATCH] Make the cross-compilation glue for dump_syms Mac handle x86_64h. x86_64h has a different cpusubtype from x86_64. The h is for Haswell. BUG= Change-Id: Icf884e5699fe120c12d13aa57cd62db5b69a2ce6 Reviewed-on: https://chromium-review.googlesource.com/457171 Reviewed-by: Ted Mielczarek --- src/common/mac/arch_utilities.cc | 28 ++++++++++++++++++---- src/third_party/mac_headers/mach/machine.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/common/mac/arch_utilities.cc b/src/common/mac/arch_utilities.cc index 4e5f5534..c9225e00 100644 --- a/src/common/mac/arch_utilities.cc +++ b/src/common/mac/arch_utilities.cc @@ -111,6 +111,7 @@ namespace { enum Architecture { kArch_i386 = 0, kArch_x86_64, + kArch_x86_64h, kArch_arm, kArch_arm64, kArch_ppc, @@ -135,6 +136,13 @@ const NXArchInfo kKnownArchitectures[] = { NX_LittleEndian, "Intel x86-64" }, + { + "x86_64h", + CPU_TYPE_X86_64, + CPU_SUBTYPE_X86_64_H, + NX_LittleEndian, + "Intel x86-64h Haswell" + }, { "arm", CPU_TYPE_ARM, @@ -189,23 +197,35 @@ const NXArchInfo *NXGetArchInfoFromName(const char *name) { const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype, cpu_subtype_t cpusubtype) { + const NXArchInfo *candidate = NULL; for (int arch = 0; arch < kNumArchitectures; ++arch) { if (kKnownArchitectures[arch].cputype == cputype) { - return &kKnownArchitectures[arch]; + if (kKnownArchitectures[arch].cpusubtype == cpusubtype) { + return &kKnownArchitectures[arch]; + } + if (!candidate) { + candidate = &kKnownArchitectures[arch]; + } } } - return NULL; + return candidate; } struct fat_arch *NXFindBestFatArch(cpu_type_t cputype, cpu_subtype_t cpusubtype, struct fat_arch *fat_archs, uint32_t nfat_archs) { + struct fat_arch *candidate = NULL; for (uint32_t f = 0; f < nfat_archs; ++f) { if (fat_archs[f].cputype == cputype) { - return &fat_archs[f]; + if (fat_archs[f].cpusubtype == cpusubtype) { + return &fat_archs[f]; + } + if (!candidate) { + candidate = &fat_archs[f]; + } } } - return NULL; + return candidate; } #endif // !__APPLE__ diff --git a/src/third_party/mac_headers/mach/machine.h b/src/third_party/mac_headers/mach/machine.h index 91d9d709..5bb21e48 100644 --- a/src/third_party/mac_headers/mach/machine.h +++ b/src/third_party/mac_headers/mach/machine.h @@ -228,6 +228,7 @@ typedef integer_t cpu_threadtype_t; #define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3) #define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3) #define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4) +#define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8) /* Haswell feature subset */ #define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1)