[PATCH] D152184: [LoongArch] Define the LAELF v20230519 relocs
WÁNG Xuěruì via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 11:41:22 PDT 2023
xen0n created this revision.
xen0n added reviewers: SixWeining, wangleiat, MaskRay, xry111.
Herald added a subscriber: emaste.
Herald added a reviewer: jhenderson.
Herald added a project: All.
xen0n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The LoongArch ELF psABI document has changed location and versioning
scheme; this revision is v2.10 in the old scheme. Notably this revision
brings initial capability of linker relaxation to LoongArch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152184
Files:
llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
llvm/unittests/Object/ELFTest.cpp
Index: llvm/unittests/Object/ELFTest.cpp
===================================================================
--- llvm/unittests/Object/ELFTest.cpp
+++ llvm/unittests/Object/ELFTest.cpp
@@ -233,6 +233,24 @@
getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_32_PCREL));
EXPECT_EQ("R_LARCH_RELAX",
getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_RELAX));
+ EXPECT_EQ("R_LARCH_DELETE",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_DELETE));
+ EXPECT_EQ("R_LARCH_ALIGN",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ALIGN));
+ EXPECT_EQ("R_LARCH_PCREL20_S2",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCREL20_S2));
+ EXPECT_EQ("R_LARCH_CFA",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_CFA));
+ EXPECT_EQ("R_LARCH_ADD6",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD6));
+ EXPECT_EQ("R_LARCH_SUB6",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB6));
+ EXPECT_EQ("R_LARCH_ADD_ULEB128",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD_ULEB128));
+ EXPECT_EQ("R_LARCH_SUB_ULEB128",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB_ULEB128));
+ EXPECT_EQ("R_LARCH_64_PCREL",
+ getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_64_PCREL));
}
TEST(ELFTest, getELFRelativeRelocationType) {
Index: llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
+++ llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
@@ -93,6 +93,15 @@
# CHECK: Type: R_LARCH_TLS_GD_HI20 (98)
# CHECK: Type: R_LARCH_32_PCREL (99)
# CHECK: Type: R_LARCH_RELAX (100)
+# CHECK: Type: R_LARCH_DELETE (101)
+# CHECK: Type: R_LARCH_ALIGN (102)
+# CHECK: Type: R_LARCH_PCREL20_S2 (103)
+# CHECK: Type: R_LARCH_CFA (104)
+# CHECK: Type: R_LARCH_ADD6 (105)
+# CHECK: Type: R_LARCH_SUB6 (106)
+# CHECK: Type: R_LARCH_ADD_ULEB128 (107)
+# CHECK: Type: R_LARCH_SUB_ULEB128 (108)
+# CHECK: Type: R_LARCH_64_PCREL (109)
--- !ELF
FileHeader:
@@ -193,3 +202,12 @@
- Type: R_LARCH_TLS_GD_HI20
- Type: R_LARCH_32_PCREL
- Type: R_LARCH_RELAX
+ - Type: R_LARCH_DELETE
+ - Type: R_LARCH_ALIGN
+ - Type: R_LARCH_PCREL20_S2
+ - Type: R_LARCH_CFA
+ - Type: R_LARCH_ADD6
+ - Type: R_LARCH_SUB6
+ - Type: R_LARCH_ADD_ULEB128
+ - Type: R_LARCH_SUB_ULEB128
+ - Type: R_LARCH_64_PCREL
Index: llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
===================================================================
--- llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
+++ llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
@@ -103,3 +103,18 @@
ELF_RELOC(R_LARCH_TLS_GD_HI20, 98)
ELF_RELOC(R_LARCH_32_PCREL, 99)
ELF_RELOC(R_LARCH_RELAX, 100)
+
+// Relocs added in ELF for the LoongArch™ Architecture v20230519, part of the
+// v2.10 LoongArch ABI specs.
+//
+// Spec addition: https://github.com/loongson/la-abi-specs/pull/1
+// Binutils commit 57a930e3bfe4b2c7fd6463ed39311e1938513138
+ELF_RELOC(R_LARCH_DELETE, 101)
+ELF_RELOC(R_LARCH_ALIGN, 102)
+ELF_RELOC(R_LARCH_PCREL20_S2, 103)
+ELF_RELOC(R_LARCH_CFA, 104)
+ELF_RELOC(R_LARCH_ADD6, 105)
+ELF_RELOC(R_LARCH_SUB6, 106)
+ELF_RELOC(R_LARCH_ADD_ULEB128, 107)
+ELF_RELOC(R_LARCH_SUB_ULEB128, 108)
+ELF_RELOC(R_LARCH_64_PCREL, 109)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152184.528533.patch
Type: text/x-patch
Size: 3490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230605/bee2d8b5/attachment.bin>
More information about the llvm-commits
mailing list