diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-05-08 09:37:00 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-05-08 09:37:00 -0500 |
commit | 233ffa1653b49755e841efdccbd2ac63272ce0c8 (patch) | |
tree | 7b70dcb41772ad49a2835064576a7c0a17462c87 | |
parent | acde8376ef638007efdd0b34413ba01b9352171c (diff) | |
parent | 1a49ef2ad3c1c3c50e6aea348260412f98ea862d (diff) |
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging
* riku/linux-user-for-upstream:
linux-user: fix emulation of /proc/self/maps
linux-user: Clean up interim solution for exit syscall
-rw-r--r-- | linux-user/syscall.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 712861829a..20d2a74877 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4866,13 +4866,53 @@ int get_osversion(void) static int open_self_maps(void *cpu_env, int fd) { +#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) TaskState *ts = ((CPUArchState *)cpu_env)->opaque; +#endif + FILE *fp; + char *line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen("/proc/self/maps", "r"); + if (fp == NULL) { + return -EACCES; + } + + while ((read = getline(&line, &len, fp)) != -1) { + int fields, dev_maj, dev_min, inode; + uint64_t min, max, offset; + char flag_r, flag_w, flag_x, flag_p; + char path[512] = ""; + fields = sscanf(line, "%"PRIx64"-%"PRIx64" %c%c%c%c %"PRIx64" %x:%x %d" + " %512s", &min, &max, &flag_r, &flag_w, &flag_x, + &flag_p, &offset, &dev_maj, &dev_min, &inode, path); + if ((fields < 10) || (fields > 11)) { + continue; + } + if (!strncmp(path, "[stack]", 7)) { + continue; + } + if (h2g_valid(min) && h2g_valid(max)) { + dprintf(fd, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx + " %c%c%c%c %08" PRIx64 " %02x:%02x %d%s%s\n", + h2g(min), h2g(max), flag_r, flag_w, + flag_x, flag_p, offset, dev_maj, dev_min, inode, + path[0] ? " " : "", path); + } + } + + free(line); + fclose(fp); + +#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n", (unsigned long long)ts->info->stack_limit, (unsigned long long)(ts->stack_base + (TARGET_PAGE_SIZE - 1)) & TARGET_PAGE_MASK, - (unsigned long long)ts->stack_base); + (unsigned long long)0); +#endif return 0; } @@ -5045,11 +5085,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, NULL, NULL, 0); } thread_env = NULL; -#ifdef ENV_GET_CPU object_delete(OBJECT(ENV_GET_CPU(cpu_env))); -#else - g_free(cpu_env); -#endif g_free(ts); pthread_exit(NULL); } |