diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index d6502597b58..6a2a6e53da5 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -588,6 +588,9 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm, case MCSymbolRefExpr::VK_PLT: Type = ELF::R_X86_64_PLT32; break; + case llvm::MCSymbolRefExpr::VK_GOTPCREL: + Type = ELF::R_X86_64_GOTPCREL; + break; default: llvm_unreachable("Unimplemented"); } diff --git a/test/MC/ELF/got.s b/test/MC/ELF/got.s index c44245d078b..47b0285a99d 100644 --- a/test/MC/ELF/got.s +++ b/test/MC/ELF/got.s @@ -2,7 +2,8 @@ // Test that this produces a R_X86_64_GOT32. - movl foo@GOT, %eax + movl foo@GOT, %eax + movl foo@GOTPCREL(%rip), %eax // CHECK: ('_relocations', [ // CHECK-NEXT: # Relocation 0 @@ -11,4 +12,10 @@ // CHECK-NEXT: ('r_type', 3) // CHECK-NEXT: ('r_addend', // CHECK-NEXT: ), +// CHECK-NEXT: # Relocation 1 +// CHECK-NEXT: (('r_offset', +// CHECK-NEXT: ('r_sym', +// CHECK-NEXT: ('r_type', 9) +// CHECK-NEXT: ('r_addend', +// CHECK-NEXT: ), // CHECK-NEXT: ])