From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59089 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeEfp-0003Me-P2 for qemu-devel@nongnu.org; Wed, 28 Jul 2010 18:00:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeEfo-0007hd-Dg for qemu-devel@nongnu.org; Wed, 28 Jul 2010 18:00:25 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:50395) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeEfo-0007hV-9I for qemu-devel@nongnu.org; Wed, 28 Jul 2010 18:00:24 -0400 Received: by eyb6 with SMTP id 6so1598058eyb.4 for ; Wed, 28 Jul 2010 15:00:22 -0700 (PDT) Date: Thu, 29 Jul 2010 00:00:18 +0200 From: "Edgar E. Iglesias" Subject: Re: [Qemu-devel] [PATCH 11/12] linux-user: Extract load_elf_image from load_elf_interp. Message-ID: <20100728220017.GA14422@laped.lan> References: <1280251538-6860-1-git-send-email-rth@twiddle.net> <1280251538-6860-12-git-send-email-rth@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1280251538-6860-12-git-send-email-rth@twiddle.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org On Tue, Jul 27, 2010 at 10:25:37AM -0700, Richard Henderson wrote: > Moving toward a single copy of the elf binary loading code. > Fill in the details of the loaded image into a struct image_info. > > Adjust create_elf_tables to read from such structures instead > of from a collection of passed arguments. Don't return error > values from load_elf_interp; always exit(-1) with a message to > stderr. Collect elf_interpreter handling in load_elf_binary > to a common spot. > > Signed-off-by: Richard Henderson > --- > linux-user/elfload.c | 341 ++++++++++++++++++++++++------------------------- > 1 files changed, 167 insertions(+), 174 deletions(-) > > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > index 61167cd..8ff9b6a 100644 > --- a/linux-user/elfload.c > +++ b/linux-user/elfload.c > @@ -1079,11 +1079,9 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot) > } > > static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, > - struct elfhdr * exec, > - abi_ulong load_addr, > - abi_ulong load_bias, > - abi_ulong interp_load_addr, > - struct image_info *info) > + struct elfhdr *exec, > + struct image_info *info, > + struct image_info *interp_info) > { > abi_ulong sp; > int size; > @@ -1128,13 +1126,13 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, > NEW_AUX_ENT (AT_NULL, 0); > > /* There must be exactly DLINFO_ITEMS entries here. */ > - NEW_AUX_ENT(AT_PHDR, (abi_ulong)(load_addr + exec->e_phoff)); > + NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff)); > NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); > NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); > NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); > - NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_load_addr)); > + NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info->load_addr)); Hi Richard, I think this part breaks loading of statically linked ELFs (no interpreter). I beleive Linux sets AT_BASE to zero in those cases. Cheers