[llvm] r372447 - Support for 64-bit PC-relative relocations for X86_64

Artur Pilipenko via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 18:37:14 PDT 2019


Author: apilipenko
Date: Fri Sep 20 18:37:14 2019
New Revision: 372447

URL: http://llvm.org/viewvc/llvm-project?rev=372447&view=rev
Log:
Support for 64-bit PC-relative relocations for X86_64

ELF files generated for X86_64 targets may contain 64-bit PC-relative 
relocations. For instance, an exception handler table entry contains the start 
of exception-throwing frame relative to the start of exception handler. As these 
two labels belong to different sections, their difference and so the relocation 
is 64-bit.

An attempt to parse such file, i.e. in DWARFContext::create, results in "failed 
to compute relocation" error.

This fix adds support for such relocations to RelocationResolver.cpp.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D67779

Patch by Oleg Pliss (Oleg.Pliss at azul.com)

Modified:
    llvm/trunk/lib/Object/RelocationResolver.cpp

Modified: llvm/trunk/lib/Object/RelocationResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/RelocationResolver.cpp?rev=372447&r1=372446&r2=372447&view=diff
==============================================================================
--- llvm/trunk/lib/Object/RelocationResolver.cpp (original)
+++ llvm/trunk/lib/Object/RelocationResolver.cpp Fri Sep 20 18:37:14 2019
@@ -30,6 +30,7 @@ static bool supportsX86_64(uint64_t Type
   case ELF::R_X86_64_DTPOFF32:
   case ELF::R_X86_64_DTPOFF64:
   case ELF::R_X86_64_PC32:
+  case ELF::R_X86_64_PC64:
   case ELF::R_X86_64_32:
   case ELF::R_X86_64_32S:
     return true;
@@ -47,6 +48,7 @@ static uint64_t resolveX86_64(Relocation
   case ELF::R_X86_64_DTPOFF64:
     return S + getELFAddend(R);
   case ELF::R_X86_64_PC32:
+  case ELF::R_X86_64_PC64:
     return S + getELFAddend(R) - R.getOffset();
   case ELF::R_X86_64_32:
   case ELF::R_X86_64_32S:




More information about the llvm-commits mailing list