[commit: ghc] ghc-7.10: powerpc: add basic support for PLT relocations (#10402) (18e0e95)
git at git.haskell.org
git at git.haskell.org
Tue Jun 23 12:42:36 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/18e0e95fc492a85fac275f600bfd4934c5de45b5/ghc
>---------------------------------------------------------------
commit 18e0e95fc492a85fac275f600bfd4934c5de45b5
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date: Tue Jun 23 07:39:34 2015 -0500
powerpc: add basic support for PLT relocations (#10402)
Commit a93ab43ab5f40cadbedea2f6342b93c245e91434
enabled support for proper PIC relocations from
assembler.
Commit adds support for relocations of type:
R_PPC_REL16_HI
R_PPC_REL16_HA
R_PPC_REL16_LO
R_PPC_PLTREL24
They are used only when GHC is built in
DYNAMIC_GHC_PROGRAMS = NO
mode.
Verified by running the following test:
// cat a.c
#include <stdio.h>
void ffi_a_hello (int i) {
fprintf (stderr, "WEEEEEEEE: i=%d\n", i);
}
-- cat A.hs
{-# LANGUAGE ForeignFunctionInterface #-}
module A where
import Foreign.C
foreign import ccall "ffi_a_hello" a :: CInt -> IO ()
# ghc -fPIC -c a.c -fforce-recomp
# ghc -fPIC -c A.hs -fforce-recomp
# ghc --interactive ./a.o A
...
*A> a 42
WEEEEEEEE: i=42
See gory details in Trac #10402.
Signed-off-by: Colin Watson <cjwatson at debian.org>
Signed-off-by: Sergei Trofimovich <siarheit at google.com>
Reviewed By: bgamari, austin
Differential Revision: https://phabricator.haskell.org/D996
GHC Trac Issues: #10402
(cherry picked from commit c0847967caf51ea4ca88d0ffc25fe1bd99dcabed)
>---------------------------------------------------------------
18e0e95fc492a85fac275f600bfd4934c5de45b5
rts/Linker.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/rts/Linker.c b/rts/Linker.c
index 5b30b84..13e222b 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -5956,6 +5956,9 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
*(Elf32_Word *) P = value - P;
break;
+ case R_PPC_PLTREL24:
+ value -= 0x8000; /* See Note [.LCTOC1 in PPC PIC code] */
+ /* fallthrough */
case R_PPC_REL24:
delta = value - P;
@@ -5976,6 +5979,18 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
*(Elf_Word *) P = (*(Elf_Word *) P & 0xfc000003)
| (delta & 0x3fffffc);
break;
+
+ case R_PPC_REL16_LO:
+ *(Elf32_Half*) P = value - P;
+ break;
+
+ case R_PPC_REL16_HI:
+ *(Elf32_Half*) P = (value - P) >> 16;
+ break;
+
+ case R_PPC_REL16_HA:
+ *(Elf32_Half*) P = (value + 0x8000 - P) >> 16;
+ break;
# endif
#if x86_64_HOST_ARCH
More information about the ghc-commits
mailing list