diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h --- a/llvm/include/llvm/BinaryFormat/ELF.h +++ b/llvm/include/llvm/BinaryFormat/ELF.h @@ -320,6 +320,7 @@ EM_BPF = 247, // Linux kernel bpf virtual machine EM_VE = 251, // NEC SX-Aurora VE EM_CSKY = 252, // C-SKY 32-bit processor + EM_LOONGARCH = 258, // LoongArch }; // Object file classes. @@ -866,6 +867,11 @@ #include "ELFRelocs/CSKY.def" }; +// ELF Relocation types for LoongArch +enum { +#include "ELFRelocs/LoongArch.def" +}; + #undef ELF_RELOC // Section header. diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def b/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def new file mode 100644 --- /dev/null +++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def @@ -0,0 +1,63 @@ +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// These types and values are from the LoongArch ELF psABI which can be found at +// https://github.com/loongson/LoongArch-Documentation +// and these definitions has been adopted by binutils (include/elf/loongarch.h). +// The commit hash (main branch) we reference is: +// 9b3bd9f4a497115913c22f1a2a47863798fbc02a + +ELF_RELOC(R_LARCH_NONE, 0) +ELF_RELOC(R_LARCH_32, 1) +ELF_RELOC(R_LARCH_64, 2) +ELF_RELOC(R_LARCH_RELATIVE, 3) +ELF_RELOC(R_LARCH_COPY, 4) +ELF_RELOC(R_LARCH_JUMP_SLOT, 5) +ELF_RELOC(R_LARCH_TLS_DTPMOD32, 6) +ELF_RELOC(R_LARCH_TLS_DTPMOD64, 7) +ELF_RELOC(R_LARCH_TLS_DTPREL32, 8) +ELF_RELOC(R_LARCH_TLS_DTPREL64, 9) +ELF_RELOC(R_LARCH_TLS_TPREL32, 10) +ELF_RELOC(R_LARCH_TLS_TPREL64, 11) +ELF_RELOC(R_LARCH_IRELATIVE, 12) + +ELF_RELOC(R_LARCH_MARK_LA, 20) +ELF_RELOC(R_LARCH_MARK_PCREL, 21) +ELF_RELOC(R_LARCH_SOP_PUSH_PCREL, 22) +ELF_RELOC(R_LARCH_SOP_PUSH_ABSOLUTE, 23) +ELF_RELOC(R_LARCH_SOP_PUSH_DUP, 24) +ELF_RELOC(R_LARCH_SOP_PUSH_GPREL, 25) +ELF_RELOC(R_LARCH_SOP_PUSH_TLS_TPREL, 26) +ELF_RELOC(R_LARCH_SOP_PUSH_TLS_GOT, 27) +ELF_RELOC(R_LARCH_SOP_PUSH_TLS_GD, 28) +ELF_RELOC(R_LARCH_SOP_PUSH_PLT_PCREL, 29) +ELF_RELOC(R_LARCH_SOP_ASSERT, 30) +ELF_RELOC(R_LARCH_SOP_NOT, 31) +ELF_RELOC(R_LARCH_SOP_SUB, 32) +ELF_RELOC(R_LARCH_SOP_SL, 33) +ELF_RELOC(R_LARCH_SOP_SR, 34) +ELF_RELOC(R_LARCH_SOP_ADD, 35) +ELF_RELOC(R_LARCH_SOP_AND, 36) +ELF_RELOC(R_LARCH_SOP_IF_ELSE, 37) +ELF_RELOC(R_LARCH_SOP_POP_32_S_10_5, 38) +ELF_RELOC(R_LARCH_SOP_POP_32_U_10_12, 39) +ELF_RELOC(R_LARCH_SOP_POP_32_S_10_12, 40) +ELF_RELOC(R_LARCH_SOP_POP_32_S_10_16, 41) +ELF_RELOC(R_LARCH_SOP_POP_32_S_10_16_S2, 42) +ELF_RELOC(R_LARCH_SOP_POP_32_S_5_20, 43) +ELF_RELOC(R_LARCH_SOP_POP_32_S_0_5_10_16_S2, 44) +ELF_RELOC(R_LARCH_SOP_POP_32_S_0_10_10_16_S2, 45) +ELF_RELOC(R_LARCH_SOP_POP_32_U, 46) +ELF_RELOC(R_LARCH_ADD8, 47) +ELF_RELOC(R_LARCH_ADD16, 48) +ELF_RELOC(R_LARCH_ADD24, 49) +ELF_RELOC(R_LARCH_ADD32, 50) +ELF_RELOC(R_LARCH_ADD64, 51) +ELF_RELOC(R_LARCH_SUB8, 52) +ELF_RELOC(R_LARCH_SUB16, 53) +ELF_RELOC(R_LARCH_SUB24, 54) +ELF_RELOC(R_LARCH_SUB32, 55) +ELF_RELOC(R_LARCH_SUB64, 56) +ELF_RELOC(R_LARCH_GNU_VTINHERIT, 57) +ELF_RELOC(R_LARCH_GNU_VTENTRY, 58) diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -1201,6 +1201,8 @@ return "elf32-sparc"; case ELF::EM_AMDGPU: return "elf32-amdgpu"; + case ELF::EM_LOONGARCH: + return "elf32-loongarch"; default: return "elf32-unknown"; } @@ -1228,6 +1230,8 @@ return "elf64-bpf"; case ELF::EM_VE: return "elf64-ve"; + case ELF::EM_LOONGARCH: + return "elf64-loongarch"; default: return "elf64-unknown"; } @@ -1312,6 +1316,17 @@ return Triple::ve; case ELF::EM_CSKY: return Triple::csky; + + case ELF::EM_LOONGARCH: + switch (EF.getHeader().e_ident[ELF::EI_CLASS]) { + case ELF::ELFCLASS32: + return Triple::loongarch32; + case ELF::ELFCLASS64: + return Triple::loongarch64; + default: + report_fatal_error("Invalid ELFCLASS!"); + } + default: return Triple::UnknownArch; } diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp --- a/llvm/lib/Object/ELF.cpp +++ b/llvm/lib/Object/ELF.cpp @@ -166,6 +166,13 @@ break; } break; + case ELF::EM_LOONGARCH: + switch (Type) { +#include "llvm/BinaryFormat/ELFRelocs/LoongArch.def" + default: + break; + } + break; default: break; } diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -344,6 +344,7 @@ ECase(EM_BPF); ECase(EM_VE); ECase(EM_CSKY); + ECase(EM_LOONGARCH); #undef ECase IO.enumFallback(Value); } @@ -841,6 +842,9 @@ case ELF::EM_68K: #include "llvm/BinaryFormat/ELFRelocs/M68k.def" break; + case ELF::EM_LOONGARCH: +#include "llvm/BinaryFormat/ELFRelocs/LoongArch.def" + break; default: // Nothing to do. break; diff --git a/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-loongarch64.test b/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-loongarch64.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-loongarch64.test @@ -0,0 +1,121 @@ +## Test that llvm-readobj/llvm-readelf shows proper relocation type +## names and values for loongarch64 target. + +# RUN: yaml2obj %s -o %t-loongarch64.o +# RUN: llvm-readobj -r --expand-relocs %t-loongarch64.o | FileCheck %s + +# CHECK: Type: R_LARCH_NONE (0) +# CHECK: Type: R_LARCH_32 (1) +# CHECK: Type: R_LARCH_64 (2) +# CHECK: Type: R_LARCH_RELATIVE (3) +# CHECK: Type: R_LARCH_COPY (4) +# CHECK: Type: R_LARCH_JUMP_SLOT (5) +# CHECK: Type: R_LARCH_TLS_DTPMOD32 (6) +# CHECK: Type: R_LARCH_TLS_DTPMOD64 (7) +# CHECK: Type: R_LARCH_TLS_DTPREL32 (8) +# CHECK: Type: R_LARCH_TLS_DTPREL64 (9) +# CHECK: Type: R_LARCH_TLS_TPREL32 (10) +# CHECK: Type: R_LARCH_TLS_TPREL64 (11) +# CHECK: Type: R_LARCH_IRELATIVE (12) +# CHECK: Type: R_LARCH_MARK_LA (20) +# CHECK: Type: R_LARCH_MARK_PCREL (21) +# CHECK: Type: R_LARCH_SOP_PUSH_PCREL (22) +# CHECK: Type: R_LARCH_SOP_PUSH_ABSOLUTE (23) +# CHECK: Type: R_LARCH_SOP_PUSH_DUP (24) +# CHECK: Type: R_LARCH_SOP_PUSH_GPREL (25) +# CHECK: Type: R_LARCH_SOP_PUSH_TLS_TPREL (26) +# CHECK: Type: R_LARCH_SOP_PUSH_TLS_GOT (27) +# CHECK: Type: R_LARCH_SOP_PUSH_TLS_GD (28) +# CHECK: Type: R_LARCH_SOP_PUSH_PLT_PCREL (29) +# CHECK: Type: R_LARCH_SOP_ASSERT (30) +# CHECK: Type: R_LARCH_SOP_NOT (31) +# CHECK: Type: R_LARCH_SOP_SUB (32) +# CHECK: Type: R_LARCH_SOP_SL (33) +# CHECK: Type: R_LARCH_SOP_SR (34) +# CHECK: Type: R_LARCH_SOP_ADD (35) +# CHECK: Type: R_LARCH_SOP_AND (36) +# CHECK: Type: R_LARCH_SOP_IF_ELSE (37) +# CHECK: Type: R_LARCH_SOP_POP_32_S_10_5 (38) +# CHECK: Type: R_LARCH_SOP_POP_32_U_10_12 (39) +# CHECK: Type: R_LARCH_SOP_POP_32_S_10_12 (40) +# CHECK: Type: R_LARCH_SOP_POP_32_S_10_16 (41) +# CHECK: Type: R_LARCH_SOP_POP_32_S_10_16_S2 (42) +# CHECK: Type: R_LARCH_SOP_POP_32_S_5_20 (43) +# CHECK: Type: R_LARCH_SOP_POP_32_S_0_5_10_16_S2 (44) +# CHECK: Type: R_LARCH_SOP_POP_32_S_0_10_10_16_S2 (45) +# CHECK: Type: R_LARCH_SOP_POP_32_U (46) +# CHECK: Type: R_LARCH_ADD8 (47) +# CHECK: Type: R_LARCH_ADD16 (48) +# CHECK: Type: R_LARCH_ADD24 (49) +# CHECK: Type: R_LARCH_ADD32 (50) +# CHECK: Type: R_LARCH_ADD64 (51) +# CHECK: Type: R_LARCH_SUB8 (52) +# CHECK: Type: R_LARCH_SUB16 (53) +# CHECK: Type: R_LARCH_SUB24 (54) +# CHECK: Type: R_LARCH_SUB32 (55) +# CHECK: Type: R_LARCH_SUB64 (56) +# CHECK: Type: R_LARCH_GNU_VTINHERIT (57) +# CHECK: Type: R_LARCH_GNU_VTENTRY (58) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_LOONGARCH +Sections: + - Name: .rela.text + Type: SHT_RELA + Relocations: + - Type: R_LARCH_NONE + - Type: R_LARCH_32 + - Type: R_LARCH_64 + - Type: R_LARCH_RELATIVE + - Type: R_LARCH_COPY + - Type: R_LARCH_JUMP_SLOT + - Type: R_LARCH_TLS_DTPMOD32 + - Type: R_LARCH_TLS_DTPMOD64 + - Type: R_LARCH_TLS_DTPREL32 + - Type: R_LARCH_TLS_DTPREL64 + - Type: R_LARCH_TLS_TPREL32 + - Type: R_LARCH_TLS_TPREL64 + - Type: R_LARCH_IRELATIVE + - Type: R_LARCH_MARK_LA + - Type: R_LARCH_MARK_PCREL + - Type: R_LARCH_SOP_PUSH_PCREL + - Type: R_LARCH_SOP_PUSH_ABSOLUTE + - Type: R_LARCH_SOP_PUSH_DUP + - Type: R_LARCH_SOP_PUSH_GPREL + - Type: R_LARCH_SOP_PUSH_TLS_TPREL + - Type: R_LARCH_SOP_PUSH_TLS_GOT + - Type: R_LARCH_SOP_PUSH_TLS_GD + - Type: R_LARCH_SOP_PUSH_PLT_PCREL + - Type: R_LARCH_SOP_ASSERT + - Type: R_LARCH_SOP_NOT + - Type: R_LARCH_SOP_SUB + - Type: R_LARCH_SOP_SL + - Type: R_LARCH_SOP_SR + - Type: R_LARCH_SOP_ADD + - Type: R_LARCH_SOP_AND + - Type: R_LARCH_SOP_IF_ELSE + - Type: R_LARCH_SOP_POP_32_S_10_5 + - Type: R_LARCH_SOP_POP_32_U_10_12 + - Type: R_LARCH_SOP_POP_32_S_10_12 + - Type: R_LARCH_SOP_POP_32_S_10_16 + - Type: R_LARCH_SOP_POP_32_S_10_16_S2 + - Type: R_LARCH_SOP_POP_32_S_5_20 + - Type: R_LARCH_SOP_POP_32_S_0_5_10_16_S2 + - Type: R_LARCH_SOP_POP_32_S_0_10_10_16_S2 + - Type: R_LARCH_SOP_POP_32_U + - Type: R_LARCH_ADD8 + - Type: R_LARCH_ADD16 + - Type: R_LARCH_ADD24 + - Type: R_LARCH_ADD32 + - Type: R_LARCH_ADD64 + - Type: R_LARCH_SUB8 + - Type: R_LARCH_SUB16 + - Type: R_LARCH_SUB24 + - Type: R_LARCH_SUB32 + - Type: R_LARCH_SUB64 + - Type: R_LARCH_GNU_VTINHERIT + - Type: R_LARCH_GNU_VTENTRY diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -1202,6 +1202,7 @@ ENUM_ENT(EM_LANAI, "EM_LANAI"), ENUM_ENT(EM_BPF, "EM_BPF"), ENUM_ENT(EM_VE, "NEC SX-Aurora Vector Engine"), + ENUM_ENT(EM_LOONGARCH, "LoongArch"), }; const EnumEntry ElfSymbolBindings[] = { diff --git a/llvm/unittests/Object/ELFObjectFileTest.cpp b/llvm/unittests/Object/ELFObjectFileTest.cpp --- a/llvm/unittests/Object/ELFObjectFileTest.cpp +++ b/llvm/unittests/Object/ELFObjectFileTest.cpp @@ -289,6 +289,19 @@ checkFormatAndArch(D, Formats[I++], Triple::msp430); } +TEST(ELFObjectFileTest, MachineTestForLoongArch) { + std::array Formats = {"elf32-loongarch", "elf32-loongarch", + "elf64-loongarch", "elf64-loongarch"}; + std::array Archs = { + Triple::loongarch32, Triple::loongarch32, Triple::loongarch64, + Triple::loongarch64}; + size_t I = 0; + for (const DataForTest &D : generateData(ELF::EM_LOONGARCH)) { + checkFormatAndArch(D, Formats[I], Archs[I]); + ++I; + } +} + TEST(ELFObjectFileTest, MachineTestForCSKY) { std::array Formats = {"elf32-csky", "elf32-csky", "elf64-unknown", "elf64-unknown"}; diff --git a/llvm/unittests/Object/ELFTest.cpp b/llvm/unittests/Object/ELFTest.cpp --- a/llvm/unittests/Object/ELFTest.cpp +++ b/llvm/unittests/Object/ELFTest.cpp @@ -52,6 +52,115 @@ EXPECT_EQ("R_VE_CALL_LO32", getELFRelocationTypeName(EM_VE, R_VE_CALL_LO32)); } +TEST(ELFTest, getELFRelocationTypeNameForLoongArch) { + EXPECT_EQ("R_LARCH_NONE", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_NONE)); + EXPECT_EQ("R_LARCH_32", getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_32)); + EXPECT_EQ("R_LARCH_64", getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_64)); + EXPECT_EQ("R_LARCH_RELATIVE", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_RELATIVE)); + EXPECT_EQ("R_LARCH_COPY", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_COPY)); + EXPECT_EQ("R_LARCH_JUMP_SLOT", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_JUMP_SLOT)); + EXPECT_EQ("R_LARCH_TLS_DTPMOD32", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPMOD32)); + EXPECT_EQ("R_LARCH_TLS_DTPMOD64", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPMOD64)); + EXPECT_EQ("R_LARCH_TLS_DTPREL32", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPREL32)); + EXPECT_EQ("R_LARCH_TLS_DTPREL64", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPREL64)); + EXPECT_EQ("R_LARCH_TLS_TPREL32", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_TPREL32)); + EXPECT_EQ("R_LARCH_TLS_TPREL64", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_TPREL64)); + EXPECT_EQ("R_LARCH_IRELATIVE", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_IRELATIVE)); + + EXPECT_EQ("R_LARCH_MARK_LA", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_MARK_LA)); + EXPECT_EQ("R_LARCH_MARK_PCREL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_MARK_PCREL)); + EXPECT_EQ("R_LARCH_SOP_PUSH_PCREL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_PCREL)); + EXPECT_EQ("R_LARCH_SOP_PUSH_ABSOLUTE", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_ABSOLUTE)); + EXPECT_EQ("R_LARCH_SOP_PUSH_DUP", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_DUP)); + EXPECT_EQ("R_LARCH_SOP_PUSH_GPREL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_GPREL)); + EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_TPREL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_TPREL)); + EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_GOT", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_GOT)); + EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_GD", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_GD)); + EXPECT_EQ("R_LARCH_SOP_PUSH_PLT_PCREL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_PLT_PCREL)); + EXPECT_EQ("R_LARCH_SOP_ASSERT", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_ASSERT)); + EXPECT_EQ("R_LARCH_SOP_NOT", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_NOT)); + EXPECT_EQ("R_LARCH_SOP_SUB", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SUB)); + EXPECT_EQ("R_LARCH_SOP_SL", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SL)); + EXPECT_EQ("R_LARCH_SOP_SR", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SR)); + EXPECT_EQ("R_LARCH_SOP_ADD", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_ADD)); + EXPECT_EQ("R_LARCH_SOP_AND", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_AND)); + EXPECT_EQ("R_LARCH_SOP_IF_ELSE", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_IF_ELSE)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_5", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_5)); + EXPECT_EQ("R_LARCH_SOP_POP_32_U_10_12", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_U_10_12)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_12", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_12)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_16", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_16)); + EXPECT_EQ( + "R_LARCH_SOP_POP_32_S_10_16_S2", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_16_S2)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_5_20", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_5_20)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_0_5_10_16_S2", + getELFRelocationTypeName(EM_LOONGARCH, + R_LARCH_SOP_POP_32_S_0_5_10_16_S2)); + EXPECT_EQ("R_LARCH_SOP_POP_32_S_0_10_10_16_S2", + getELFRelocationTypeName(EM_LOONGARCH, + R_LARCH_SOP_POP_32_S_0_10_10_16_S2)); + EXPECT_EQ("R_LARCH_SOP_POP_32_U", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_U)); + EXPECT_EQ("R_LARCH_ADD8", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD8)); + EXPECT_EQ("R_LARCH_ADD16", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD16)); + EXPECT_EQ("R_LARCH_ADD24", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD24)); + EXPECT_EQ("R_LARCH_ADD32", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD32)); + EXPECT_EQ("R_LARCH_ADD64", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD64)); + EXPECT_EQ("R_LARCH_SUB8", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB8)); + EXPECT_EQ("R_LARCH_SUB16", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB16)); + EXPECT_EQ("R_LARCH_SUB24", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB24)); + EXPECT_EQ("R_LARCH_SUB32", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB32)); + EXPECT_EQ("R_LARCH_SUB64", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB64)); + EXPECT_EQ("R_LARCH_GNU_VTINHERIT", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GNU_VTINHERIT)); + EXPECT_EQ("R_LARCH_GNU_VTENTRY", + getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GNU_VTENTRY)); +} + TEST(ELFTest, getELFRelativeRelocationType) { EXPECT_EQ(ELF::R_VE_RELATIVE, getELFRelativeRelocationType(EM_VE)); }