powerpc: add basic support for PLT relocations (#10402)
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@debian.org>
Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Reviewed By: bgamari, austin

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

GHC Trac Issues: #10402

snoyberg/ghc,vTurbine/ghc,da-x/ghc,mcschroeder/ghc,vTurbine/ghc,olsner/ghc,vTurbine/ghc,shlevy/ghc,vikraman/ghc,sdiehl/ghc,ghc-android/ghc,TomMD/ghc,GaloisInc/halvm-ghc,olsner/ghc,ml9951/ghc,acowley/ghc,GaloisInc/halvm-ghc,AlexanderPankiv/ghc,urbanslug/ghc,mcschroeder/ghc,mettekou/ghc,da-x/ghc,sgillespie/ghc,nkaretnikov/ghc,siddhanathan/ghc,shlevy/ghc,ezyang/ghc,sdiehl/ghc,elieux/ghc,mettekou/ghc,vikraman/ghc,AlexanderPankiv/ghc,tjakway/ghcjvm,mfine/ghc,tjakway/ghcjvm,ghc-android/ghc,siddhanathan/ghc,sgillespie/ghc,acowley/ghc,mettekou/ghc,da-x/ghc,ml9951/ghc,wxwxwwxxx/ghc,wxwxwwxxx/ghc,mfine/ghc,TomMD/ghc,nkaretnikov/ghc,sgillespie/ghc,urbanslug/ghc,anton-dessiatov/ghc,urbanslug/ghc,vTurbine/ghc,anton-dessiatov/ghc,gridaphobe/ghc,olsner/ghc,ezyang/ghc,GaloisInc/halvm-ghc,acowley/ghc,elieux/ghc,elieux/ghc,ezyang/ghc,mcschroeder/ghc,elieux/ghc,mfine/ghc,snoyberg/ghc,nushio3/ghc,mettekou/ghc,tjakway/ghcjvm,sdiehl/ghc,vikraman/ghc,anton-dessiatov/ghc,ghc-android/ghc,mfine/ghc,AlexanderPankiv/ghc,elieux/ghc,oldmanmike/ghc,sgillespie/ghc,acowley/ghc,vikraman/ghc,tjakway/ghcjvm,mcschroeder/ghc,olsner/ghc,gridaphobe/ghc,GaloisInc/halvm-ghc,mcschroeder/ghc,nushio3/ghc,acowley/ghc,sdiehl/ghc,ghc-android/ghc,siddhanathan/ghc,gridaphobe/ghc,gridaphobe/ghc,TomMD/ghc,wxwxwwxxx/ghc,oldmanmike/ghc,acowley/ghc,ml9951/ghc,GaloisInc/halvm-ghc,ezyang/ghc,snoyberg/ghc,shlevy/ghc,nushio3/ghc,AlexanderPankiv/ghc,wxwxwwxxx/ghc,nkaretnikov/ghc,ml9951/ghc,da-x/ghc,tjakway/ghcjvm,da-x/ghc,tjakway/ghcjvm,elieux/ghc,anton-dessiatov/ghc,olsner/ghc,snoyberg/ghc,ml9951/ghc,nkaretnikov/ghc,oldmanmike/ghc,anton-dessiatov/ghc,nushio3/ghc,sdiehl/ghc,GaloisInc/halvm-ghc,ghc-android/ghc,sgillespie/ghc,AlexanderPankiv/ghc,snoyberg/ghc,da-x/ghc,oldmanmike/ghc,shlevy/ghc,vikraman/ghc,snoyberg/ghc,mettekou/ghc,oldmanmike/ghc,vTurbine/ghc,ml9951/ghc,ezyang/ghc,acowley/ghc,oldmanmike/ghc,gridaphobe/ghc,mcschroeder/ghc,sdiehl/ghc,urbanslug/ghc,shlevy/ghc,vikraman/ghc,anton-dessiatov/ghc,vTurbine/ghc,urbanslug/ghc,sgillespie/ghc,TomMD/ghc,nkaretnikov/ghc,AlexanderPankiv/ghc,gridaphobe/ghc,gridaphobe/ghc,vikraman/ghc,mfine/ghc,shlevy/ghc,da-x/ghc,sgillespie/ghc,nushio3/ghc,nushio3/ghc,mcschroeder/ghc,vTurbine/ghc,tjakway/ghcjvm,siddhanathan/ghc,siddhanathan/ghc,nushio3/ghc,sdiehl/ghc,mfine/ghc,AlexanderPankiv/ghc,GaloisInc/halvm-ghc,mettekou/ghc,oldmanmike/ghc,anton-dessiatov/ghc,mfine/ghc,TomMD/ghc,urbanslug/ghc,shlevy/ghc,nkaretnikov/ghc,wxwxwwxxx/ghc,siddhanathan/ghc,nkaretnikov/ghc,wxwxwwxxx/ghc,TomMD/ghc,mettekou/ghc,TomMD/ghc,ezyang/ghc,urbanslug/ghc,olsner/ghc,siddhanathan/ghc,ml9951/ghc,olsner/ghc,ezyang/ghc,wxwxwwxxx/ghc,elieux/ghc,ml9951/ghc,ghc-android/ghc,snoyberg/ghc,ghc-android/ghc