/// <summary>Provides the canonical Architecture form for a given architecture sub architecture pair</summary> /// <param name="archType">Architecture type</param> /// <param name="subArch">Sub Architecture type</param> /// <returns>Canonical <see cref="ArchType"/></returns> /// <remarks> /// Some architectures, particularly ARM variants, have multiple sub-architecture types that /// have a canonical form (i.e. Arch=<see cref="ArchType.Arm"/>; SubArch=<see cref="SubArchType.ARMSubArch_v7m"/>; /// has the Canonical Arch of <see cref="ArchType.Thumb"/>). This method retrieves the canonical Arch /// for a given architecture,SubArchitecture pair. /// </remarks> public static ArchType GetCanonicalArchForSubArch(ArchType archType, SubArchType subArch) { archType.ValidateDefined(nameof(archType)); subArch.ValidateDefined(nameof(subArch)); switch (archType) { case ArchType.Kalimba: switch (subArch) { case SubArchType.NoSubArch: case SubArchType.KalimbaSubArch_v3: case SubArchType.KalimbaSubArch_v4: case SubArchType.KalimbaSubArch_v5: return(ArchType.Kalimba); default: return(ArchType.UnknownArch); } case ArchType.Arm: case ArchType.Armeb: switch (subArch) { case SubArchType.ARMSubArch_v6m: return(archType == ArchType.Armeb ? ArchType.Thumbeb : ArchType.Thumb); case SubArchType.KalimbaSubArch_v3: case SubArchType.KalimbaSubArch_v4: case SubArchType.KalimbaSubArch_v5: return(ArchType.UnknownArch); default: return(archType); } default: return(archType); } }
public static ObjectFormatType GetDefaultObjectFormat(ArchType arch, OSType os) { arch.ValidateDefined(nameof(arch)); os.ValidateDefined(nameof(os)); switch (arch) { case ArchType.UnknownArch: case ArchType.Aarch64: case ArchType.Arm: case ArchType.Thumb: case ArchType.X86: case ArchType.Amd64: if (IsOsDarwin(os)) { return(ObjectFormatType.MachO); } if (os == OSType.Win32) { return(ObjectFormatType.COFF); } return(ObjectFormatType.ELF); case ArchType.Aarch64BE: case ArchType.AMDGCN: case ArchType.Amdil: case ArchType.Amdil64: case ArchType.Armeb: case ArchType.Avr: case ArchType.BPFeb: case ArchType.BPFel: case ArchType.Hexagon: case ArchType.Lanai: case ArchType.Hsail: case ArchType.Hsail64: case ArchType.Kalimba: case ArchType.Le32: case ArchType.Le64: case ArchType.MIPS: case ArchType.MIPS64: case ArchType.MIPS64el: case ArchType.MIPSel: case ArchType.MSP430: case ArchType.Nvptx: case ArchType.Nvptx64: case ArchType.PPC64le: case ArchType.R600: case ArchType.Renderscript32: case ArchType.Renderscript64: case ArchType.Shave: case ArchType.Sparc: case ArchType.Sparcel: case ArchType.Sparcv9: case ArchType.Spir: case ArchType.Spir64: case ArchType.SystemZ: case ArchType.TCE: case ArchType.Thumbeb: case ArchType.Wasm32: case ArchType.Wasm64: case ArchType.Xcore: return(ObjectFormatType.ELF); case ArchType.PPC: case ArchType.PPC64: if (IsOsDarwin(os)) { return(ObjectFormatType.MachO); } return(ObjectFormatType.ELF); default: throw new ArgumentException(Resources.Unsupported_Architecture, nameof(arch)); } }