Changeset View
Changeset View
Standalone View
Standalone View
head/sys/compat/cloudabi64/cloudabi64_module.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
cloudabi64_copyout_strings(struct image_params *imgp) | cloudabi64_copyout_strings(struct image_params *imgp) | ||||
{ | { | ||||
struct image_args *args; | struct image_args *args; | ||||
uintptr_t begin; | uintptr_t begin; | ||||
size_t len; | size_t len; | ||||
/* Copy out program arguments. */ | /* Copy out program arguments. */ | ||||
args = imgp->args; | args = imgp->args; | ||||
len = args->begin_envv - args->begin_argv; | len = exec_args_get_begin_envv(args) - args->begin_argv; | ||||
begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t)); | begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t)); | ||||
copyout(args->begin_argv, (void *)begin, len); | copyout(args->begin_argv, (void *)begin, len); | ||||
return ((register_t *)begin); | return ((register_t *)begin); | ||||
} | } | ||||
int | int | ||||
cloudabi64_fixup(register_t **stack_base, struct image_params *imgp) | cloudabi64_fixup(register_t **stack_base, struct image_params *imgp) | ||||
{ | { | ||||
Show All 38 Lines | if (error != 0) | ||||
return (error); | return (error); | ||||
/* | /* | ||||
* Compute length of program arguments. As the argument data is | * Compute length of program arguments. As the argument data is | ||||
* binary safe, we had to add a trailing null byte in | * binary safe, we had to add a trailing null byte in | ||||
* exec_copyin_data_fds(). Undo this by reducing the length. | * exec_copyin_data_fds(). Undo this by reducing the length. | ||||
*/ | */ | ||||
args = (Elf64_Auxargs *)imgp->auxargs; | args = (Elf64_Auxargs *)imgp->auxargs; | ||||
argdatalen = imgp->args->begin_envv - imgp->args->begin_argv; | argdatalen = exec_args_get_begin_envv(imgp->args) - | ||||
imgp->args->begin_argv; | |||||
if (argdatalen > 0) | if (argdatalen > 0) | ||||
--argdatalen; | --argdatalen; | ||||
/* Write out an auxiliary vector. */ | /* Write out an auxiliary vector. */ | ||||
cloudabi64_auxv_t auxv[] = { | cloudabi64_auxv_t auxv[] = { | ||||
#define VAL(type, val) { .a_type = (type), .a_val = (val) } | #define VAL(type, val) { .a_type = (type), .a_val = (val) } | ||||
#define PTR(type, ptr) { .a_type = (type), .a_ptr = (uintptr_t)(ptr) } | #define PTR(type, ptr) { .a_type = (type), .a_ptr = (uintptr_t)(ptr) } | ||||
PTR(CLOUDABI_AT_ARGDATA, argdata), | PTR(CLOUDABI_AT_ARGDATA, argdata), | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |