Skip to content

Commit 45199a8

Browse files
committed
[mips] Add mips3 to linux platform
1 parent ed27be5 commit 45199a8

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

arch/mips/arch_mips.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,16 +3263,18 @@ extern "C"
32633263
{
32643264
InitMipsSettings();
32653265

3266-
Architecture* mipsel = new MipsArchitecture("mipsel32", LittleEndian, 32, MIPS_32);
32673266
Architecture* mipseb = new MipsArchitecture("mips32", BigEndian, 32, MIPS_32);
3267+
Architecture* mipsel = new MipsArchitecture("mipsel32", LittleEndian, 32, MIPS_32);
32683268
Architecture* mips3 = new MipsArchitecture("mips3", BigEndian, 32, MIPS_3);
3269+
Architecture* mips3el = new MipsArchitecture("mipsel3", LittleEndian, 32, MIPS_3);
32693270
Architecture* mips64el = new MipsArchitecture("mipsel64", LittleEndian, 64, MIPS_64);
32703271
Architecture* mips64eb = new MipsArchitecture("mips64", BigEndian, 64, MIPS_64);
32713272
Architecture* cnmips64eb = new MipsArchitecture("cavium-mips64", BigEndian, 64, MIPS_64, DECOMPOSE_FLAGS_CAVIUM);
32723273

3273-
Architecture::Register(mipsel);
32743274
Architecture::Register(mipseb);
3275+
Architecture::Register(mipsel);
32753276
Architecture::Register(mips3);
3277+
Architecture::Register(mips3el);
32763278
Architecture::Register(mips64el);
32773279
Architecture::Register(mips64eb);
32783280
Architecture::Register(cnmips64eb);
@@ -3284,12 +3286,14 @@ extern "C"
32843286
MipsN64CallingConvention* n64BE = new MipsN64CallingConvention(mips64eb);
32853287
MipsN64CallingConvention* n64BEc = new MipsN64CallingConvention(cnmips64eb);
32863288

3287-
mipsel->RegisterCallingConvention(o32LE);
3288-
mipsel->SetDefaultCallingConvention(o32LE);
32893289
mipseb->RegisterCallingConvention(o32BE);
32903290
mipseb->SetDefaultCallingConvention(o32BE);
3291+
mipsel->RegisterCallingConvention(o32LE);
3292+
mipsel->SetDefaultCallingConvention(o32LE);
32913293
mips3->RegisterCallingConvention(o32BE);
32923294
mips3->SetDefaultCallingConvention(o32BE);
3295+
mips3->RegisterCallingConvention(o32LE);
3296+
mips3->SetDefaultCallingConvention(o32LE);
32933297
mips64el->RegisterCallingConvention(n64LE);
32943298
mips64el->SetDefaultCallingConvention(n64LE);
32953299
mips64eb->RegisterCallingConvention(n64BE);
@@ -3299,25 +3303,29 @@ extern "C"
32993303

33003304
MipsLinuxSyscallCallingConvention* linuxSyscallLE = new MipsLinuxSyscallCallingConvention(mipsel);
33013305
MipsLinuxSyscallCallingConvention* linuxSyscallBE = new MipsLinuxSyscallCallingConvention(mipseb);
3302-
mipsel->RegisterCallingConvention(linuxSyscallLE);
33033306
mipseb->RegisterCallingConvention(linuxSyscallBE);
3307+
mipsel->RegisterCallingConvention(linuxSyscallLE);
33043308
mips3->RegisterCallingConvention(linuxSyscallBE);
3309+
mips3el->RegisterCallingConvention(linuxSyscallLE);
33053310

3306-
mipsel->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mipsel));
33073311
mipseb->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mipseb));
3312+
mipsel->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mipsel));
33083313
mips3->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mips3));
3314+
mips3el->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mips3el));
33093315
mips64el->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mips64el));
33103316
mips64eb->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(mips64eb));
33113317
cnmips64eb->RegisterCallingConvention(new MipsLinuxRtlResolveCallingConvention(cnmips64eb));
33123318

33133319
/* function recognizers */
3314-
mipsel->RegisterFunctionRecognizer(new MipsImportedFunctionRecognizer());
33153320
mipseb->RegisterFunctionRecognizer(new MipsImportedFunctionRecognizer());
3321+
mipsel->RegisterFunctionRecognizer(new MipsImportedFunctionRecognizer());
33163322
mips3->RegisterFunctionRecognizer(new MipsImportedFunctionRecognizer());
3323+
mips3el->RegisterFunctionRecognizer(new MipsImportedFunctionRecognizer());
33173324

3318-
mipsel->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
33193325
mipseb->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
3326+
mipsel->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
33203327
mips3->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
3328+
mips3el->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
33213329
mips64el->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
33223330
mips64eb->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
33233331
cnmips64eb->RegisterRelocationHandler("ELF", new MipsElfRelocationHandler());
@@ -3336,7 +3344,6 @@ extern "C"
33363344
BinaryViewType::RegisterArchitecture("ELF", ARCH_ID_MIPS64, BigEndian, mips64eb);
33373345
BinaryViewType::RegisterArchitecture("ELF", ARCH_ID_MIPS32, LittleEndian, mipsel);
33383346
BinaryViewType::RegisterArchitecture("ELF", ARCH_ID_MIPS32, BigEndian, mipseb);
3339-
BinaryViewType::RegisterArchitecture("ELF", ARCH_ID_MIPS32, BigEndian, mips3);
33403347

33413348
Ref<BinaryViewType> elf = BinaryViewType::GetByName("ELF");
33423349
if (elf)

platform/linux/platform_linux.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,27 +352,37 @@ extern "C"
352352

353353
Ref<Architecture> mipsel = Architecture::GetByName("mipsel32");
354354
Ref<Architecture> mipseb = Architecture::GetByName("mips32");
355+
Ref<Architecture> mips3el = Architecture::GetByName("mipsel3");
356+
Ref<Architecture> mips3eb = Architecture::GetByName("mips3");
355357
Ref<Architecture> mips64eb = Architecture::GetByName("mips64");
356358
Ref<Architecture> cnmips64eb = Architecture::GetByName("cavium-mips64");
357-
if (mipsel && mipseb && mips64eb && cnmips64eb)
359+
if (mipsel && mipseb && mips64eb && cnmips64eb && mips3el && mips3eb)
358360
{
359-
Ref<Platform> platformLE, platformBE, platformBE64, platformBE64cn;
361+
Ref<Platform> platformLE, platformBE, platformBE64, platformBE64cn, platform3LE, platform3BE;
360362

361363
platformLE = new LinuxMipsPlatform(mipsel, "linux-mipsel");
362364
platformBE = new LinuxMipsPlatform(mipseb, "linux-mips");
365+
platform3LE = new LinuxMipsPlatform(mips3el, "linux-mipsel3");
366+
platform3BE = new LinuxMipsPlatform(mips3eb, "linux-mips3");
363367
platformBE64 = new LinuxMips64Platform(mips64eb, "linux-mips64");
364368
platformBE64cn = new LinuxMips64Platform(cnmips64eb, "linux-cnmips64");
365369
Platform::Register("linux", platformLE);
366370
Platform::Register("linux", platformBE);
371+
Platform::Register("linux", platform3LE);
372+
Platform::Register("linux", platform3BE);
367373
Platform::Register("linux", platformBE64);
368374
Platform::Register("linux", platformBE64cn);
369375
// Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one
370376
BinaryViewType::RegisterPlatform("ELF", 0, mipsel, platformLE);
371377
BinaryViewType::RegisterPlatform("ELF", 0, mipseb, platformBE);
378+
BinaryViewType::RegisterPlatform("ELF", 0, mips3el, platform3LE);
379+
BinaryViewType::RegisterPlatform("ELF", 0, mips3eb, platform3BE);
372380
BinaryViewType::RegisterPlatform("ELF", 0, mips64eb, platformBE64);
373381
BinaryViewType::RegisterPlatform("ELF", 0, cnmips64eb, platformBE64cn);
374382
BinaryViewType::RegisterPlatform("ELF", 3, mipsel, platformLE);
375383
BinaryViewType::RegisterPlatform("ELF", 3, mipseb, platformBE);
384+
BinaryViewType::RegisterPlatform("ELF", 3, mips3el, platform3LE);
385+
BinaryViewType::RegisterPlatform("ELF", 3, mips3eb, platform3BE);
376386
BinaryViewType::RegisterPlatform("ELF", 3, mips64eb, platformBE64);
377387
BinaryViewType::RegisterPlatform("ELF", 3, cnmips64eb, platformBE64cn);
378388
}

0 commit comments

Comments
 (0)