From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuoVh-00045Y-J4 for qemu-devel@nongnu.org; Thu, 04 Jul 2013 14:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UuoVd-0000tZ-Rc for qemu-devel@nongnu.org; Thu, 04 Jul 2013 14:44:05 -0400 Received: from mail-ea0-x22b.google.com ([2a00:1450:4013:c01::22b]:48195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UuoSQ-00085B-1g for qemu-devel@nongnu.org; Thu, 04 Jul 2013 14:40:42 -0400 Received: by mail-ea0-f171.google.com with SMTP id m14so1012229eaj.30 for ; Thu, 04 Jul 2013 11:40:41 -0700 (PDT) Sender: =?UTF-8?Q?Timo_Ter=C3=A4s?= Date: Thu, 4 Jul 2013 21:40:57 +0300 From: Timo Teras Message-ID: <20130704214057.24608d55@vostro> In-Reply-To: <1372942883-26110-1-git-send-email-timo.teras@iki.fi> References: <1372942883-26110-1-git-send-email-timo.teras@iki.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH] elfload: load PIE executables to right address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Timo =?UTF-8?Q?Ter=C3=A4s?= Cc: qemu-devel@nongnu.org On Thu, 4 Jul 2013 16:01:23 +0300 Timo Ter=C3=A4s wrote: > PIE images are ET_DYN images. Check first for pinterp_name to make > sure the main executable always is loaded to correct place. >=20 > See below for current behaviour of PIE executables: >=20 > Reserved 0x7f000000 bytes of guest address space > host mmap_min_addr=3D0x1000 > guest_base 0x7f7cb41d5000 > start end size prot > 0037f400-003fe400 0007f000 r-x > 003fe400-003ff400 00001000 --- > 003ff400-003fe400 fffff000 rw- > 003fe400-003ff400 00001000 --- > 003ff400-003ffc00 00000800 rw- > 003ffc00-003fec00 fffff000 r-x > 003fec00-003ffc00 00001000 --- > 003ffc00-0007f000 ffc7f400 rw- > start_brk 0x00000000 > end_code 0x7eff7ac0 > start_code 0x7eff7000 > start_data 0x7efffac0 > end_data 0x7efffc18 > start_stack 0x7eff6dc8 > brk 0x7efffc34 > entry 0x7e799b30 > 00000000-00005000 ---p 00000000 00:00 0 > 00005000-00015000 rw-p 00000000 00:00 0 > 00015000-7e77d000 ---p 00000000 00:00 0 > 7e77d000-7e7ec000 r-xp 00000000 68:03 14326298 /lib/libc.so > 7e7ec000-7e7f3000 ---p 00000000 00:00 0 > 7e7f3000-7e7f4000 rw-p 0006e000 68:03 14326298 /lib/libc.so > 7e7f4000-7e7f6000 rw-p 00000000 00:00 0 > 7e7f6000-7e7f7000 ---p 00000000 00:00 0 > 7e7f7000-7eff7000 rw-p 00000000 00:00 0 > 7eff7000-7eff8000 r-xp 00000000 68:03 9731305 /usr/bin/brk > 7eff8000-7efff000 ---p 00000000 00:00 0 > 7e7f7000-7eff7000 rw-p 00000000 00:00 0 [stack] >=20 > Showing how the main binary got loaded to wrong place. Forgot to mention. Due to the above, the brk is set wrong, and the application will be unable to allocate any memory. Making them practically unusable. I've done quick testing that with this patch applied, the PIE executables will have working brk(). - Timo