diff options
author | Zejun Wu <watashi@fb.com> | 2018-12-28 20:47:33 -0800 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-01-30 10:06:32 -0500 |
commit | 740534d43cf9f1635c60f6311b7e0d89af962617 (patch) | |
tree | eb9c9d3b9fecf99177e160d6ac7c94dff74417f0 /rts/Linker.c | |
parent | e29b1ee72d77d5a06ac949f9dcc80108243a25c0 (diff) | |
download | haskell-740534d43cf9f1635c60f6311b7e0d89af962617.tar.gz |
Allocate bss section within proper range of other sections
Summary:
This re-applies {D5195} and {D5235}, they were reverted as part of diff
stack to unbreak i386. The proper fix is done in {D5289}.
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`
2.
with
```
DYNAMIC_GHC_PROGRAMS = NO
DYNAMIC_BY_DEFAULT = NO
```
`TEST="T15729" make test` passed in both linux (both i386 and x86_64) and macos.
3.
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: #15729
Differential Revision: https://phabricator.haskell.org/D5290
Diffstat (limited to 'rts/Linker.c')
-rw-r--r-- | rts/Linker.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index 296b6441ea..b6f1de9be6 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1286,6 +1286,8 @@ mkOc( pathchar *path, char *image, int imageSize, #if defined(NEED_SYMBOL_EXTRAS) oc->symbol_extras = NULL; #endif + oc->bssBegin = NULL; + oc->bssEnd = NULL; oc->imageMapped = mapped; oc->misalignment = misalignment; @@ -1499,35 +1501,35 @@ HsInt loadOc (ObjectCode* oc) } /* Note [loadOc orderings] - The order of `ocAllocateSymbolExtras` and `ocGetNames` matters. For MachO + The order of `ocAllocateExtras` and `ocGetNames` matters. For MachO and ELF, `ocInit` and `ocGetNames` initialize a bunch of pointers based - on the offset to `oc->image`, but `ocAllocateSymbolExtras` may relocate + on the offset to `oc->image`, but `ocAllocateExtras` may relocate the address of `oc->image` and invalidate those pointers. So we must - compute or recompute those pointers after `ocAllocateSymbolExtras`. + compute or recompute those pointers after `ocAllocateExtras`. On Windows, when we have an import library we (for now, as we don't honor the lazy loading semantics of the library and instead GHCi is already lazy) don't use the library after ocGetNames as it just populates the - symbol table. Allocating space for jump tables in ocAllocateSymbolExtras + symbol table. Allocating space for jump tables in ocAllocateExtras would just be a waste then as we'll be stopping further processing of the library in the next few steps. If necessary, the actual allocation - happens in `ocGetNames_PEi386` and `ocAllocateSymbolExtras_PEi386` simply + happens in `ocGetNames_PEi386` and `ocAllocateExtras_PEi386` simply set the correct pointers. */ #if defined(NEED_SYMBOL_EXTRAS) # if defined(OBJFORMAT_MACHO) - r = ocAllocateSymbolExtras_MachO ( oc ); + r = ocAllocateExtras_MachO ( oc ); if (!r) { IF_DEBUG(linker, - debugBelch("loadOc: ocAllocateSymbolExtras_MachO failed\n")); + debugBelch("loadOc: ocAllocateExtras_MachO failed\n")); return r; } # elif defined(OBJFORMAT_ELF) - r = ocAllocateSymbolExtras_ELF ( oc ); + r = ocAllocateExtras_ELF ( oc ); if (!r) { IF_DEBUG(linker, - debugBelch("loadOc: ocAllocateSymbolExtras_ELF failed\n")); + debugBelch("loadOc: ocAllocateExtras_ELF failed\n")); return r; } # endif @@ -1550,7 +1552,7 @@ HsInt loadOc (ObjectCode* oc) #if defined(NEED_SYMBOL_EXTRAS) # if defined(OBJFORMAT_PEi386) - ocAllocateSymbolExtras_PEi386 ( oc ); + ocAllocateExtras_PEi386 ( oc ); # endif #endif |