[llvm] bb39a8a - [LoongArch] Define the LAELF v20230519 relocs

Weining Lu via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 20:16:37 PDT 2023


Author: WANG Xuerui
Date: 2023-06-07T11:16:05+08:00
New Revision: bb39a8aad12a4c93382e23a50004da6633156786

URL: https://github.com/llvm/llvm-project/commit/bb39a8aad12a4c93382e23a50004da6633156786
DIFF: https://github.com/llvm/llvm-project/commit/bb39a8aad12a4c93382e23a50004da6633156786.diff

LOG: [LoongArch] Define the LAELF v20230519 relocs

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.

Reviewed By: SixWeining, MaskRay

Differential Revision: https://reviews.llvm.org/D152184

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
    llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
    llvm/unittests/Object/ELFTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def b/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
index 67dbd020140b6..02bce3c717127 100644
--- a/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
+++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/LoongArch.def
@@ -103,3 +103,18 @@ ELF_RELOC(R_LARCH_TLS_GD_PC_HI20,   97)
 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)

diff  --git a/llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test b/llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
index c26fae7e83236..e32dc893fa798 100644
--- a/llvm/test/tools/llvm-readobj/ELF/reloc-types-loongarch64.test
+++ b/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 @@ Sections:
       - 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

diff  --git a/llvm/unittests/Object/ELFTest.cpp b/llvm/unittests/Object/ELFTest.cpp
index 24f65841c5f22..50b1df124a4a5 100644
--- a/llvm/unittests/Object/ELFTest.cpp
+++ b/llvm/unittests/Object/ELFTest.cpp
@@ -233,6 +233,24 @@ TEST(ELFTest, getELFRelocationTypeNameForLoongArch) {
             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) {


        


More information about the llvm-commits mailing list