diff options
author | Alexander Graf <agraf@suse.de> | 2011-11-02 20:23:26 +0100 |
---|---|---|
committer | Riku Voipio <riku.voipio@linaro.org> | 2012-02-02 17:51:20 +0200 |
commit | 257450ee59fd7e781cb4e2316ddc845c40b9fc42 (patch) | |
tree | 3fca131d092e6a1f3cc4023733bb003e6e0b61d9 /linux-user/syscall.c | |
parent | 480b8e7dd56746c550a8ae9d7d1ba5d22cf1a4ee (diff) |
linux-user: fake /proc/self/auxv
Gtk tries to read /proc/self/auxv to find its auxv table instead of
taking it from its own program memory space.
However, when running with linux-user, we see the host's auxv which
clearly exposes wrong information. so let's instead expose the guest
memory backed auxv tables via /proc/self/auxv as well.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5a5fdac1e6..c6bfcd8815 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4639,6 +4639,35 @@ static int open_self_stat(void *cpu_env, int fd) return 0; } +static int open_self_auxv(void *cpu_env, int fd) +{ + TaskState *ts = ((CPUState *)cpu_env)->opaque; + abi_ulong auxv = ts->info->saved_auxv; + abi_ulong len = ts->info->auxv_len; + char *ptr; + + /* + * Auxiliary vector is stored in target process stack. + * read in whole auxv vector and copy it to file + */ + ptr = lock_user(VERIFY_READ, auxv, len, 0); + if (ptr != NULL) { + while (len > 0) { + ssize_t r; + r = write(fd, ptr, len); + if (r <= 0) { + break; + } + len -= r; + ptr += r; + } + lseek(fd, 0, SEEK_SET); + unlock_user(ptr, auxv, len); + } + + return 0; +} + static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) { struct fake_open { @@ -4649,6 +4678,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) static const struct fake_open fakes[] = { { "/proc/self/maps", open_self_maps }, { "/proc/self/stat", open_self_stat }, + { "/proc/self/auxv", open_self_auxv }, { NULL, NULL } }; |