[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/19] linux-user: fake /proc/self/stat
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 05/19] linux-user: fake /proc/self/stat |
Date: |
Fri, 3 Feb 2012 16:49:18 +0200 |
From: Alexander Graf <address@hidden>
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 <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
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
- [Qemu-devel] [PATCH 15/19] linux-user: Add default-configs for mipsn32[el], (continued)
- [Qemu-devel] [PATCH 15/19] linux-user: Add default-configs for mipsn32[el], riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 02/19] linux-user: save auxv length, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 17/19] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 19/19] linux-user: Fix sa_flags byte swaps for mips, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 01/19] linux-user: stack_base is now mandatory on all targets, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 06/19] linux-user: fake /proc/self/auxv, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 16/19] linux-user: Add default configs for mips64[el], riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 03/19] linux-user: add open() hijack infrastructure, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 07/19] linux-user/main.c: Add option to user-mode emulation so that user can specify log file name, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 05/19] linux-user: fake /proc/self/stat,
riku . voipio <=
- [Qemu-devel] [PATCH 08/19] linux-user: add SO_PEERCRED support for getsockopt, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 11/19] linux-user: fix wait* syscall status returns, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 13/19] linux-user/syscall.c: Implement f and l versions of set/get/removexattr, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 04/19] linux-user: fake /proc/self/maps, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 10/19] linux-user/strace.c: Correct errno printing for mmap etc, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 12/19] linux-user: Allow NULL value pointer in setxattr and getxattr, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 14/19] linux-user: Implement *listxattr syscalls, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 09/19] linux-user: fix QEMU_STRACE=1 segfault, riku . voipio, 2012/02/03
- [Qemu-devel] [PATCH 18/19] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64, riku . voipio, 2012/02/03
- Re: [Qemu-devel] [PULL] [PATCH 00/19] linux-user update, Blue Swirl, 2012/02/04