From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3047 invoked by alias); 13 Feb 2010 16:09:59 -0000 Received: (qmail 3031 invoked by uid 22791); 13 Feb 2010 16:09:58 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Feb 2010 16:09:52 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1DG9neT028117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 13 Feb 2010 11:09:49 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1DG9lh5012974 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 13 Feb 2010 11:09:48 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o1DG9kYl012742; Sat, 13 Feb 2010 17:09:46 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1DG9iWh012741; Sat, 13 Feb 2010 17:09:44 +0100 Date: Sat, 13 Feb 2010 16:09:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [patch] Extend PIC displacement check by minpagesize Message-ID: <20100213160944.GB6115@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00337.txt.bz2 Hi, this is a minor patch not blocking anything I just found while working on PIE. It just makes the PIC heuristics there a small bit more reliable. This is a dissected part from the original patch: [patch] Sanity check PIE displacement (like the PIC one) http://sourceware.org/ml/gdb-patches/2010-02/msg00000.html It is a follow-up to the change: [rfa] Fix detection of prelinked libraries on PPC http://sourceware.org/ml/gdb-patches/2007-07/msg00109.html http://sourceware.org/ml/gdb-cvs/2007-07/msg00055.html fc5294c8de7ee77ec3ed9e0ca2dff670d0e7789f One needs for a reproducibility Linux kernel with: # CONFIG_PPC_64K_PAGES is not set Verified on gdb.ppc64 it stil works for inferior.ppc32 + core.ppc32: minpagesize = 0x1000 align = 0xffff l_addr = 0xff8f000 l_dynaddr = 0xff9f648 dynaddr = 0xffa0648 l_dynaddr-dynaddr = 0xfffff000 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x0ff90000 0x0ff90000 0x0060c 0x0060c R E 0x10000 LOAD 0x00060c 0x0ffa060c 0x0ffa060c 0x0011c 0x00124 RW 0x10000 ELF_MINPAGESIZE is always at least 1 in bfd/*. No regressions on {ppc64-m32}-fedora12-linux-gnu (that is host=powerpc64-fedora12-linux-gnu target=powerpc-fedora12-linux-gnu) and on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. Thanks, Jan 2010-02-13 Jan Kratochvil * solib-svr4.c (LM_ADDR_CHECK): New variable minpagesize. Optionally initialize it from ELF BFD. Extend the prelink condition by it. --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -194,6 +194,7 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd) if (dynaddr + l_addr != l_dynaddr) { CORE_ADDR align = 0x1000; + CORE_ADDR minpagesize = align; if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) { @@ -206,6 +207,8 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd) for (i = 0; i < ehdr->e_phnum; i++) if (phdr[i].p_type == PT_LOAD && phdr[i].p_align > align) align = phdr[i].p_align; + + minpagesize = get_elf_backend_data (abfd)->minpagesize; } /* Turn it into a mask. */ @@ -230,9 +233,12 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd) mapping of the library may not actually happen on a 64k boundary! (In the usual case where (l_addr & align) == 0, this check is - equivalent to the possibly expected check above.) */ + equivalent to the possibly expected check above.) + + Even on PPC it must be zero-aligned at least for MINPAGESIZE. */ - if ((l_addr & align) == ((l_dynaddr - dynaddr) & align)) + if ((l_addr & (minpagesize - 1)) == 0 + && (l_addr & align) == ((l_dynaddr - dynaddr) & align)) { l_addr = l_dynaddr - dynaddr;