From patchwork Wed Mar 2 16:14:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu CASTET X-Patchwork-Id: 85097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7BA99B70D8 for ; Thu, 3 Mar 2011 03:15:55 +1100 (EST) Received: from localhost ([127.0.0.1]:46428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuoiN-0005c0-On for incoming@patchwork.ozlabs.org; Wed, 02 Mar 2011 11:15:51 -0500 Received: from [140.186.70.92] (port=34403 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuohB-00058N-Ub for qemu-devel@nongnu.org; Wed, 02 Mar 2011 11:14:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PuohA-0002cN-Hd for qemu-devel@nongnu.org; Wed, 02 Mar 2011 11:14:37 -0500 Received: from smtp6-g21.free.fr ([212.27.42.6]:57487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Puoh9-0002bM-Vm for qemu-devel@nongnu.org; Wed, 02 Mar 2011 11:14:36 -0500 Received: from [192.168.0.3] (unknown [81.57.151.96]) by smtp6-g21.free.fr (Postfix) with ESMTP id 2E17E82509 for ; Wed, 2 Mar 2011 17:14:29 +0100 (CET) Message-ID: <4D6E6CE5.5020805@free.fr> Date: Wed, 02 Mar 2011 17:14:29 +0100 From: matthieu castet User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.23) Gecko/20090823 SeaMonkey/1.1.18 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.27.42.6 Subject: [Qemu-devel] [PATCH] allow to load android binary X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, Android binary start with a weird elf program header : the first one is of size 0 pointing to NULL addr. Ignore LOAD program where MemSiz is 0. Elf file type is EXEC (Executable file) Entry point 0xb0001000 There are 5 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x0000d4 0x00000000 0xb0000000 0x00000 0x00000 R 0x1000 LOAD 0x001000 0xb0001000 0xb0001000 0x073d4 0x073d4 R E 0x1000 LOAD 0x009000 0xb0009000 0xb0009000 0x0068c 0x0969c RW 0x1000 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0 EXIDX 0x00801c 0xb000801c 0xb000801c 0x003b8 0x003b8 R 0x4 Section to Segment mapping: Segment Sections... 00 01 .text .rodata .ARM.extab .ARM.exidx 02 .preinit_array .init_array .fini_array .ctors .data.rel.ro .got .data .bss 03 04 .ARM.exidx From 4d986b66e9ae04efeabde9ad73f60d3c2d6912f9 Mon Sep 17 00:00:00 2001 From: Matthieu CASTET Date: Wed, 2 Mar 2011 17:04:39 +0100 Subject: [PATCH] allow to load android binary Android binary start with a weird elf program header : the first one is of size 0 pointing to NULL addr. Ignore LOAD program where MemSiz is 0. Elf file type is EXEC (Executable file) Entry point 0xb0001000 There are 5 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x0000d4 0x00000000 0xb0000000 0x00000 0x00000 R 0x1000 LOAD 0x001000 0xb0001000 0xb0001000 0x073d4 0x073d4 R E 0x1000 LOAD 0x009000 0xb0009000 0xb0009000 0x0068c 0x0969c RW 0x1000 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0 EXIDX 0x00801c 0xb000801c 0xb000801c 0x003b8 0x003b8 R 0x4 Section to Segment mapping: Segment Sections... 00 01 .text .rodata .ARM.extab .ARM.exidx 02 .preinit_array .init_array .fini_array .ctors .data.rel.ro .got .data .bss 03 04 .ARM.exidx --- linux-user/elfload.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 33d776d..284f3be 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1201,7 +1201,7 @@ static void load_elf_image(const char *image_name, int image_fd, amount of memory to handle that. */ loaddr = -1, hiaddr = 0; for (i = 0; i < ehdr->e_phnum; ++i) { - if (phdr[i].p_type == PT_LOAD) { + if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz) { abi_ulong a = phdr[i].p_vaddr; if (a < loaddr) { loaddr = a; @@ -1301,7 +1301,7 @@ static void load_elf_image(const char *image_name, int image_fd, for (i = 0; i < ehdr->e_phnum; i++) { struct elf_phdr *eppnt = phdr + i; - if (eppnt->p_type == PT_LOAD) { + if (eppnt->p_type == PT_LOAD && eppnt->p_memsz) { abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em; int elf_prot = 0; -- 1.7.4.1