summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-06-18 05:42:33 +0000
committerdillon <dillon@FreeBSD.org>2002-06-18 05:42:33 +0000
commit33d5a8940419428fb52d7bde4bb0ab98c70577e2 (patch)
treeb12c35e693d6856f2ca287d761c7cf80dc70ab70 /libexec
parented445694ae1edf386850e3f650bbe2519101a1c8 (diff)
downloadFreeBSD-src-33d5a8940419428fb52d7bde4bb0ab98c70577e2.zip
FreeBSD-src-33d5a8940419428fb52d7bde4bb0ab98c70577e2.tar.gz
This is the same alloca() fix as was committed for i386. David O'Brien
tested the patch on -stable. Reviewed by: obrien Approved by: jdp MFC after: 3 days
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/alpha/reloc.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libexec/rtld-elf/alpha/reloc.c b/libexec/rtld-elf/alpha/reloc.c
index 882a8ac..4d9356c 100644
--- a/libexec/rtld-elf/alpha/reloc.c
+++ b/libexec/rtld-elf/alpha/reloc.c
@@ -152,10 +152,18 @@ 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;
- cache = (SymCache *)alloca(obj->nchains * sizeof(SymCache));
+ /*
+ * The dynamic loader may be called from a thread, we have
+ * limited amounts of stack available so we cannot use alloca().
+ */
+ cache = mmap(NULL, bytes, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
+ if (cache == MAP_FAILED)
+ cache = NULL;
if (cache != NULL)
- memset(cache, 0, obj->nchains * sizeof(SymCache));
+ memset(cache, 0, bytes);
/* Perform relocations without addend if there are any: */
rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
@@ -166,16 +174,20 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
locrela.r_offset = rel->r_offset;
locrela.r_addend = 0;
if (reloc_non_plt_obj(obj_rtld, obj, &locrela, cache))
- return -1;
+ goto done;
}
/* Perform relocations with addend if there are any: */
relalim = (const Elf_Rela *) ((caddr_t) obj->rela + obj->relasize);
for (rela = obj->rela; obj->rela != NULL && rela < relalim; rela++) {
if (reloc_non_plt_obj(obj_rtld, obj, rela, cache))
- return -1;
+ goto done;
}
- return 0;
+ r = 0;
+done:
+ if (cache)
+ munmap(cache, bytes);
+ return(r);
}
/* Process the PLT relocations. */
OpenPOWER on IntegriCloud