aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Roeder <tmroeder@google.com>2013-10-30 18:47:25 +0000
committerTom Roeder <tmroeder@google.com>2013-10-30 18:47:25 +0000
commit4ca9a2a0adf01ae1aaad2c7fa499501b58183991 (patch)
tree8e7def5375f343b1abd86bbc9cf52616920198af
parentf34c3ca3046378bdb7e49b7366bafca0e0bafb9a (diff)
downloadexternal_llvm-4ca9a2a0adf01ae1aaad2c7fa499501b58183991.zip
external_llvm-4ca9a2a0adf01ae1aaad2c7fa499501b58183991.tar.gz
external_llvm-4ca9a2a0adf01ae1aaad2c7fa499501b58183991.tar.bz2
This commit adds some (but not all) of the x86-64 relocations that are not
currently supported in the ELF object writer, along with a simple test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193709 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp6
-rw-r--r--test/MC/ELF/relocation.s16
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
index 6a4bdeb..3ddd865 100644
--- a/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
@@ -108,6 +108,12 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
case MCSymbolRefExpr::VK_None:
Type = ELF::R_X86_64_64;
break;
+ case MCSymbolRefExpr::VK_GOT:
+ Type = ELF::R_X86_64_GOT64;
+ break;
+ case MCSymbolRefExpr::VK_GOTOFF:
+ Type = ELF::R_X86_64_GOTOFF64;
+ break;
case MCSymbolRefExpr::VK_TPOFF:
Type = ELF::R_X86_64_TPOFF64;
break;
diff --git a/test/MC/ELF/relocation.s b/test/MC/ELF/relocation.s
index ba50c81..6823075 100644
--- a/test/MC/ELF/relocation.s
+++ b/test/MC/ELF/relocation.s
@@ -14,6 +14,8 @@ bar:
leaq foo@TPOFF(%rax), %rax # R_X86_64_TPOFF32
leaq foo@TLSLD(%rip), %rdi # R_X86_64_TLSLD
leaq foo@dtpoff(%rax), %rcx # R_X86_64_DTPOFF32
+ movabs foo@GOT, %rax # R_X86_64_GOT64
+ movabs foo@GOTOFF, %rax # R_X86_64_GOTOFF64
pushq $bar
movq foo(%rip), %rdx
leaq foo-bar(%r14),%r14
@@ -35,12 +37,14 @@ bar:
// CHECK-NEXT: 0x3B R_X86_64_TPOFF32 foo 0x0
// CHECK-NEXT: 0x42 R_X86_64_TLSLD foo 0xFFFFFFFFFFFFFFFC
// CHECK-NEXT: 0x49 R_X86_64_DTPOFF32 foo 0x0
-// CHECK-NEXT: 0x4E R_X86_64_32S .text 0x0
-// CHECK-NEXT: 0x55 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC
-// 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 baz 0x0
+// CHECK-NEXT: 0x4F R_X86_64_GOT64 foo 0x0
+// CHECK-NEXT: 0x59 R_X86_64_GOTOFF64 foo 0x0
+// CHECK-NEXT: 0x62 R_X86_64_32S .text 0x0
+// CHECK-NEXT: 0x69 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC
+// CHECK-NEXT: 0x70 R_X86_64_PC32 foo 0x70
+// CHECK-NEXT: 0x77 R_X86_64_32S .text 0x0
+// CHECK-NEXT: 0x7B R_X86_64_DTPOFF64 foo 0x0
+// CHECK-NEXT: 0x85 R_X86_64_TPOFF64 baz 0x0
// CHECK-NEXT: ]
// CHECK-NEXT: }