summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-10-27 10:52:25 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-06 03:46:44 -0500
commit2cb879092c0c946f5313216fc9ce4b93954c2f74 (patch)
treedfe782a367219dbf96172b451fa3cfa7c7c1388c /rts/Linker.c
parentc85f4928d4dbb2eb2cf906d08bfe7620d6f04ca5 (diff)
downloadhaskell-2cb879092c0c946f5313216fc9ce4b93954c2f74.tar.gz
[AArch64] Aarch64 Always PIC
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 2d54c29196..036c7937a4 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1022,42 +1022,6 @@ resolveSymbolAddr (pathchar* buffer, int size,
}
#if RTS_LINKER_USE_MMAP
-
-/* -----------------------------------------------------------------------------
- Occationally we depend on mmap'd region being close to already mmap'd regions.
-
- Our static in-memory linker may be restricted by the architectures relocation
- range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably
- get memory for the linker close to existing mappings. mmap on it's own is
- free to return any memory location, independent of what the preferred
- location argument indicates.
-
- For example mmap (via qemu) might give you addresses all over the available
- memory range if the requested location is already occupied.
-
- mmap_next will do a linear search from the start page upwards to find a
- suitable location that is as close as possible to the locations (proivded
- via the first argument).
- -------------------------------------------------------------------------- */
-
-void*
-mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) {
- if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset);
- // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the
- // address.
- size_t pageSize = getPageSize();
- for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) {
- void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize));
- void *mem = mmap(target, length, prot, flags, fd, offset);
- if(mem == NULL) return mem;
- if(mem == target) return mem;
- munmap(mem, length);
- IF_DEBUG(linker && (i % 1024 == 0),
- debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target));
- }
- return NULL;
-}
-
//
// Returns NULL on failure.
//
@@ -1089,8 +1053,8 @@ mmap_again:
debugBelch("mmapForLinker: \tflags %#0x\n",
MAP_PRIVATE | tryMap32Bit | fixed | flags));
- result = mmap_next(map_addr, size, prot,
- MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset);
+ result = mmap(map_addr, size, prot,
+ MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset);
if (result == MAP_FAILED) {
sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr);