[PATCH] D17809: [mips] Extend MipsAsmParser class to handle expressions in the %tprel / %dtprel relocations

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 07:39:27 PST 2016


atanasyan updated this revision to Diff 49739.
atanasyan added a comment.

Do not right shift addend for DTPREL_HI and TPREL_HI relocations to mimics GAS behavior and LD expectations.


Repository:
  rL LLVM

http://reviews.llvm.org/D17809

Files:
  lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  test/MC/Mips/tprel-hi-lo-expr.s

Index: test/MC/Mips/tprel-hi-lo-expr.s
===================================================================
--- /dev/null
+++ test/MC/Mips/tprel-hi-lo-expr.s
@@ -0,0 +1,25 @@
+# Check that llvm-mc accepts arithmetic expression as an argument
+# of the %tprel_hi, %tprel_lo relocations.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s \
+# RUN:   | llvm-objdump -d -r - | FileCheck %s
+
+  .text
+foo:
+  lui     $3,%tprel_hi($loc0+0x7ffc)
+# CHECK: 0:       3c 03 7f fc     lui   $3, 32764
+# CHECK:                  00000000:  R_MIPS_TLS_TPREL_HI16    $loc0
+  addiu   $3,$3,%tprel_lo($loc0+0x7ffc)
+# CHECK: 4:       24 63 7f fc     addiu $3, $3, 32764
+# CHECK:                  00000004:  R_MIPS_TLS_TPREL_LO16    $loc0
+  lui     $3,%dtprel_hi($loc0+0x7ffc)
+# CHECK: 8:       3c 03 7f fc     lui   $3, 32764
+# CHECK:                  00000008:  R_MIPS_TLS_DTPREL_HI16   $loc0
+  addiu   $3,$3,%dtprel_lo($loc0+0x7ffc)
+# CHECK: c:       24 63 7f fc     addiu $3, $3, 32764
+# CHECK:                  0000000c:  R_MIPS_TLS_DTPREL_LO16   $loc0
+
+  .section .tdata,"awT",%progbits
+$loc0:
+  .word 0
+  .space 0x8000
Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp
===================================================================
--- lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -4095,6 +4095,15 @@
       // Get the 4th 16-bits.
       Val = ((MCE->getValue() + 0x800080008000LL) >> 48) & 0xffff;
       break;
+    case MCSymbolRefExpr::VK_Mips_DTPREL_HI:
+    case MCSymbolRefExpr::VK_Mips_TPREL_HI:
+    case MCSymbolRefExpr::VK_Mips_DTPREL_LO:
+    case MCSymbolRefExpr::VK_Mips_TPREL_LO:
+      // Get the 16-bits for both 'hi' and 'lo' relocations.
+      // TPREL and DTPREL relocations do not use combined addend calculated
+      // using both HI and LO parts like %hi and %lo do.
+      Val = MCE->getValue() & 0xffff;
+      break;
     default:
       report_fatal_error("unsupported reloc value");
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17809.49739.patch
Type: text/x-patch
Size: 1993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160303/26f7d878/attachment.bin>


More information about the llvm-commits mailing list