From eed70ad4d270ca1d134d325362f23c831fe98b0b Mon Sep 17 00:00:00 2001 From: noone Date: Tue, 11 Jun 2024 04:44:24 -0500 Subject: Add Cavium Octeon MIPS Instructions and more general MIPS fixes --- platform/linux/platform_linux.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'platform/linux/platform_linux.cpp') diff --git a/platform/linux/platform_linux.cpp b/platform/linux/platform_linux.cpp index e6f3ecb4..8377aad9 100644 --- a/platform/linux/platform_linux.cpp +++ b/platform/linux/platform_linux.cpp @@ -181,6 +181,28 @@ public: } }; +class LinuxMips64Platform: public Platform +{ +public: + LinuxMips64Platform(Architecture* arch, const std::string& name): Platform(arch, name) + { + Ref cc; + + cc = arch->GetCallingConventionByName("n64"); + if (cc) + { + RegisterDefaultCallingConvention(cc); + RegisterCdeclCallingConvention(cc); + RegisterFastcallCallingConvention(cc); + RegisterStdcallCallingConvention(cc); + } + + cc = arch->GetCallingConventionByName("linux-syscall"); + if (cc) + SetSystemCallConvention(cc); + } +}; + class LinuxRiscVPlatform : public Platform { @@ -329,19 +351,29 @@ extern "C" Ref mipsel = Architecture::GetByName("mipsel32"); Ref mipseb = Architecture::GetByName("mips32"); - if (mipsel && mipseb) + Ref mips64eb = Architecture::GetByName("mips64"); + Ref cnmips64eb = Architecture::GetByName("cavium-mips64"); + if (mipsel && mipseb && mips64eb && cnmips64eb) { - Ref platformLE, platformBE; + Ref platformLE, platformBE, platformBE64, platformBE64cn; platformLE = new LinuxMipsPlatform(mipsel, "linux-mipsel"); platformBE = new LinuxMipsPlatform(mipseb, "linux-mips"); + platformBE64 = new LinuxMips64Platform(mips64eb, "linux-mips64"); + platformBE64cn = new LinuxMips64Platform(cnmips64eb, "linux-cnmips64"); Platform::Register("linux", platformLE); Platform::Register("linux", platformBE); + Platform::Register("linux", platformBE64); + Platform::Register("linux", platformBE64cn); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one BinaryViewType::RegisterPlatform("ELF", 0, mipsel, platformLE); BinaryViewType::RegisterPlatform("ELF", 0, mipseb, platformBE); + BinaryViewType::RegisterPlatform("ELF", 0, mips64eb, platformBE64); + BinaryViewType::RegisterPlatform("ELF", 0, cnmips64eb, platformBE64cn); BinaryViewType::RegisterPlatform("ELF", 3, mipsel, platformLE); BinaryViewType::RegisterPlatform("ELF", 3, mipseb, platformBE); + BinaryViewType::RegisterPlatform("ELF", 3, mips64eb, platformBE64); + BinaryViewType::RegisterPlatform("ELF", 3, cnmips64eb, platformBE64cn); } Ref rv32 = Architecture::GetByName("rv32gc"); -- cgit v1.3.1