Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powerpc/elf_common.c
Show All 28 Lines | |||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
static int | static int | ||||
__elfN(powerpc_copyout_auxargs)(struct image_params *imgp, uintptr_t base) | __elfN(powerpc_copyout_auxargs)(struct image_params *imgp, uintptr_t base) | ||||
{ | { | ||||
Elf_Auxargs *args; | Elf_Auxargs *args; | ||||
Elf_Auxinfo *argarray, *pos; | Elf_Auxinfo *argarray, *pos; | ||||
struct vmspace *vmspace; | |||||
int error; | int error; | ||||
/* | /* | ||||
* XXX If we can't find image's OSREL, assume it uses the new auxv | * XXX If we can't find image's OSREL, assume it uses the new auxv | ||||
* format. | * format. | ||||
* | * | ||||
* This is specially important for rtld, that is not tagged. Using | * This is specially important for rtld, that is not tagged. Using | ||||
* direct exec mode with new (ELFv2) binaries that expect the new auxv | * direct exec mode with new (ELFv2) binaries that expect the new auxv | ||||
* format would result in crashes otherwise. | * format would result in crashes otherwise. | ||||
* | * | ||||
* Unfortunately, this may break direct exec'ing old binaries, | * Unfortunately, this may break direct exec'ing old binaries, | ||||
* but it seems better to correctly support new binaries by default, | * but it seems better to correctly support new binaries by default, | ||||
* considering the transition to ELFv2 happened quite some time | * considering the transition to ELFv2 happened quite some time | ||||
* ago. If needed, a sysctl may be added to allow old auxv format to | * ago. If needed, a sysctl may be added to allow old auxv format to | ||||
* be used when OSREL is not found. | * be used when OSREL is not found. | ||||
*/ | */ | ||||
if (imgp->proc->p_osrel >= P_OSREL_POWERPC_NEW_AUX_ARGS || | if (imgp->proc->p_osrel >= P_OSREL_POWERPC_NEW_AUX_ARGS || | ||||
imgp->proc->p_osrel == 0) | imgp->proc->p_osrel == 0) | ||||
return (__elfN(freebsd_copyout_auxargs)(imgp, base)); | return (__elfN(freebsd_copyout_auxargs)(imgp, base)); | ||||
args = (Elf_Auxargs *)imgp->auxargs; | args = (Elf_Auxargs *)imgp->auxargs; | ||||
argarray = pos = malloc(AT_OLD_COUNT * sizeof(*pos), M_TEMP, | argarray = pos = malloc(AT_OLD_COUNT * sizeof(*pos), M_TEMP, | ||||
M_WAITOK | M_ZERO); | M_WAITOK | M_ZERO); | ||||
vmspace = imgp->proc->p_vmspace; | |||||
if (args->execfd != -1) | if (args->execfd != -1) | ||||
AUXARGS_ENTRY(pos, AT_OLD_EXECFD, args->execfd); | AUXARGS_ENTRY(pos, AT_OLD_EXECFD, args->execfd); | ||||
AUXARGS_ENTRY(pos, AT_OLD_PHDR, args->phdr); | AUXARGS_ENTRY(pos, AT_OLD_PHDR, args->phdr); | ||||
AUXARGS_ENTRY(pos, AT_OLD_PHENT, args->phent); | AUXARGS_ENTRY(pos, AT_OLD_PHENT, args->phent); | ||||
AUXARGS_ENTRY(pos, AT_OLD_PHNUM, args->phnum); | AUXARGS_ENTRY(pos, AT_OLD_PHNUM, args->phnum); | ||||
AUXARGS_ENTRY(pos, AT_OLD_PAGESZ, args->pagesz); | AUXARGS_ENTRY(pos, AT_OLD_PAGESZ, args->pagesz); | ||||
AUXARGS_ENTRY(pos, AT_OLD_FLAGS, args->flags); | AUXARGS_ENTRY(pos, AT_OLD_FLAGS, args->flags); | ||||
AUXARGS_ENTRY(pos, AT_OLD_ENTRY, args->entry); | AUXARGS_ENTRY(pos, AT_OLD_ENTRY, args->entry); | ||||
AUXARGS_ENTRY(pos, AT_OLD_BASE, args->base); | AUXARGS_ENTRY(pos, AT_OLD_BASE, args->base); | ||||
AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags); | AUXARGS_ENTRY(pos, AT_OLD_EHDRFLAGS, args->hdr_eflags); | ||||
if (imgp->execpathp != 0) | if (imgp->execpathp != 0) | ||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_EXECPATH, imgp->execpathp); | AUXARGS_ENTRY_PTR(pos, AT_OLD_EXECPATH, imgp->execpathp); | ||||
AUXARGS_ENTRY(pos, AT_OLD_OSRELDATE, | AUXARGS_ENTRY(pos, AT_OLD_OSRELDATE, | ||||
imgp->proc->p_ucred->cr_prison->pr_osreldate); | imgp->proc->p_ucred->cr_prison->pr_osreldate); | ||||
if (imgp->canary != 0) { | if (imgp->canary != 0) { | ||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_CANARY, imgp->canary); | AUXARGS_ENTRY_PTR(pos, AT_OLD_CANARY, imgp->canary); | ||||
AUXARGS_ENTRY(pos, AT_OLD_CANARYLEN, imgp->canarylen); | AUXARGS_ENTRY(pos, AT_OLD_CANARYLEN, imgp->canarylen); | ||||
} | } | ||||
AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus); | AUXARGS_ENTRY(pos, AT_OLD_NCPUS, mp_ncpus); | ||||
if (imgp->pagesizes != 0) { | if (imgp->pagesizes != 0) { | ||||
AUXARGS_ENTRY_PTR(pos, AT_OLD_PAGESIZES, imgp->pagesizes); | AUXARGS_ENTRY_PTR(pos, AT_OLD_PAGESIZES, imgp->pagesizes); | ||||
AUXARGS_ENTRY(pos, AT_OLD_PAGESIZESLEN, imgp->pagesizeslen); | AUXARGS_ENTRY(pos, AT_OLD_PAGESIZESLEN, imgp->pagesizeslen); | ||||
} | } | ||||
if (imgp->sysent->sv_timekeep_base != 0) { | if ((imgp->sysent->sv_flags & SV_TIMEKEEP) != 0) { | ||||
AUXARGS_ENTRY(pos, AT_OLD_TIMEKEEP, | AUXARGS_ENTRY(pos, AT_OLD_TIMEKEEP, | ||||
imgp->sysent->sv_timekeep_base); | vmspace->vm_shp_base + imgp->sysent->sv_timekeep_offset); | ||||
} | } | ||||
AUXARGS_ENTRY(pos, AT_OLD_STACKPROT, imgp->sysent->sv_shared_page_obj | AUXARGS_ENTRY(pos, AT_OLD_STACKPROT, imgp->sysent->sv_shared_page_obj | ||||
!= NULL && imgp->stack_prot != 0 ? imgp->stack_prot : | != NULL && imgp->stack_prot != 0 ? imgp->stack_prot : | ||||
imgp->sysent->sv_stackprot); | imgp->sysent->sv_stackprot); | ||||
if (imgp->sysent->sv_hwcap != NULL) | if (imgp->sysent->sv_hwcap != NULL) | ||||
AUXARGS_ENTRY(pos, AT_OLD_HWCAP, *imgp->sysent->sv_hwcap); | AUXARGS_ENTRY(pos, AT_OLD_HWCAP, *imgp->sysent->sv_hwcap); | ||||
if (imgp->sysent->sv_hwcap2 != NULL) | if (imgp->sysent->sv_hwcap2 != NULL) | ||||
AUXARGS_ENTRY(pos, AT_OLD_HWCAP2, *imgp->sysent->sv_hwcap2); | AUXARGS_ENTRY(pos, AT_OLD_HWCAP2, *imgp->sysent->sv_hwcap2); | ||||
Show All 10 Lines |