Add relocation type R_X86_64_REX_GOTPCRELX
authorTamar Christina <tamar@zhox.com>
Sun, 5 Jun 2016 07:59:05 +0000 (09:59 +0200)
committerRaspbian forward porter <root@raspbian.org>
Fri, 30 Dec 2016 02:30:41 +0000 (02:30 +0000)
Summary:
Adding support for the `R_X86_64_REX_GOTPCRELX` relocation type.
This relocation is treated by the linker the same as the `R_X86_64_GOTPCRELX` type
`G + GOT + A - P` to generate relative offsets to the GOT.
The `REX` prefix has no influence in this stage.

This is based on https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf

Test Plan: ./validate

Reviewers: erikd, austin, bgamari, simonmar

Reviewed By: erikd

Subscribers: thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2303

GHC Trac Issues: #12147

Gbp-Pq: Name R_X86_64_REX_GOTPCRELX

rts/Linker.c

index 50f438afc2037bc65a94f35f02926bd425956faa..fd541ec08792c87c431dac63bfb6f90e4b6d700e 100644 (file)
@@ -5855,7 +5855,13 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
           *(Elf64_Sword *)P = (Elf64_Sword)value;
 #endif
           break;
-
+/* These two relocations were introduced in glibc 2.23 and binutils 2.26.
+    But in order to use them the system which compiles the bindist for GHC needs
+    to have glibc >= 2.23. So only use them if they're defined. */
+#if defined(R_X86_64_REX_GOTPCRELX) && defined(R_X86_64_GOTPCRELX)
+      case R_X86_64_REX_GOTPCRELX:
+      case R_X86_64_GOTPCRELX:
+#endif
       case R_X86_64_GOTPCREL:
       {
           StgInt64 gotAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)->addr;