[PATCH] D67779: Support for 64-bit PC-relative relocations for X86_64

Oleg Pliss via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 17:21:40 PDT 2019


OlegPliss created this revision.
OlegPliss added reviewers: MaskRay, yonghong-song, apilipenko.
Herald added subscribers: llvm-commits, aprantl.
Herald added a project: LLVM.

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.

The proposed simple and straightforward fix adds support for such relocations to RelocationResolver.cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D67779

Files:
  lib/Object/RelocationResolver.cpp


Index: lib/Object/RelocationResolver.cpp
===================================================================
--- lib/Object/RelocationResolver.cpp
+++ lib/Object/RelocationResolver.cpp
@@ -30,6 +30,7 @@
   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 @@
   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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67779.220923.patch
Type: text/x-patch
Size: 635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190920/e6354f27/attachment-0001.bin>


More information about the llvm-commits mailing list