summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-10 10:00:22 +0000
committerRoland McGrath <roland@gnu.org>1996-01-10 10:00:22 +0000
commit22930c9bf21ea15d0da1477a379029e2de259b69 (patch)
tree4965b8c88d7fa7c00db1b58de2029b26d3310d95 /elf
parent7410183b8b5e048a99b715c18b7259160077c4e0 (diff)
downloadglibc-22930c9bf21ea15d0da1477a379029e2de259b69.tar.gz
Tue Jan 9 16:10:26 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>cvs/libc-960110
* elf/dl-load.c (_dl_map_object_from_fd): After mapping first segment to find location, mprotect excess region to no access, don't munmap it. * sysdeps/mach/hurd/dl-sysdep.c (mmap): If vm_map returns KERN_NO_SPACE for fixed location, deallocate it and try again.
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-load.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 416f9ac688..527901cd6d 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -355,20 +355,23 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname)
kernel map it anywhere it likes, but we must have space for all
the segments in their specified positions relative to the first.
So we map the first segment without MAP_FIXED, but with its
- extent increased to cover all the segments. Then we unmap the
- excess portion, and there is known sufficient space there to map
- the later segments. */
+ extent increased to cover all the segments. Then we remove
+ access from excess portion, and there is known sufficient space
+ there to remap from the later segments. */
caddr_t mapat;
mapat = map_segment (c->mapstart,
loadcmds[nloadcmds - 1].allocend - c->mapstart,
c->prot, 0, c->mapoff);
l->l_addr = (Elf32_Addr) mapat - c->mapstart;
- /* Unmap the excess portion, and then jump into the normal
- segment-mapping loop to handle the portion of the segment past
- the end of the file mapping. */
- munmap (mapat + c->mapend,
- loadcmds[nloadcmds - 1].allocend - c->mapend);
+ /* Change protection on the excess portion to disallow all access;
+ the portions we do not remap later will be inaccessible as if
+ unallocated. Then jump into the normal segment-mapping loop to
+ handle the portion of the segment past the end of the file
+ mapping. */
+ mprotect (mapat + c->mapend,
+ loadcmds[nloadcmds - 1].allocend - c->mapend,
+ 0);
goto postmap;
}