From 9290de3a99f0d8a74f4364768620e3ee099cf6e1 Mon Sep 17 00:00:00 2001 From: Tom Roeder Date: Wed, 30 Oct 2013 18:47:25 +0000 Subject: [PATCH] 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. llvm-svn: 193709 --- .../X86/MCTargetDesc/X86ELFObjectWriter.cpp | 6 ++++++ test/MC/ELF/relocation.s | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp index 6a4bdeb133b..3ddd86599eb 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 ba50c8182fb..682307501d6 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: }