[PATCH] D35242: [ARM, ELF] Don't shift movt relocation offsets

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 14:07:42 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL307713: [ARM, ELF] Don't shift movt relocation offsets (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D35242?vs=105993&id=106097#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35242

Files:
  llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/trunk/test/MC/ARM/elf-movt.s


Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -392,7 +392,7 @@
   case FK_SecRel_4:
     return Value;
   case ARM::fixup_arm_movt_hi16:
-    if (!IsPCRel)
+    if (!IsPCRel && !STI->getTargetTriple().isOSBinFormatELF())
       Value >>= 16;
     LLVM_FALLTHROUGH;
   case ARM::fixup_arm_movw_lo16: {
@@ -404,7 +404,7 @@
     return Value;
   }
   case ARM::fixup_t2_movt_hi16:
-    if (!IsPCRel)
+    if (!IsPCRel && !STI->getTargetTriple().isOSBinFormatELF())
       Value >>= 16;
     LLVM_FALLTHROUGH;
   case ARM::fixup_t2_movw_lo16: {
Index: llvm/trunk/test/MC/ARM/elf-movt.s
===================================================================
--- llvm/trunk/test/MC/ARM/elf-movt.s
+++ llvm/trunk/test/MC/ARM/elf-movt.s
@@ -14,19 +14,31 @@
 	movw	r0, :lower16:GOT-(.LPC0_2+8)
 	movt	r0, :upper16:GOT-(.LPC0_2+8)
 .LPC0_2:
+	movw	r0, :lower16:extern_symbol+1234
+	movt	r0, :upper16:extern_symbol+1234
 @ ASM:          movw    r0, :lower16:(GOT-(.LPC0_2+8))
 @ ASM-NEXT:     movt    r0, :upper16:(GOT-(.LPC0_2+8))
+@ ASM:          movw    r0, :lower16:(extern_symbol+1234)
+@ ASM-NEXT:     movt    r0, :upper16:(extern_symbol+1234)
 
 @OBJ:      Disassembly of section .text:
 @OBJ-NEXT: barf:
 @OBJ-NEXT: 0:             f0 0f 0f e3     movw    r0, #65520
 @OBJ-NEXT: 00000000:         R_ARM_MOVW_PREL_NC   GOT
 @OBJ-NEXT: 4:             f4 0f 4f e3     movt    r0, #65524
 @OBJ-NEXT: 00000004:         R_ARM_MOVT_PREL      GOT
+ at OBJ-NEXT: 8:             d2 04 00 e3     movw    r0, #1234
+ at OBJ-NEXT: 00000008:         R_ARM_MOVW_ABS_NC    extern_symbol
+ at OBJ-NEXT: c:             d2 04 40 e3     movt    r0, #1234
+ at OBJ-NEXT: 0000000c:         R_ARM_MOVT_ABS       extern_symbol
 
 @THUMB:      Disassembly of section .text:
 @THUMB-NEXT: barf:
 @THUMB-NEXT: 0:             4f f6 f0 70     movw    r0, #65520
 @THUMB-NEXT: 00000000:         R_ARM_THM_MOVW_PREL_NC GOT
 @THUMB-NEXT: 4:             cf f6 f4 70     movt    r0, #65524
 @THUMB-NEXT: 00000004:         R_ARM_THM_MOVT_PREL    GOT
+ at THUMB-NEXT: 8:             40 f2 d2 40     movw    r0, #1234
+ at THUMB-NEXT: 00000008:         R_ARM_THM_MOVW_ABS_NC  extern_symbol
+ at THUMB-NEXT: c:             c0 f2 d2 40     movt    r0, #1234
+ at THUMB-NEXT: 0000000c:         R_ARM_THM_MOVT_ABS     extern_symbol


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35242.106097.patch
Type: text/x-patch
Size: 2471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170711/ca157d4f/attachment.bin>


More information about the llvm-commits mailing list