Skip to content
  • Zejun Wu's avatar
    Add a RTS option -xp to load PIC object anywhere in address space · 5403a863
    Zejun Wu authored and Ben Gamari's avatar Ben Gamari committed
    Add a RTS option -xp to load PIC object anywhere in address space. We do
    this by relaxing the requirement of <0x80000000 result of
    `mmapForLinker` and implying USE_CONTIGUOUS_MMAP.
    
    We also need to change calls to `ocInit` and `ocGetNames` to avoid
    dangling pointers when the address of `oc->image` is changed by
    `ocAllocateSymbolExtra`.
    
    Test Plan:
    ```
    $ uname -a
    Linux localhost 4.18.8-arch1-1-ARCH #1 SMP PREEMPT Sat Sep 15 20:34:48
    UTC 2018 x86_64 GNU/Linux
    $ cat mk/build.mk
    DYNAMIC_GHC_PROGRAMS = NO
    DYNAMIC_BY_DEFAULT = NO
    
    GhcRTSWays += thr_debug
    EXTRA_HC_OPTS += -debug
    WAY_p_HC_OPTS += -fPIC -fexternal-dynamic-refs
    $ inplace/bin/ghc-stage2 --interactive -prof +RTS -xp
    GHCi, version 8.7.20180928: http://www.haskell.org/ghc/  :? for help
    ghc-stage2: R_X86_64_32 relocation out of range:
    ghczmprim_GHCziTypes_ZMZN_closure = 7f690bffab59
    Recompile
    /data/users/watashi/ghc/libraries/ghc-prim/dist-install/build/HSghc-prim
    -0.5.3.o with -fPIC -fex...
    5403a863