From 7f3f7db3798a4d71f451d4eede04bcd6f9bec96b Mon Sep 17 00:00:00 2001 From: rdivacky Date: Tue, 18 May 2010 08:55:23 +0000 Subject: Only use the cache after the early stage of loading. This is because calling mmap() etc. may use GOT which is not set up yet. Use calloc() instead of mmap() in cases where this was the case before (sparc64, powerpc, arm). Submitted by: Dimitry Andric (dimitry andric com) Reviewed by: kan Approved by: ed (mentor) --- libexec/rtld-elf/powerpc/reloc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'libexec/rtld-elf/powerpc') diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index ccdcd90..c90852f 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -287,7 +287,6 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) const Elf_Rela *relalim; const Elf_Rela *rela; SymCache *cache; - int bytes = obj->nchains * sizeof(SymCache); int r = -1; /* @@ -295,10 +294,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, - -1, 0); - if (cache == MAP_FAILED) - cache = NULL; + cache = calloc(obj->nchains, sizeof(SymCache)); + /* No need to check for NULL here */ } else cache = NULL; @@ -314,9 +311,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) } r = 0; done: - if (cache) { - munmap(cache, bytes); - } + if (cache != NULL) + free(cache); return (r); } -- cgit v1.1