aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2013-10-15 15:00:36 -0700
committerRichard Henderson <rth@twiddle.net>2013-11-30 07:48:46 +1300
commit0b959cf5e4cce08ed96bd7832447e1543cd3622f (patch)
tree19f68d431357bd4325cb7c3414ac775ee38cca98
parent664d2c4458a268eb176a223c397453a72ed167f4 (diff)
linux-user: Use qemu_getauxval for AT_EXECFD
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r--linux-user/main.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 50db7553ea..54f71fe8f6 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3663,26 +3663,6 @@ static int parse_args(int argc, char **argv)
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)
{
struct target_pt_regs regs1, *regs = &regs1;
@@ -3876,13 +3856,13 @@ int main(int argc, char **argv, char **envp)
env->opaque = ts;
task_settid(ts);
- execfd = get_execfd(envp);
- if (execfd < 0) {
+ execfd = qemu_getauxval(AT_EXECFD);
+ if (execfd == 0) {
execfd = open(filename, O_RDONLY);
- }
- if (execfd < 0) {
- printf("Error while loading %s: %s\n", filename, strerror(-execfd));
- _exit(1);
+ if (execfd < 0) {
+ printf("Error while loading %s: %s\n", filename, strerror(errno));
+ _exit(1);
+ }
}
ret = loader_exec(execfd, filename, target_argv, target_environ, regs,