diff --git a/lib/libc/gen/auxv.c b/lib/libc/gen/auxv.c index 61dac29e532..1c833d3ce73 100644 --- a/lib/libc/gen/auxv.c +++ b/lib/libc/gen/auxv.c @@ -73,10 +73,17 @@ static char *canary, *pagesizes, *execpath; static void *timekeep; static u_long hwcap, hwcap2; +#ifdef __powerpc__ +static void _init_aux_powerpc_fixup(void); +#endif + static void init_aux(void) { Elf_Auxinfo *aux; +#ifdef __powerpc__ + int old_auxv_format = 1; +#endif for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) { switch (aux->a_type) { @@ -125,9 +132,58 @@ init_aux(void) case AT_TIMEKEEP: timekeep = aux->a_un.a_ptr; break; +#ifdef __powerpc__ + case 23: /* AT_STACKPROT */ + old_auxv_format = 0; + break; +#endif + } + } +#ifdef __powerpc__ + if (old_auxv_format) + _init_aux_powerpc_fixup(); +#endif +} + +#ifdef __powerpc__ +static void +_init_aux_powerpc_fixup(void) +{ + Elf_Auxinfo *aux; + + for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) { + switch (aux->a_type) { + case 14: /* AT_CANARY */ + canary = (char *)(aux->a_un.a_ptr); + break; + + case 15: /* AT_CANARYLEN */ + canary_len = aux->a_un.a_val; + break; + + case 13: /* AT_EXECPATH */ + execpath = (char *)(aux->a_un.a_ptr); + break; + + case 18: /* AT_PAGESIZES */ + pagesizes = (char *)(aux->a_un.a_ptr); + break; + + case 19: /* AT_PAGESIZESLEN */ + pagesizes_len = aux->a_un.a_val; + break; + + case 16: /* AT_OSRELDATE */ + osreldate = aux->a_un.a_val; + break; + + case 17: /* AT_NCPUS */ + ncpus = aux->a_un.a_val; + break; } } } +#endif __weak_reference(_elf_aux_info, elf_aux_info);