rts/linker: Use mmapForLinker to map PLT wip/backport-MR1139
authorBen Gamari <ben@well-typed.com>
Sat, 8 Jun 2019 19:31:54 +0000 (19:31 +0000)
committerBen Gamari <ben@smart-cactus.org>
Wed, 12 Jun 2019 12:47:52 +0000 (08:47 -0400)
The PLT needs to be located within a close distance of
the code calling it under the small memory model.

Fixes #16784.

(cherry picked from commit 0b7f81f560c602f32cfc90fd3fb5f1c52f06ad49)

rts/linker/Elf.c

index 9ea10d4..f83700a 100644 (file)
@@ -732,12 +732,8 @@ ocGetNames_ELF ( ObjectCode* oc )
           unsigned nstubs = numberOfStubsForSection(oc, i);
           unsigned stub_space = STUB_SIZE * nstubs;
 
-          void * mem = mmap(NULL, size+stub_space,
-                            PROT_READ | PROT_WRITE | PROT_EXEC,
-                            MAP_ANON | MAP_PRIVATE,
-                            -1, 0);
-
-          if( mem == MAP_FAILED ) {
+          void * mem = mmapForLinker(size+stub_space, MAP_ANON, -1, 0);
+          if( mem == NULL ) {
               barf("failed to mmap allocated memory to load section %d. "
                    "errno = %d", i, errno);
           }