Skip to content

Commit 32455f9

Browse files
committed
Add C-SKY linux support to Ultimate edition.
1 parent fdff8c8 commit 32455f9

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

platform/linux/platform_linux.cpp

+75-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,52 @@ class LinuxRiscVPlatform : public Platform
226226
}
227227
};
228228

229+
#ifdef ULTIMATE_EDITION
230+
class LinuxCSkyV1Platform : public Platform
231+
{
232+
public:
233+
LinuxCSkyV1Platform(Architecture* arch, const std::string& name) : Platform(arch, name)
234+
{
235+
Ref<CallingConvention> cc;
236+
237+
cc = arch->GetCallingConventionByName("default");
238+
if (cc)
239+
{
240+
RegisterDefaultCallingConvention(cc);
241+
RegisterCdeclCallingConvention(cc);
242+
RegisterFastcallCallingConvention(cc);
243+
RegisterStdcallCallingConvention(cc);
244+
}
245+
246+
cc = arch->GetCallingConventionByName("syscall");
247+
if (cc)
248+
SetSystemCallConvention(cc);
249+
}
250+
};
251+
252+
class LinuxCSkyV2Platform : public Platform
253+
{
254+
public:
255+
LinuxCSkyV2Platform(Architecture* arch, const std::string& name) : Platform(arch, name)
256+
{
257+
Ref<CallingConvention> cc;
258+
259+
cc = arch->GetCallingConventionByName("default");
260+
if (cc)
261+
{
262+
RegisterDefaultCallingConvention(cc);
263+
RegisterCdeclCallingConvention(cc);
264+
RegisterFastcallCallingConvention(cc);
265+
RegisterStdcallCallingConvention(cc);
266+
}
267+
268+
cc = arch->GetCallingConventionByName("syscall");
269+
if (cc)
270+
SetSystemCallConvention(cc);
271+
}
272+
};
273+
#endif
274+
229275

230276
extern "C"
231277
{
@@ -240,7 +286,9 @@ extern "C"
240286
AddOptionalPluginDependency("arch_mips");
241287
AddOptionalPluginDependency("arch_ppc");
242288
AddOptionalPluginDependency("arch_riscv");
243-
AddOptionalPluginDependency("arch_msp430");
289+
#ifdef ULTIMATE_EDITION
290+
AddOptionalPluginDependency("arch_csky");
291+
#endif
244292
AddOptionalPluginDependency("view_elf");
245293
}
246294
#endif
@@ -411,6 +459,32 @@ extern "C"
411459
BinaryViewType::RegisterPlatform("ELF", 3, rv64, platform);
412460
}
413461

462+
#ifdef ULTIMATE_EDITION
463+
Ref<Architecture> cskyv1 = Architecture::GetByName("csky_le_v1");
464+
if (cskyv1)
465+
{
466+
Ref<Platform> platform;
467+
468+
platform = new LinuxCSkyV1Platform(cskyv1, "linux-csky_le_v1");
469+
Platform::Register("linux", platform);
470+
// Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one
471+
BinaryViewType::RegisterPlatform("ELF", 0, cskyv1, platform);
472+
BinaryViewType::RegisterPlatform("ELF", 3, cskyv1, platform);
473+
}
474+
475+
Ref<Architecture> cskyv2 = Architecture::GetByName("csky_le");
476+
if (cskyv2)
477+
{
478+
Ref<Platform> platform;
479+
480+
platform = new LinuxCSkyV2Platform(cskyv2, "linux-csky_le");
481+
Platform::Register("linux", platform);
482+
// Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one
483+
BinaryViewType::RegisterPlatform("ELF", 0, cskyv2, platform);
484+
BinaryViewType::RegisterPlatform("ELF", 3, cskyv2, platform);
485+
}
486+
#endif
487+
414488
return true;
415489
}
416490
}

0 commit comments

Comments
 (0)