提交 0b959cf5 编写于 作者: R Richard Henderson

linux-user: Use qemu_getauxval for AT_EXECFD

Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NRichard Henderson <rth@twiddle.net>
上级 664d2c44
...@@ -3663,26 +3663,6 @@ static int parse_args(int argc, char **argv) ...@@ -3663,26 +3663,6 @@ static int parse_args(int argc, char **argv)
return optind; return optind;
} }
static int get_execfd(char **envp)
{
typedef struct {
long a_type;
long a_val;
} auxv_t;
auxv_t *auxv;
while (*envp++ != NULL) {
;
}
for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
if (auxv->a_type == AT_EXECFD) {
return auxv->a_val;
}
}
return -1;
}
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
struct target_pt_regs regs1, *regs = &regs1; struct target_pt_regs regs1, *regs = &regs1;
...@@ -3876,14 +3856,14 @@ int main(int argc, char **argv, char **envp) ...@@ -3876,14 +3856,14 @@ int main(int argc, char **argv, char **envp)
env->opaque = ts; env->opaque = ts;
task_settid(ts); task_settid(ts);
execfd = get_execfd(envp); execfd = qemu_getauxval(AT_EXECFD);
if (execfd < 0) { if (execfd == 0) {
execfd = open(filename, O_RDONLY); execfd = open(filename, O_RDONLY);
}
if (execfd < 0) { if (execfd < 0) {
printf("Error while loading %s: %s\n", filename, strerror(-execfd)); printf("Error while loading %s: %s\n", filename, strerror(errno));
_exit(1); _exit(1);
} }
}
ret = loader_exec(execfd, filename, target_argv, target_environ, regs, ret = loader_exec(execfd, filename, target_argv, target_environ, regs,
info, &bprm); info, &bprm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册