Avoid the use of a `switch(){}' statement before _rtld_init() is called.
`switch()' code may be translated using a jump table approach which causes it to reference the equivalent of a global variable, something that must be avoided before _rtld_init() has run.
This commit is contained in:
parent
b26a441f6a
commit
38fd9b8f99
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtld.c,v 1.43 2000/11/10 23:53:04 mycroft Exp $ */
|
||||
/* $NetBSD: rtld.c,v 1.44 2001/02/03 13:25:00 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -334,12 +334,40 @@ _rtld(sp)
|
|||
}
|
||||
aux = (const AuxInfo *) sp;
|
||||
|
||||
/* Digest the auxiliary vector. */
|
||||
pAUX_base = pAUX_entry = pAUX_execfd = NULL;
|
||||
pAUX_phdr = pAUX_phent = pAUX_phnum = NULL;
|
||||
#ifdef VARPSZ
|
||||
pAUX_pagesz = NULL;
|
||||
#endif
|
||||
/*
|
||||
* First pass through the the auxiliary vector, avoiding the use
|
||||
* of a `switch() {}' statement at this stage. A `switch()' may
|
||||
* be translated into code utilizing a jump table approach which
|
||||
* references the equivalent of a global variable. This must be
|
||||
* avoided until _rtld_init() has done its job.
|
||||
*
|
||||
* _rtld_init() only needs `pAUX_base' and possibly `pAUX_pagesz',
|
||||
* so we look for just those in this pass.
|
||||
*/
|
||||
for (auxp = aux; auxp->a_type != AT_NULL; ++auxp) {
|
||||
if (auxp->a_type == AT_BASE)
|
||||
pAUX_base = auxp;
|
||||
#ifdef VARPSZ
|
||||
if (auxp->a_type == AT_PAGESZ)
|
||||
pAUX_pagesz = auxp;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize and relocate ourselves. */
|
||||
assert(pAUX_base != NULL);
|
||||
#ifdef VARPSZ
|
||||
assert(pAUX_pagesz != NULL);
|
||||
_rtld_init((caddr_t) pAUX_base->a_v, (int)pAUX_pagesz->a_v);
|
||||
#else
|
||||
_rtld_init((caddr_t) pAUX_base->a_v, 0);
|
||||
#endif
|
||||
|
||||
/* Digest the auxiliary vector (full pass now that we can afford it). */
|
||||
for (auxp = aux; auxp->a_type != AT_NULL; ++auxp) {
|
||||
switch (auxp->a_type) {
|
||||
case AT_BASE:
|
||||
|
@ -368,15 +396,6 @@ _rtld(sp)
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize and relocate ourselves. */
|
||||
assert(pAUX_base != NULL);
|
||||
#ifdef VARPSZ
|
||||
assert(pAUX_pagesz != NULL);
|
||||
_rtld_init((caddr_t) pAUX_base->a_v, (int)pAUX_pagesz->a_v);
|
||||
#else
|
||||
_rtld_init((caddr_t) pAUX_base->a_v, 0);
|
||||
#endif
|
||||
|
||||
#ifdef VARPSZ
|
||||
_rtld_pagesz = (int)pAUX_pagesz->a_v;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue