diff --git a/BinaryTools.Elf.Tests/TestElfHeader.cs b/BinaryTools.Elf.Tests/TestElfHeader.cs
index 38aa72f..77970a3 100644
--- a/BinaryTools.Elf.Tests/TestElfHeader.cs
+++ b/BinaryTools.Elf.Tests/TestElfHeader.cs
@@ -95,5 +95,35 @@ public void CorrectType()
Assert.Equal(ElfType.Executable, elfFile.Header.Type);
}
+
+ [Fact]
+ public void CorrectMachineX8664()
+ {
+ var stream = new FileStream("Binaries/base32", FileMode.Open, FileAccess.Read);
+ var reader = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
+ ElfFile elfFile = ElfFile.ReadElfFile(reader);
+
+ Assert.Equal(ElfMachine.X8664, elfFile.Header.Machine);
+ }
+
+ [Fact]
+ public void CorrectMachineI386()
+ {
+ var stream = new FileStream("Binaries/helloworld32le", FileMode.Open, FileAccess.Read);
+ var reader = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
+ ElfFile elfFile = ElfFile.ReadElfFile(reader);
+
+ Assert.Equal(ElfMachine.I386, elfFile.Header.Machine);
+ }
+
+ [Fact]
+ public void CorrectMachineS390()
+ {
+ var stream = new FileStream("Binaries/helloworld64be", FileMode.Open, FileAccess.Read);
+ var reader = new EndianBinaryReader(stream, EndianBitConverter.NativeEndianness);
+ ElfFile elfFile = ElfFile.ReadElfFile(reader);
+
+ Assert.Equal(ElfMachine.S390, elfFile.Header.Machine);
+ }
}
}
diff --git a/BinaryTools.Elf/Bit32/ElfHeader.cs b/BinaryTools.Elf/Bit32/ElfHeader.cs
index c171c5d..5143d60 100644
--- a/BinaryTools.Elf/Bit32/ElfHeader.cs
+++ b/BinaryTools.Elf/Bit32/ElfHeader.cs
@@ -75,7 +75,7 @@ internal ElfHeader(BinaryReader reader, Int64 position)
Type = (ElfType)reader.ReadUInt16();
// Represents Elf32_Ehdr.e_machine
- Machine = reader.ReadUInt16();
+ Machine = (ElfMachine)reader.ReadUInt16();
// Represents Elf32_Ehdr.e_version
Version = reader.ReadUInt32();
diff --git a/BinaryTools.Elf/Bit64/ElfHeader.cs b/BinaryTools.Elf/Bit64/ElfHeader.cs
index 249a17d..83949de 100644
--- a/BinaryTools.Elf/Bit64/ElfHeader.cs
+++ b/BinaryTools.Elf/Bit64/ElfHeader.cs
@@ -75,7 +75,7 @@ internal ElfHeader(BinaryReader reader, Int64 position)
Type = (ElfType)reader.ReadUInt16();
// Represents Elf64_Ehdr.e_machine
- Machine = reader.ReadUInt16();
+ Machine = (ElfMachine)reader.ReadUInt16();
// Represents Elf64_Ehdr.e_version
Version = reader.ReadUInt32();
diff --git a/BinaryTools.Elf/ElfHeader.cs b/BinaryTools.Elf/ElfHeader.cs
index 5dea0a1..8da1eb0 100644
--- a/BinaryTools.Elf/ElfHeader.cs
+++ b/BinaryTools.Elf/ElfHeader.cs
@@ -171,7 +171,7 @@ public UInt32 Version
///
/// Gets the ELF file Instruction Set Architecture (ISA).
///
- public UInt16 Machine
+ public ElfMachine Machine
{
get; protected set;
}
diff --git a/BinaryTools.Elf/ElfMachine.cs b/BinaryTools.Elf/ElfMachine.cs
new file mode 100644
index 0000000..3f4bfd4
--- /dev/null
+++ b/BinaryTools.Elf/ElfMachine.cs
@@ -0,0 +1,616 @@
+using System.ComponentModel;
+
+namespace BinaryTools.Elf
+{
+ ///
+ /// Enumerates the required architecture for an individual ELF file.
+ ///
+ public enum ElfMachine : ushort
+ {
+ ///
+ /// No machine
+ ///
+ [Description("No machine")]
+ None = 0,
+
+ ///
+ /// AT&T WE 32100
+ ///
+ [Description("AT&T WE 32100")]
+ M32 = 1,
+
+ ///
+ /// SPARC
+ ///
+ [Description("SPARC")]
+ SPARC = 2,
+
+ ///
+ /// Intel 80386
+ ///
+ [Description("Intel 80386")]
+ I386 = 3,
+
+ ///
+ /// Motorola 68000
+ ///
+ [Description("Motorola 68000")]
+ M68K = 4,
+
+ ///
+ /// Motorola 88000
+ ///
+ [Description("Motorola 88000")]
+ M88K = 5,
+
+ ///
+ /// Reserved for future use (was EM_486)
+ ///
+ [Description("Reserved for future use (was EM_486)")]
+ Reserved6 = 6,
+
+ ///
+ /// Intel 80860
+ ///
+ [Description("Intel 80860")]
+ I860 = 7,
+
+ ///
+ /// MIPS I Architecture
+ ///
+ [Description("MIPS I Architecture")]
+ MIPS = 8,
+
+ ///
+ /// IBM System/370 Processor
+ ///
+ [Description("IBM System/370 Processor")]
+ S370 = 9,
+
+ ///
+ /// MIPS RS3000 Little-endian
+ ///
+ [Description("MIPS RS3000 Little-endian")]
+ MIPSRS3LE = 10,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved11 = 11,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved12 = 12,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved13 = 13,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved14 = 14,
+
+ ///
+ /// Hewlett-Packard PA-RISC
+ ///
+ [Description("Hewlett-Packard PA-RISC")]
+ PARISC = 15,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved16 = 16,
+
+ ///
+ /// Fujitsu VPP500
+ ///
+ [Description("Fujitsu VPP500")]
+ FujitsuVPP500 = 17,
+
+ ///
+ /// Enhanced instruction set SPARC
+ ///
+ [Description("Enhanced instruction set SPARC")]
+ SPARC32Plus = 18,
+
+ ///
+ /// Intel 80960
+ ///
+ [Description("Intel 80960")]
+ I960 = 19,
+
+ ///
+ /// PowerPC
+ ///
+ [Description("PowerPC")]
+ PPC = 20,
+
+ ///
+ /// 64-bit PowerPC
+ ///
+ [Description("64-bit PowerPC")]
+ PPC64 = 21,
+
+ ///
+ /// IBM System/390 Processor
+ ///
+ [Description("IBM System/390 Processor")]
+ S390 = 22,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved23 = 23,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved24 = 24,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved25 = 25,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved26 = 26,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved27 = 27,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved28 = 28,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved29 = 29,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved30 = 30,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved31 = 31,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved32 = 32,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved33 = 33,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved34 = 34,
+
+ ///
+ /// Reserved for future use
+ ///
+ [Description("Reserved for future use")]
+ Reserved35 = 35,
+
+ ///
+ /// NEC V800
+ ///
+ [Description("NEC V800")]
+ V800 = 36,
+
+ ///
+ /// Fujitsu FR20
+ ///
+ [Description("Fujitsu FR20")]
+ FR20 = 37,
+
+ ///
+ /// TRW RH-32
+ ///
+ [Description("TRW RH-32")]
+ RG32 = 38,
+
+ ///
+ /// Motorola RCE
+ ///
+ [Description("Motorola RCE")]
+ RCE = 38,
+
+ ///
+ /// Advanced RISC Machines ARM
+ ///
+ [Description("Advanced RISC Machines ARM")]
+ ARM = 40,
+
+ ///
+ /// Digital Alpha
+ ///
+ [Description("Digital Alpha")]
+ Alpha = 41,
+
+ ///
+ /// Hitachi SH
+ ///
+ [Description("Hitachi SH")]
+ SH = 42,
+
+ ///
+ /// SPARC Version 9
+ ///
+ [Description("SPARC Version 9")]
+ SPARCV9 = 43,
+
+ ///
+ /// Siemens TriCore embedded processor
+ ///
+ [Description("Siemens TriCore embedded processor")]
+ TriCore = 44,
+
+ ///
+ /// Argonaut RISC Core, Argonaut Technologies Inc.
+ ///
+ [Description("Argonaut RISC Core, Argonaut Technologies Inc.")]
+ ARC = 45,
+
+ ///
+ /// Hitachi H8/300
+ ///
+ [Description("Hitachi H8/300")]
+ H8300 = 46,
+
+ ///
+ /// Hitachi H8/300H
+ ///
+ [Description("Hitachi H8/300H")]
+ H8300H = 47,
+
+ ///
+ /// Hitachi H8S
+ ///
+ [Description("Hitachi H8S")]
+ H8S = 48,
+
+ ///
+ /// Hitachi H8/500
+ ///
+ [Description("Hitachi H8/500")]
+ H8500 = 49,
+
+ ///
+ /// Intel IA-64 processor architecture
+ ///
+ [Description("Intel IA-64 processor architecture")]
+ IA64 = 50,
+
+ ///
+ /// Stanford MIPS-X
+ ///
+ [Description("Stanford MIPS-X")]
+ MIPSX = 51,
+
+ ///
+ /// Motorola ColdFire
+ ///
+ [Description("Motorola ColdFire")]
+ ColdFire = 52,
+
+ ///
+ /// Motorola M68HC12
+ ///
+ [Description("Motorola M68HC12")]
+ M68HC12 = 53,
+
+ ///
+ /// Fujitsu MMA Multimedia Accelerator
+ ///
+ [Description("Fujitsu MMA Multimedia Accelerator")]
+ MMA = 54,
+
+ ///
+ /// Siemens PCP
+ ///
+ [Description("Siemens PCP")]
+ PCP = 55,
+
+ ///
+ /// Sony nCPU embedded RISC processor
+ ///
+ [Description("Sony nCPU embedded RISC processor")]
+ NCPU = 56,
+
+ ///
+ /// Denso NDR1 microprocessor
+ ///
+ [Description("Denso NDR1 microprocessor")]
+ NDR1 = 57,
+
+ ///
+ /// Motorola Star*Core processor
+ ///
+ [Description("Motorola Star*Core processor")]
+ StarCore = 58,
+
+ ///
+ /// Toyota ME16 processor
+ ///
+ [Description("Toyota ME16 processor")]
+ ME16 = 59,
+
+ ///
+ /// STMicroelectronics ST100 processor
+ ///
+ [Description("STMicroelectronics ST100 processor")]
+ ST100 = 60,
+
+ ///
+ /// Advanced Logic Corp. TinyJ embedded processor family
+ ///
+ [Description("Advanced Logic Corp. TinyJ embedded processor family")]
+ TINYJ = 61,
+
+ ///
+ /// AMD x86-64 architecture
+ ///
+ [Description("AMD x86-64 architecture")]
+ X8664 = 62,
+
+ ///
+ /// Sony DSP Processor
+ ///
+ [Description("Sony DSP Processor")]
+ PDSP = 63,
+
+ ///
+ /// Digital Equipment Corp. PDP-10
+ ///
+ [Description("Digital Equipment Corp. PDP-10")]
+ PDP10 = 64,
+
+ ///
+ /// Digital Equipment Corp. PDP-11
+ ///
+ [Description("Digital Equipment Corp. PDP-11")]
+ PDP11 = 10,
+
+ ///
+ /// Siemens FX66 microcontroller
+ ///
+ [Description("Siemens FX66 microcontroller")]
+ FX66 = 66,
+
+ ///
+ /// STMicroelectronics ST9+ 8/16 bit microcontroller
+ ///
+ [Description("STMicroelectronics ST9+ 8/16 bit microcontroller")]
+ ST9PLUS = 67,
+
+ ///
+ /// STMicroelectronics ST7 8-bit microcontroller
+ ///
+ [Description("STMicroelectronics ST7 8-bit microcontroller")]
+ ST7 = 68,
+
+ ///
+ /// Motorola MC68HC16 Microcontroller
+ ///
+ [Description("Motorola MC68HC16 Microcontroller")]
+ MC68HC16 = 69,
+
+ ///
+ /// Motorola MC68HC11 Microcontroller
+ ///
+ [Description("Motorola MC68HC11 Microcontroller")]
+ MC68HC11 = 70,
+
+ ///
+ /// Motorola MC68HC08 Microcontroller
+ ///
+ [Description("Motorola MC68HC08 Microcontroller")]
+ MC68HC08 = 71,
+
+ ///
+ /// Motorola MC68HC05 Microcontroller
+ ///
+ [Description("Motorola MC68HC05 Microcontroller")]
+ MC68HC05 = 72,
+
+ ///
+ /// Silicon Graphics SVx
+ ///
+ [Description("Silicon Graphics SVx")]
+ SVX = 73,
+
+ ///
+ /// STMicroelectronics ST19 8-bit microcontroller
+ ///
+ [Description("STMicroelectronics ST19 8-bit microcontroller")]
+ ST19 = 74,
+
+ ///
+ /// Digital VAX
+ ///
+ [Description("Digital VAX")]
+ VAX = 75,
+
+ ///
+ /// Axis Communications 32-bit embedded processor
+ ///
+ [Description("Axis Communications 32-bit embedded processor")]
+ CRIS = 76,
+
+ ///
+ /// Infineon Technologies 32-bit embedded processor
+ ///
+ [Description("Infineon Technologies 32-bit embedded processor")]
+ JAVELIN = 77,
+
+ ///
+ /// Element 14 64-bit DSP Processor
+ ///
+ [Description("Element 14 64-bit DSP Processor")]
+ FIREPATH = 78,
+
+ ///
+ /// LSI Logic 16-bit DSP Processor
+ ///
+ [Description("LSI Logic 16-bit DSP Processor")]
+ ZSP = 79,
+
+ ///
+ /// Donald Knuth's educational 64-bit processor
+ ///
+ [Description("Donald Knuth's educational 64-bit processor")]
+ MMIX = 80,
+
+ ///
+ /// Harvard University machine-independent object files
+ ///
+ [Description("Harvard University machine-independent object files")]
+ HUANY = 81,
+
+ ///
+ /// SiTera Prism
+ ///
+ [Description("SiTera Prism")]
+ Prism = 82,
+
+ ///
+ /// Atmel AVR 8-bit microcontroller
+ ///
+ [Description("Atmel AVR 8-bit microcontroller")]
+ AVR = 83,
+
+ ///
+ /// Fujitsu FR30
+ ///
+ [Description("Fujitsu FR30")]
+ FR30 = 84,
+
+ ///
+ /// Mitsubishi D10V
+ ///
+ [Description("Mitsubishi D10V")]
+ D10V = 85,
+
+ ///
+ /// Mitsubishi D30V
+ ///
+ [Description("Mitsubishi D30V")]
+ D30V = 86,
+
+ ///
+ /// NEC v850
+ ///
+ [Description("NEC v850")]
+ V850 = 87,
+
+ ///
+ /// Mitsubishi M32R
+ ///
+ [Description("Mitsubishi M32R")]
+ M32R = 88,
+
+ ///
+ /// Matsushita MN10300
+ ///
+ [Description("Matsushita MN10300")]
+ MN10300 = 89,
+
+ ///
+ /// Matsushita MN10200
+ ///
+ [Description("Matsushita MN10200")]
+ MN10200 = 90,
+
+ ///
+ /// picoJava
+ ///
+ [Description("picoJava")]
+ PJ = 91,
+
+ ///
+ /// OpenRISC 32-bit embedded processor
+ ///
+ [Description("OpenRISC 32-bit embedded processor")]
+ OpenRISC = 92,
+
+ ///
+ /// ARC Cores Tangent-A5
+ ///
+ [Description("ARC Cores Tangent-A5")]
+ ARCA5 = 93,
+
+ ///
+ /// Tensilica Xtensa Architecture
+ ///
+ [Description("Tensilica Xtensa Architecture")]
+ Xtensa = 94,
+
+ ///
+ /// Alphamosaic VideoCore processor
+ ///
+ [Description("Alphamosaic VideoCore processor")]
+ VideoCore = 95,
+
+ ///
+ /// Thompson Multimedia General Purpose Processor
+ ///
+ [Description("Thompson Multimedia General Purpose Processor")]
+ TMMGPP = 96,
+
+ ///
+ /// National Semiconductor 32000 series
+ ///
+ [Description("National Semiconductor 32000 series")]
+ NS32K = 97,
+
+ ///
+ /// Tenor Network TPC processor
+ ///
+ [Description("Tenor Network TPC processor")]
+ TPC = 98,
+
+ ///
+ /// Trebia SNP 1000 processor
+ ///
+ [Description("Trebia SNP 1000 processor")]
+ SNP1K = 99,
+
+ ///
+ /// STMicroelectronics (www.st.com) ST200 microcontroller
+ ///
+ [Description("STMicroelectronics (www.st.com) ST200 microcontroller")]
+ ST200 = 100,
+ }
+}