Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Woops, unmap the first page in the `win' c...
details: https://anonhg.NetBSD.org/src/rev/43d9cc510262
branches: trunk
changeset: 536930:43d9cc510262
user: mycroft <mycroft%NetBSD.org@localhost>
date: Tue Sep 24 12:44:58 2002 +0000
description:
Woops, unmap the first page in the `win' case, too.
Tidy up a bit.
diffstat:
libexec/ld.elf_so/map_object.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diffs (78 lines):
diff -r c7d0928e0727 -r 43d9cc510262 libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c Tue Sep 24 12:18:32 2002 +0000
+++ b/libexec/ld.elf_so/map_object.c Tue Sep 24 12:44:58 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: map_object.c,v 1.19 2002/09/24 09:35:13 junyoung Exp $ */
+/* $NetBSD: map_object.c,v 1.20 2002/09/24 12:44:58 mycroft Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -59,7 +59,6 @@
{
Obj_Entry *obj;
Elf_Ehdr *ehdr;
- void *u;
Elf_Phdr *phdr;
Elf_Phdr *phlimit;
Elf_Phdr *segs[2];
@@ -86,13 +85,12 @@
size_t nclear;
#endif
- u = mmap(NULL, _rtld_pagesz, PROT_READ, MAP_FILE | MAP_SHARED, fd,
+ ehdr = mmap(NULL, _rtld_pagesz, PROT_READ, MAP_FILE | MAP_SHARED, fd,
(off_t)0);
- if (u == MAP_FAILED) {
+ if (ehdr == MAP_FAILED) {
_rtld_error("%s: read error: %s", path, xstrerror(errno));
return NULL;
}
- ehdr = (Elf_Ehdr *)u;
/* Make sure the file is valid */
if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 ||
ehdr->e_ident[EI_CLASS] != ELFCLASS) {
@@ -213,8 +211,7 @@
MAP_FILE | MAP_PRIVATE | MAP_FIXED, fd, data_offset)
== MAP_FAILED) {
_rtld_error("mmap of data failed: %s", xstrerror(errno));
- munmap(mapbase, mapsize);
- goto bad;
+ goto bad2;
}
/* Overlay the bss segment onto the proper region. */
@@ -223,8 +220,7 @@
MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0)
== MAP_FAILED) {
_rtld_error("mmap of bss failed: %s", xstrerror(errno));
- munmap(mapbase, mapsize);
- goto bad;
+ goto bad2;
}
/* Unmap the gap between the text and data. */
@@ -233,8 +229,7 @@
if (gap_size != 0 && munmap(gap_addr, gap_size) == -1) {
_rtld_error("munmap of text -> data gap failed: %s",
xstrerror(errno));
- munmap(mapbase, mapsize);
- goto bad;
+ goto bad2;
}
#ifdef RTLD_LOADER
@@ -271,10 +266,13 @@
obj->interp = (const char *) (obj->relocbase + phinterp->p_vaddr);
obj->isdynamic = ehdr->e_type == ET_DYN;
+ munmap(ehdr, _rtld_pagesz);
return obj;
+bad2:
+ munmap(mapbase, mapsize);
bad:
- munmap(u, _rtld_pagesz);
+ munmap(ehdr, _rtld_pagesz);
return NULL;
}
Home |
Main Index |
Thread Index |
Old Index