[PATCH] X86: Use R_X86_64_TPOFF64 for FK_Data_8

David Majnemer david.majnemer at gmail.com
Wed Sep 18 14:32:46 PDT 2013


Hi dblaikie, nrieck, rafael,

LLVM would crash when trying to come up with a relocation type for
assembly like:
movabsq $V at TPOFF, %rax

Instead, we say the relocation type is R_X86_64_TPOFF64.

Fixes PR17274.

http://llvm-reviews.chandlerc.com/D1717

Files:
  lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
  test/MC/ELF/relocation.s

Index: lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
===================================================================
--- lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -108,6 +108,9 @@
         case MCSymbolRefExpr::VK_None:
           Type = ELF::R_X86_64_64;
           break;
+        case MCSymbolRefExpr::VK_TPOFF:
+          Type = ELF::R_X86_64_TPOFF64;
+          break;
         case MCSymbolRefExpr::VK_DTPOFF:
           Type = ELF::R_X86_64_DTPOFF64;
           break;
Index: test/MC/ELF/relocation.s
===================================================================
--- test/MC/ELF/relocation.s
+++ test/MC/ELF/relocation.s
@@ -19,6 +19,7 @@
         leaq    foo-bar(%r14),%r14
         addq	$bar,%rax         # R_X86_64_32S
 	.quad	foo at DTPOFF
+        movabsq	$bar at TPOFF, %rax
 
 // CHECK:        Section {
 // CHECK:          Name: .rela.text
@@ -39,6 +40,7 @@
 // CHECK-NEXT:       0x5C R_X86_64_PC32     foo 0x5C
 // CHECK-NEXT:       0x63 R_X86_64_32S      .text 0x0
 // CHECK-NEXT:       0x67 R_X86_64_DTPOFF64 foo 0x0
+// CHECK-NEXT:       0x71 R_X86_64_TPOFF64  .text
 // CHECK-NEXT:     ]
 // CHECK-NEXT:   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1717.1.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130918/47fc9b21/attachment.bin>


More information about the llvm-commits mailing list