From 12deebde945e1a874a9e19f0a46e2585f6d49808 Mon Sep 17 00:00:00 2001 From: Devin Vaukz Date: Fri, 2 Jul 2021 19:37:54 -0700 Subject: [PATCH] Align mk_architecture names with otool --- libMachO/Architecture/architecture.c | 180 ++++++++++++++++++++++----- 1 file changed, 151 insertions(+), 29 deletions(-) diff --git a/libMachO/Architecture/architecture.c b/libMachO/Architecture/architecture.c index 7670020..ee3b29d 100644 --- a/libMachO/Architecture/architecture.c +++ b/libMachO/Architecture/architecture.c @@ -54,24 +54,76 @@ mk_architecture_copy_description(mk_architecture_t architecture, char *output, s { const char *description = ""; - switch (mk_architecture_get_cpu_type(architecture)) + cpu_type_t cputype = mk_architecture_get_cpu_type(architecture); + cpu_subtype_t cpusubtype = mk_architecture_get_cpu_subtype(architecture); + + switch (cputype) { case CPU_TYPE_ANY: - description = "ANY"; + { + switch (cpusubtype) { + case CPU_SUBTYPE_LITTLE_ENDIAN: + description = "little"; + break; + case CPU_SUBTYPE_BIG_ENDIAN: + description = "big"; + break; + case CPU_SUBTYPE_MULTIPLE: + default: + description = "any"; + break; + } break; + } case CPU_TYPE_VAX: - description = "VAX"; + description = "vax"; break; case CPU_TYPE_MC680x0: - description = "MC680x0"; + { + switch (cpusubtype) { + case CPU_SUBTYPE_MC68040: + description = "m68040"; + break; + case CPU_SUBTYPE_MC68030_ONLY: + description = "m68030"; + break; + default: + description = "m68k"; + break; + } break; + } //case CPU_TYPE_X86: case CPU_TYPE_I386: - description = "i386"; + { + switch (cpusubtype) { + case CPU_SUBTYPE_486: + description = "i486"; + break; + case CPU_SUBTYPE_486SX: + description = "i486SX"; + break; + case CPU_SUBTYPE_PENT: + description = "pentium"; + break; + case CPU_SUBTYPE_PENTPRO: + description = "pentpro"; + break; + case CPU_SUBTYPE_PENTII_M3: + description = "pentIIm3"; + break; + case CPU_SUBTYPE_PENTII_M5: + description = "pentIIm5"; + break; + default: + description = "i386"; + break; + } break; + } case CPU_TYPE_X86_64: { - switch (mk_architecture_get_cpu_subtype(architecture)) { + switch (cpusubtype) { case CPU_SUBTYPE_X86_64_H: description = "x86_64h"; break; @@ -85,35 +137,56 @@ mk_architecture_copy_description(mk_architecture_t architecture, char *output, s description = "MC98000"; break; case CPU_TYPE_HPPA: - description = "HPPA"; + description = "hppa"; break; case CPU_TYPE_ARM: { - switch (mk_architecture_get_cpu_subtype(architecture)) { - case CPU_SUBTYPE_ARM_V7K: - description = "armv7k"; - break; - case CPU_SUBTYPE_ARM_V7S: - description = "armv7s"; - break; - case CPU_SUBTYPE_ARM_V7F: - description = "armv7f"; - break; - case CPU_SUBTYPE_ARM_V7: - description = "armv7"; + switch (cpusubtype) { + case CPU_SUBTYPE_ARM_V4T: + description = "armv4t"; break; case CPU_SUBTYPE_ARM_V6: description = "armv6"; break; + case CPU_SUBTYPE_ARM_V5TEJ: + description = "armv5"; + break; + case CPU_SUBTYPE_ARM_XSCALE: + description = "xscale"; + break; + case CPU_SUBTYPE_ARM_V7: + description = "armv7"; + break; + case CPU_SUBTYPE_ARM_V7F: + description = "armv7f"; + break; + case CPU_SUBTYPE_ARM_V7S: + description = "armv7s"; + break; + case CPU_SUBTYPE_ARM_V7K: + description = "armv7k"; + break; + case CPU_SUBTYPE_ARM_V6M: + description = "armv6m"; + break; + case CPU_SUBTYPE_ARM_V7M: + description = "armv7m"; + break; + case CPU_SUBTYPE_ARM_V7EM: + description = "armv7em"; + break; default: - description = "ARM"; + description = "arm"; break; } break; } case CPU_TYPE_ARM64: { - switch (mk_architecture_get_cpu_subtype(architecture)) { + switch (cpusubtype) { + case CPU_SUBTYPE_ARM64_V8: + description = "arm64v8"; + break; case CPU_SUBTYPE_ARM64E: description = "arm64e"; break; @@ -124,27 +197,76 @@ mk_architecture_copy_description(mk_architecture_t architecture, char *output, s break; } case CPU_TYPE_ARM64_32: - { description = "arm64_32"; break; - } case CPU_TYPE_MC88000: - description = "MC88000"; + description = "m88k"; break; case CPU_TYPE_SPARC: - description = "SPARC"; + description = "sparc"; break; case CPU_TYPE_I860: - description = "I860"; + description = "i860"; break; case CPU_TYPE_POWERPC: - description = "PowerPC"; + { + switch (cpusubtype) { + case CPU_SUBTYPE_POWERPC_601: + description = "ppc601"; + break; + case CPU_SUBTYPE_POWERPC_602: + description = "ppc602"; + break; + case CPU_SUBTYPE_POWERPC_603: + description = "ppc603"; + break; + case CPU_SUBTYPE_POWERPC_603e: + description = "ppc603e"; + break; + case CPU_SUBTYPE_POWERPC_603ev: + description = "ppc603ev"; + break; + case CPU_SUBTYPE_POWERPC_604: + description = "ppc604"; + break; + case CPU_SUBTYPE_POWERPC_604e: + description = "ppc604e"; + break; + case CPU_SUBTYPE_POWERPC_620: + description = "ppc620"; + break; + case CPU_SUBTYPE_POWERPC_750: + description = "ppc750"; + break; + case CPU_SUBTYPE_POWERPC_7400: + description = "ppc7400"; + break; + case CPU_SUBTYPE_POWERPC_7450: + description = "ppc7450"; + break; + case CPU_SUBTYPE_POWERPC_970: + description = "ppc970"; + break; + default: + description = "ppc"; + break; + } break; + } case CPU_TYPE_POWERPC64: - description = "PowerPC 64"; + { + switch (cpusubtype) { + case CPU_SUBTYPE_POWERPC_970: + description = "ppc970-64"; + break; + default: + description = "ppc64"; + break; + } break; + } default: - description = "Unknown"; + description = "unknown"; break; }