From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsA20-0004HR-O7 for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsA1r-0002bn-3l for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:40 -0500 Received: from afflict.kos.to ([92.243.29.197]:37247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsA1q-0002bB-TJ for qemu-devel@nongnu.org; Tue, 31 Jan 2012 04:29:31 -0500 From: riku.voipio@linaro.org Date: Tue, 31 Jan 2012 11:29:14 +0200 Message-Id: <32ca1a64b3e93ececef377481588b2e3a43f3673.1328001769.git.riku.voipio@linaro.org> In-Reply-To: References: Subject: [Qemu-devel] [PATCH 05/19] linux-user: fake /proc/self/stat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf From: Alexander Graf 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 Signed-off-by: Riku Voipio --- linux-user/syscall.c | 26 ++++++++++++++++++++++++++ 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 } }; -- 1.7.5.4