[lld] r317778 - [MIPS] Setup less-significant bit in a symbol value in microMIPS thunks

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 02:42:22 PST 2017


Author: atanasyan
Date: Thu Nov  9 02:42:22 2017
New Revision: 317778

URL: http://llvm.org/viewvc/llvm-project?rev=317778&view=rev
Log:
[MIPS] Setup less-significant bit in a symbol value in microMIPS thunks

The less-significant bit signals about microMIPS code for jump/branch instructions.

Modified:
    lld/trunk/ELF/Thunks.cpp
    lld/trunk/test/ELF/mips-micro-thunks.s

Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=317778&r1=317777&r2=317778&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Thu Nov  9 02:42:22 2017
@@ -258,7 +258,7 @@ InputSection *MipsThunk::getTargetInputS
 // Write microMIPS R2-R5 LA25 thunk code
 // to call PIC function from the non-PIC one.
 void MicroMipsThunk::writeTo(uint8_t *Buf, ThunkSection &) const {
-  uint64_t S = Destination.getVA();
+  uint64_t S = Destination.getVA() | 1;
   write16(Buf, 0x41b9, Config->Endianness);       // lui   $25, %hi(func)
   write16(Buf + 4, 0xd400, Config->Endianness);   // j     func
   write16(Buf + 8, 0x3339, Config->Endianness);   // addiu $25, $25, %lo(func)
@@ -283,7 +283,7 @@ InputSection *MicroMipsThunk::getTargetI
 // Write microMIPS R6 LA25 thunk code
 // to call PIC function from the non-PIC one.
 void MicroMipsR6Thunk::writeTo(uint8_t *Buf, ThunkSection &) const {
-  uint64_t S = Destination.getVA();
+  uint64_t S = Destination.getVA() | 1;
   uint64_t P = ThunkSym->getVA();
   write16(Buf, 0x1320, Config->Endianness);       // lui   $25, %hi(func)
   write16(Buf + 4, 0x3339, Config->Endianness);   // addiu $25, $25, %lo(func)

Modified: lld/trunk/test/ELF/mips-micro-thunks.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-micro-thunks.s?rev=317778&r1=317777&r2=317778&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-micro-thunks.s (original)
+++ lld/trunk/test/ELF/mips-micro-thunks.s Thu Nov  9 02:42:22 2017
@@ -27,7 +27,7 @@
 # EB: __microLA25Thunk_foo:
 # EB-NEXT:    20008:       41 b9 00 02     lui     $25, 2
 # EB-NEXT:    2000c:       d4 01 00 10     j       131104
-# EB-NEXT:    20010:       33 39 00 20     addiu   $25, $25, 32
+# EB-NEXT:    20010:       33 39 00 21     addiu   $25, $25, 33
 # EB-NEXT:    20014:       0c 00           nop
 
 # EL: __start:
@@ -37,7 +37,7 @@
 # EL: __microLA25Thunk_foo:
 # EL-NEXT:    20008:       b9 41 02 00     lui     $25, 2
 # EL-NEXT:    2000c:       01 d4 10 00     j       131104
-# EL-NEXT:    20010:       39 33 20 00     addiu   $25, $25, 32
+# EL-NEXT:    20010:       39 33 21 00     addiu   $25, $25, 33
 # EL-NEXT:    20014:       00 0c           nop
 
   .text




More information about the llvm-commits mailing list