aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2011-11-02 20:23:25 +0100
committerRiku Voipio <riku.voipio@linaro.org>2012-02-02 17:51:20 +0200
commit480b8e7dd56746c550a8ae9d7d1ba5d22cf1a4ee (patch)
tree1632d5ad7b811658843a9d92e7709ddd42b23ba7 /linux-user
parent36c08d498b8ea6995666b805d37c6bb14da66a97 (diff)
downloadqemu-480b8e7dd56746c550a8ae9d7d1ba5d22cf1a4ee.zip
qemu-480b8e7dd56746c550a8ae9d7d1ba5d22cf1a4ee.tar.gz
qemu-480b8e7dd56746c550a8ae9d7d1ba5d22cf1a4ee.tar.bz2
linux-user: fake /proc/self/stat
The boehm gc finds the program's stack starting pointer by checking /proc/self/stat. Unfortunately, so far it reads qemu's stack pointer which clearly is wrong. So let's instead fake the file so the guest program sees the right address. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1864d7f..5a5fdac 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4614,6 +4614,31 @@ static int open_self_maps(void *cpu_env, int fd)
return 0;
}
+static int open_self_stat(void *cpu_env, int fd)
+{
+ TaskState *ts = ((CPUState *)cpu_env)->opaque;
+ abi_ulong start_stack = ts->info->start_stack;
+ int i;
+
+ for (i = 0; i < 44; i++) {
+ char buf[128];
+ int len;
+ uint64_t val = 0;
+
+ if (i == 27) {
+ /* stack bottom */
+ val = start_stack;
+ }
+ snprintf(buf, sizeof(buf), "%"PRId64 "%c", val, i == 43 ? '\n' : ' ');
+ len = strlen(buf);
+ if (write(fd, buf, len) != len) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
{
struct fake_open {
@@ -4623,6 +4648,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
const struct fake_open *fake_open;
static const struct fake_open fakes[] = {
{ "/proc/self/maps", open_self_maps },
+ { "/proc/self/stat", open_self_stat },
{ NULL, NULL }
};