From dff1cb3d9c111808fec60190747272b973547c52 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 14 May 2020 08:14:44 +0800 Subject: [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. --- rts/LinkerInternals.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rts/LinkerInternals.h') diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h index cf0cd35167..1f63f0c485 100644 --- a/rts/LinkerInternals.h +++ b/rts/LinkerInternals.h @@ -14,6 +14,7 @@ #if RTS_LINKER_USE_MMAP #include +void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); @@ -293,7 +294,7 @@ void exitLinker( void ); void freeObjectCode (ObjectCode *oc); SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo); -void *mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset); +void *mmapForLinker (size_t bytes, uint32_t prot, uint32_t flags, int fd, int offset); void mmapForLinkerMarkExecutable (void *start, size_t len); void addProddableBlock ( ObjectCode* oc, void* start, int size ); -- cgit v1.2.1