Allocate bss section within proper range of other sections

Authored by watashi on Dec 28 2018, 10:47 PM.

Description

Allocate bss section within proper range of other sections

Summary:
This re-applies D5195: Add a RTS option -xp to load PIC object anywhere in address space and D5235: Fix T15729 and T3001-2 in master, they were reverted as part of diff
stack to unbreak i386. The proper fix is done in D5289: Add a RTS option -xp to load PIC object anywhere in address space.

Allocate bss section within proper range of other sections:

  • when +RTS -xp is passed, allocate it contiguously as we did for jump islands
  • when we mmap the code to lower 2Gb, we should allocate bss section there too

Test Plan:

  1. ./validate

with

DYNAMIC_GHC_PROGRAMS = NO
DYNAMIC_BY_DEFAULT = NO

TEST="T15729" make test passed in both linux (both i386 and x86_64) and macos.

Also test in a use case where we used to encouter error like:

ghc-iserv-prof: R_X86_64_PC32 relocation out of range: (noname) =
b90282ba

and now, everything works fine.

Reviewers: simonmar, bgamari, angerman, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: Trac #15729

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

Details