[lld] r255453 - [ELF][MIPS] Ignore R_MIPS_JALR relocation for now

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 12 22:49:15 PST 2015


Author: atanasyan
Date: Sun Dec 13 00:49:14 2015
New Revision: 255453

URL: http://llvm.org/viewvc/llvm-project?rev=255453&view=rev
Log:
[ELF][MIPS] Ignore R_MIPS_JALR relocation for now

The `R_MIPS_JALR` is a relocation generated by gcc and gas. This
relocation points to the `jalr` instruction which might be optimized and
converted to the `b` instruction under some conditions.

Now we just ignore this relocation and keep instructions unchanged.

Added:
    lld/trunk/test/ELF/mips-jalr.test
Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=255453&r1=255452&r2=255453&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sun Dec 13 00:49:14 2015
@@ -1318,6 +1318,9 @@ void MipsTargetInfo<ELFT>::relocateOne(u
     }
     break;
   }
+  case R_MIPS_JALR:
+    // Ignore this optimization relocation for now
+    break;
   case R_MIPS_LO16: {
     uint32_t Instr = read32<E>(Loc);
     int64_t AHL = SignExtend64<16>(Instr & 0xffff);

Added: lld/trunk/test/ELF/mips-jalr.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-jalr.test?rev=255453&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-jalr.test (added)
+++ lld/trunk/test/ELF/mips-jalr.test Sun Dec 13 00:49:14 2015
@@ -0,0 +1,47 @@
+# Check that lld ignores R_MIPS_JALR relocation for now.
+
+# RUN: yaml2obj -format elf %s -o %t.o
+# RUN: ld.lld %t.o -o %t.so -shared
+# RUN: llvm-objdump -d %t.so | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: 10000:   09 f8 20 03   jalr    $25
+
+FileHeader:
+  Class:    ELFCLASS32
+  Data:     ELFDATA2LSB
+  Type:     ET_REL
+  Machine:  EM_MIPS
+  Flags:    [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
+
+Sections:
+  - Name:          .text
+    Type:          SHT_PROGBITS
+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:  16
+    Content:       "09f82003"
+#                   ^-- jalr T1
+
+  - Name:          .rel.text
+    Type:          SHT_REL
+    Link:          .symtab
+    Info:          .text
+    Relocations:
+      - Offset:  0
+        Symbol:  T1
+        Type:    R_MIPS_JALR
+
+Symbols:
+  Local:
+    - Name:     T1
+      Type:     STT_FUNC
+      Section:  .text
+      Value:    0
+      Size:     4
+  Global:
+    - Name:     __start
+      Type:     STT_FUNC
+      Section:  .text
+      Value:    0
+      Size:     4




More information about the llvm-commits mailing list