diff options
| author | Alexander Taylor <alex@vector35.com> | 2025-02-25 19:46:55 -0500 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2025-03-10 11:11:56 -0400 |
| commit | 32455f977824cf50ec0049cad16e741f0d050c73 (patch) | |
| tree | c00ee0ce84fa2dc36fc5844744a62aa94e194f74 | |
| parent | fdff8c85a51c4b77e4e25226ab4b2efb8d31ab9d (diff) | |
Add C-SKY linux support to Ultimate edition.
| -rw-r--r-- | platform/linux/platform_linux.cpp | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/platform/linux/platform_linux.cpp b/platform/linux/platform_linux.cpp index 0a70f5b5..2ba346f8 100644 --- a/platform/linux/platform_linux.cpp +++ b/platform/linux/platform_linux.cpp @@ -226,6 +226,52 @@ public: } }; +#ifdef ULTIMATE_EDITION +class LinuxCSkyV1Platform : public Platform +{ +public: + LinuxCSkyV1Platform(Architecture* arch, const std::string& name) : Platform(arch, name) + { + Ref<CallingConvention> cc; + + cc = arch->GetCallingConventionByName("default"); + if (cc) + { + RegisterDefaultCallingConvention(cc); + RegisterCdeclCallingConvention(cc); + RegisterFastcallCallingConvention(cc); + RegisterStdcallCallingConvention(cc); + } + + cc = arch->GetCallingConventionByName("syscall"); + if (cc) + SetSystemCallConvention(cc); + } +}; + +class LinuxCSkyV2Platform : public Platform +{ +public: + LinuxCSkyV2Platform(Architecture* arch, const std::string& name) : Platform(arch, name) + { + Ref<CallingConvention> cc; + + cc = arch->GetCallingConventionByName("default"); + if (cc) + { + RegisterDefaultCallingConvention(cc); + RegisterCdeclCallingConvention(cc); + RegisterFastcallCallingConvention(cc); + RegisterStdcallCallingConvention(cc); + } + + cc = arch->GetCallingConventionByName("syscall"); + if (cc) + SetSystemCallConvention(cc); + } +}; +#endif + extern "C" { @@ -240,7 +286,9 @@ extern "C" AddOptionalPluginDependency("arch_mips"); AddOptionalPluginDependency("arch_ppc"); AddOptionalPluginDependency("arch_riscv"); - AddOptionalPluginDependency("arch_msp430"); +#ifdef ULTIMATE_EDITION + AddOptionalPluginDependency("arch_csky"); +#endif AddOptionalPluginDependency("view_elf"); } #endif @@ -411,6 +459,32 @@ extern "C" BinaryViewType::RegisterPlatform("ELF", 3, rv64, platform); } +#ifdef ULTIMATE_EDITION + Ref<Architecture> cskyv1 = Architecture::GetByName("csky_le_v1"); + if (cskyv1) + { + Ref<Platform> platform; + + platform = new LinuxCSkyV1Platform(cskyv1, "linux-csky_le_v1"); + Platform::Register("linux", platform); + // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one + BinaryViewType::RegisterPlatform("ELF", 0, cskyv1, platform); + BinaryViewType::RegisterPlatform("ELF", 3, cskyv1, platform); + } + + Ref<Architecture> cskyv2 = Architecture::GetByName("csky_le"); + if (cskyv2) + { + Ref<Platform> platform; + + platform = new LinuxCSkyV2Platform(cskyv2, "linux-csky_le"); + Platform::Register("linux", platform); + // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one + BinaryViewType::RegisterPlatform("ELF", 0, cskyv2, platform); + BinaryViewType::RegisterPlatform("ELF", 3, cskyv2, platform); + } +#endif + return true; } } |
