protected override IProcessorArchitecture CreateArchitecture(byte endianness) { var options = new Dictionary <string, object>(); string archName; switch (machine) { case ElfMachine.EM_IA_64: archName = "ia64"; break; case ElfMachine.EM_MIPS: //$TODO: detect release 6 of the MIPS architecture. // would be great to get our sweaty little hands on // such a binary. if (endianness == ELFDATA2LSB) { archName = "mips-le-64"; } else if (endianness == ELFDATA2MSB) { archName = "mips-be-64"; } else { throw new NotSupportedException(string.Format("The MIPS architecture does not support ELF endianness value {0}", endianness)); } break; case ElfMachine.EM_PARISC: archName = "paRisc"; options["WordSize"] = "64"; break; case ElfMachine.EM_RISCV: archName = "risc-v"; options["WordSize"] = "64"; RiscVElf.SetOptions((RiscVFlags)Header64.e_flags, options); break; case ElfMachine.EM_S390: //$REVIEW: any pertinent differences? archName = "zSeries"; options["WordSize"] = "64"; break; default: return(base.CreateArchitecture(endianness)); } var cfgSvc = Services.RequireService <IConfigurationService>(); var arch = cfgSvc.GetArchitecture(archName); arch.LoadUserOptions(options); return(arch); }
protected override IProcessorArchitecture?CreateArchitecture(EndianServices endianness) { var options = new Dictionary <string, object>(); string archName; switch (machine) { case ElfMachine.EM_IA_64: archName = "ia64"; break; case ElfMachine.EM_MIPS: //$TODO: detect release 6 of the MIPS architecture. // would be great to get our sweaty little hands on // such a binary. archName = endianness == EndianServices.Little ? "mips-le-64" : "mips-be-64"; break; case ElfMachine.EM_PARISC: archName = "paRisc"; options["WordSize"] = "64"; break; case ElfMachine.EM_RISCV: archName = "risc-v"; options["WordSize"] = "64"; var flags = (RiscVFlags)Header64.e_flags; // According to the Risc-V ELF spec, a RV64G implementation is strongly // encouraged to support the LP64D ABI if ((flags & RiscVFlags.EF_RISCV_FLOAT_ABI_MASK) == 0) { flags |= RiscVFlags.EF_RISCV_FLOAT_ABI_DOUBLE; } RiscVElf.SetOptions(flags, options); break; case ElfMachine.EM_S390: //$REVIEW: any pertinent differences? archName = "zSeries"; options["WordSize"] = "64"; break; default: return(base.CreateArchitecture(endianness)); } var cfgSvc = Services.RequireService <IConfigurationService>(); var arch = cfgSvc.GetArchitecture(archName, options); return(arch); }
protected override IProcessorArchitecture CreateArchitecture(EndianServices endianness) { var options = new Dictionary <string, object>(); string archName; switch (machine) { case ElfMachine.EM_IA_64: archName = "ia64"; break; case ElfMachine.EM_MIPS: //$TODO: detect release 6 of the MIPS architecture. // would be great to get our sweaty little hands on // such a binary. archName = endianness == EndianServices.Little ? "mips-le-64" : "mips-be-64"; break; case ElfMachine.EM_PARISC: archName = "paRisc"; options["WordSize"] = "64"; break; case ElfMachine.EM_RISCV: archName = "risc-v"; options["WordSize"] = "64"; RiscVElf.SetOptions((RiscVFlags)Header64.e_flags, options); break; case ElfMachine.EM_S390: //$REVIEW: any pertinent differences? archName = "zSeries"; options["WordSize"] = "64"; break; default: return(base.CreateArchitecture(endianness)); } var cfgSvc = Services.RequireService <IConfigurationService>(); var arch = cfgSvc.GetArchitecture(archName, options); return(arch); }
protected override IProcessorArchitecture CreateArchitecture(byte endianness) { string arch; var options = new Dictionary <string, object>(); string stackRegName = null; switch (machine) { case ElfMachine.EM_MIPS: //$TODO: detect release 6 of the MIPS architecture. // would be great to get our sweaty little hands on // such a binary. var mipsFlags = (MIPSflags)Header.e_flags; bool is64 = false; switch (mipsFlags & MIPSflags.EF_MIPS_ARCH) { case MIPSflags.EF_MIPS_ARCH_64: is64 = true; break; case MIPSflags.EF_MIPS_ARCH_64R2: is64 = true; options["decoder"] = "v6"; break; case MIPSflags.EF_MIPS_ARCH_32R2: options["decoder"] = "v6"; break; } if (endianness == ELFDATA2LSB) { arch = is64 ? "mips-le-64" : "mips-le-32"; } else if (endianness == ELFDATA2MSB) { arch = is64 ? "mips-be-64" : "mips-be-32"; } else { throw new NotSupportedException(string.Format("The MIPS architecture does not support ELF endianness value {0}", endianness)); } break; case ElfMachine.EM_RISCV: arch = "risc-v"; options["WordSize"] = "32"; RiscVElf.SetOptions((RiscVFlags)Header.e_flags, options); break; default: return(base.CreateArchitecture(endianness)); } var cfgSvc = Services.RequireService <IConfigurationService>(); var a = cfgSvc.GetArchitecture(arch); a.LoadUserOptions(options); if (stackRegName != null) { a.StackRegister = a.GetRegister(stackRegName); } return(a); }
protected override IProcessorArchitecture?CreateArchitecture(EndianServices endianness) { string arch; var options = new Dictionary <string, object>(); string?stackRegName = null; options[ProcessorOption.Endianness] = (endianness == EndianServices.Little) ? "le" : "be"; switch (machine) { case ElfMachine.EM_MIPS: //$TODO: detect release 6 of the MIPS architecture. // would be great to get our sweaty little hands on // such a binary. var mipsFlags = (MIPSflags)Header.e_flags; bool is64 = false; switch (mipsFlags & MIPSflags.EF_MIPS_ARCH) { case MIPSflags.EF_MIPS_ARCH_64: is64 = true; break; case MIPSflags.EF_MIPS_ARCH_64R2: is64 = true; options[ProcessorOption.InstructionSet] = "v6"; break; case MIPSflags.EF_MIPS_ARCH_32R2: options[ProcessorOption.InstructionSet] = "v6"; break; } if (endianness == EndianServices.Little) { arch = is64 ? "mips-le-64" : "mips-le-32"; } else if (endianness == EndianServices.Big) { arch = is64 ? "mips-be-64" : "mips-be-32"; } else { throw new NotSupportedException($"The MIPS architecture does not support ELF endianness value {endianness}."); } break; case ElfMachine.EM_RISCV: arch = "risc-v"; options[ProcessorOption.WordSize] = "32"; RiscVElf.SetOptions((RiscVFlags)Header.e_flags, options); break; default: return(base.CreateArchitecture(endianness)); } var cfgSvc = Services.RequireService <IConfigurationService>(); var a = cfgSvc.GetArchitecture(arch, options); if (a is null) { throw new InvalidOperationException($"Unknown architecture '{arch}'."); } if (stackRegName != null) { var sp = a.GetRegister(stackRegName); if (sp != null) { a.StackRegister = sp; } } return(a); }