diff options
author | Ariane van der Steldt <ariane@cvs.openbsd.org> | 2012-01-09 17:01:23 +0000 |
---|---|---|
committer | Ariane van der Steldt <ariane@cvs.openbsd.org> | 2012-01-09 17:01:23 +0000 |
commit | 1f4e3c7ba0f4df1dcba845786357b287ae848442 (patch) | |
tree | fd792d7b59705a723204238060552129a1f4028d /libexec/ld.so | |
parent | 4614526551b8fe9ac885e727ad1f3f51aa460708 (diff) |
Don't mmap 0 byte areas, treat them as a noop instead.
ok miod@
Diffstat (limited to 'libexec/ld.so')
-rw-r--r-- | libexec/ld.so/library.c | 15 | ||||
-rw-r--r-- | libexec/ld.so/library_mquery.c | 20 |
2 files changed, 20 insertions, 15 deletions
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c index e932382de6c..a927ae1c560 100644 --- a/libexec/ld.so/library.c +++ b/libexec/ld.so/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.63 2011/11/28 20:59:03 guenther Exp $ */ +/* $OpenBSD: library.c,v 1.64 2012/01/09 17:01:22 ariane Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -181,17 +181,20 @@ _dl_tryload_shlib(const char *libname, int type, int flags) Elf_Addr size = off + phdp->p_filesz; void *res; - res = _dl_mmap(start, ROUND_PG(size), - PFLAGS(phdp->p_flags), - MAP_FIXED|MAP_PRIVATE, libfile, - TRUNC_PG(phdp->p_offset)); + if (size != 0) { + res = _dl_mmap(start, ROUND_PG(size), + PFLAGS(phdp->p_flags), + MAP_FIXED|MAP_PRIVATE, libfile, + TRUNC_PG(phdp->p_offset)); + } else + res = NULL; /* silence gcc */ next_load = _dl_malloc(sizeof(struct load_list)); next_load->next = load_list; load_list = next_load; next_load->start = start; next_load->size = size; next_load->prot = PFLAGS(phdp->p_flags); - if (_dl_mmap_error(res)) { + if (size != 0 && _dl_mmap_error(res)) { _dl_printf("%s: rtld mmap failed mapping %s.\n", _dl_progname, libname); _dl_close(libfile); diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index 6bf0920cf9b..08e4d7075c4 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.39 2011/11/28 20:59:03 guenther Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.40 2012/01/09 17:01:22 ariane Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -157,15 +157,17 @@ _dl_tryload_shlib(const char *libname, int type, int flags) off = (phdp->p_vaddr & align); size = off + phdp->p_filesz; - ld = _dl_malloc(sizeof(struct load_list)); - ld->start = NULL; - ld->size = size; - ld->moff = TRUNC_PG(phdp->p_vaddr); - ld->foff = TRUNC_PG(phdp->p_offset); - ld->prot = PFLAGS(phdp->p_flags); - LDLIST_INSERT(ld); + if (size != 0) { + ld = _dl_malloc(sizeof(struct load_list)); + ld->start = NULL; + ld->size = size; + ld->moff = TRUNC_PG(phdp->p_vaddr); + ld->foff = TRUNC_PG(phdp->p_offset); + ld->prot = PFLAGS(phdp->p_flags); + LDLIST_INSERT(ld); + } - if ((ld->prot & PROT_WRITE) == 0 || + if ((PFLAGS(phdp->p_flags) & PROT_WRITE) == 0 || ROUND_PG(size) == ROUND_PG(off + phdp->p_memsz)) break; /* This phdr has a zfod section */ |