All of lore.kernel.org
 help / color / mirror / Atom feed
From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH 02/19] linux-user: save auxv length
Date: Fri,  3 Feb 2012 16:49:15 +0200	[thread overview]
Message-ID: <125b0f55b63d11518f7d17480c795697c98b9bd3.1328280144.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1328280144.git.riku.voipio@linaro.org>

From: Alexander Graf <agraf@suse.de>

We create our own AUXV segment on stack and save a pointer to it.
However we don't save the length of it, so any code that wants to
do anything useful with it later on has to walk it again.

Instead, let's remember the length of our AUXV segment. This
simplifies later uses by a lot.

(edited by Riku to apply to qemu HEAD)

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
 linux-user/elfload.c |   15 ++++-----------
 linux-user/qemu.h    |    1 +
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 845be8b..2fd4a93 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1245,6 +1245,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
                                    struct image_info *interp_info)
 {
     abi_ulong sp;
+    abi_ulong sp_auxv;
     int size;
     int i;
     abi_ulong u_rand_bytes;
@@ -1316,6 +1317,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
         sp -= n; put_user_ual(id, sp);          \
     } while(0)
 
+    sp_auxv = sp;
     NEW_AUX_ENT (AT_NULL, 0);
 
     /* There must be exactly DLINFO_ITEMS entries here.  */
@@ -1346,6 +1348,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
 #undef NEW_AUX_ENT
 
     info->saved_auxv = sp;
+    info->auxv_len = sp_auxv - sp;
 
     sp = loader_build_argptr(envc, argc, sp, p, 0);
     return sp;
@@ -2326,9 +2329,8 @@ static void fill_auxv_note(struct memelfnote *note, const TaskState *ts)
 {
     elf_addr_t auxv = (elf_addr_t)ts->info->saved_auxv;
     elf_addr_t orig_auxv = auxv;
-    abi_ulong val;
     void *ptr;
-    int i, len;
+    int len = ts->info->auxv_len;
 
     /*
      * Auxiliary vector is stored in target process stack.  It contains
@@ -2336,15 +2338,6 @@ static void fill_auxv_note(struct memelfnote *note, const TaskState *ts)
      * strictly necessary but we do it here for sake of completeness.
      */
 
-    /* find out length of the vector, AT_NULL is terminator */
-    i = len = 0;
-    do {
-        get_user_ual(val, auxv);
-        i += 2;
-        auxv += 2 * sizeof (elf_addr_t);
-    } while (val != AT_NULL);
-    len = i * sizeof (elf_addr_t);
-
     /* read in whole auxv vector and copy it to memelfnote */
     ptr = lock_user(VERIFY_READ, orig_auxv, len, 0);
     if (ptr != NULL) {
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 30e2abd..308dbc0 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -48,6 +48,7 @@ struct image_info {
         abi_ulong       code_offset;
         abi_ulong       data_offset;
         abi_ulong       saved_auxv;
+        abi_ulong       auxv_len;
         abi_ulong       arg_start;
         abi_ulong       arg_end;
 	int		personality;
-- 
1.7.5.4

  parent reply	other threads:[~2012-02-03 14:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 14:49 [Qemu-devel] [PULL] [PATCH 00/19] linux-user update riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 01/19] linux-user: stack_base is now mandatory on all targets riku.voipio
2012-02-08  9:46   ` Laurent Desnogues
2013-03-07 11:03     ` Laurent Desnogues
2013-03-11 15:00       ` Riku Voipio
2012-02-03 14:49 ` riku.voipio [this message]
2012-02-03 14:49 ` [Qemu-devel] [PATCH 03/19] linux-user: add open() hijack infrastructure riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 04/19] linux-user: fake /proc/self/maps riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 05/19] linux-user: fake /proc/self/stat riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 06/19] linux-user: fake /proc/self/auxv riku.voipio
2012-02-03 14:49 ` [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 14:49 ` [Qemu-devel] [PATCH 08/19] linux-user: add SO_PEERCRED support for getsockopt riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 09/19] linux-user: fix QEMU_STRACE=1 segfault riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 10/19] linux-user/strace.c: Correct errno printing for mmap etc riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 11/19] linux-user: fix wait* syscall status returns riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 12/19] linux-user: Allow NULL value pointer in setxattr and getxattr riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 13/19] linux-user/syscall.c: Implement f and l versions of set/get/removexattr riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 14/19] linux-user: Implement *listxattr syscalls riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 15/19] linux-user: Add default-configs for mipsn32[el] riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 16/19] linux-user: Add default configs for mips64[el] riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 17/19] linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32 riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 18/19] linux-user: Define TARGET_QEMU_ESIGRETURN for mips64 riku.voipio
2012-02-03 14:49 ` [Qemu-devel] [PATCH 19/19] linux-user: Fix sa_flags byte swaps for mips riku.voipio
2012-02-04 12:43 ` [Qemu-devel] [PULL] [PATCH 00/19] linux-user update Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2012-01-31  9:29 [Qemu-devel] [PATCH 00/19] Pending linux-user patches riku.voipio
2012-01-31  9:29 ` [Qemu-devel] [PATCH 02/19] linux-user: save auxv length riku.voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=125b0f55b63d11518f7d17480c795697c98b9bd3.1328280144.git.riku.voipio@linaro.org \
    --to=riku.voipio@linaro.org \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.