Allocate bss section within proper range of other sections

Authored by watashi on Oct 9 2018, 7:22 PM.



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

This depends on D5195: Add a RTS option -xp to load PIC object anywhere in address space

Test Plan
  1. ./validate



TEST="T15729" make test passed in both linux 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.

watashi created this revision.Oct 9 2018, 7:22 PM

This looks OK.

One thing I just realised: we're allocating memory for the PLT/GOT/BSS directly after the mapped file, but the file might contain large amounts of symbol table data and debug sections, which might mean that the PLT/GOT/BSS are a long way from the text section. I expect the small memory model only guarantees that text+data < 2GB, not symbol tables and debug info. Really we ought to be double-mapping the image like we do in the non-PIC mode, but with only one mapping (not one per section).

simonmar accepted this revision.Oct 10 2018, 2:36 PM
This revision is now accepted and ready to land.Oct 10 2018, 2:36 PM
This revision was automatically updated to reflect the committed changes.