From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1296 invoked by alias); 25 Feb 2011 07:49:35 -0000 Received: (qmail 1287 invoked by uid 22791); 25 Feb 2011 07:49:33 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iw0-f169.google.com (HELO mail-iw0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Feb 2011 07:49:29 +0000 Received: by iwl42 with SMTP id 42so1122126iwl.0 for ; Thu, 24 Feb 2011 23:49:27 -0800 (PST) Received: by 10.42.241.10 with SMTP id lc10mr423463icb.482.1298620167216; Thu, 24 Feb 2011 23:49:27 -0800 (PST) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id i2sm242059icv.3.2011.02.24.23.49.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Feb 2011 23:49:24 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 3F86316DE62A; Fri, 25 Feb 2011 18:19:17 +1030 (CST) Date: Fri, 25 Feb 2011 07:49:00 -0000 From: Alan Modra To: "H.J. Lu" Cc: Andreas Schwab , David Stubbs , binutils@sourceware.org Subject: Re: VMA section overlap warnings for overlays Message-ID: <20110225074917.GB5959@bubble.grove.modra.org> Mail-Followup-To: "H.J. Lu" , Andreas Schwab , David Stubbs , binutils@sourceware.org References: <20100715141753.GI31087@bubble.grove.modra.org> <20100716093630.GN31087@bubble.grove.modra.org> <20100720054451.GF19525@bubble.grove.modra.org> <20100720141031.GI19525@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00302.txt.bz2 On Thu, Feb 24, 2011 at 03:49:25PM -0800, H.J. Lu wrote: > On Tue, Jul 20, 2010 at 7:10 AM, Alan Modra wrote: > > This removes all the special treatment for zero size sections when > > using ELF_SECTION_IN_SEGMENT in elf.c, and makes readelf display [snip] > This may have caused: > > http://sourceware.org/bugzilla/show_bug.cgi?id=12516 Yes, looks like it. PR 12519 * internal.h (ELF_SECTION_IN_SEGMENT_1): Don't match zero size sections at start or end of PT_DYNAMIC. Index: include/elf/internal.h =================================================================== RCS file: /cvs/src/src/include/elf/internal.h,v retrieving revision 1.26 diff -u -p -r1.26 internal.h --- include/elf/internal.h 20 Jul 2010 14:08:30 -0000 1.26 +++ include/elf/internal.h 25 Feb 2011 04:28:30 -0000 @@ -302,7 +302,9 @@ struct elf_segment_map /* Decide if the section SEC_HDR is in SEGMENT. If CHECK_VMA, then VMAs are checked for alloc sections. If STRICT, then a zero size section won't match at the end of a segment, unless the segment - is also zero size. */ + is also zero size. Regardless of STRICT and CHECK_VMA, zero size + sections won't match at the start or end of PT_DYNAMIC, unless + PT_DYNAMIC is itself zero sized. */ #define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma, strict) \ ((/* Only PT_LOAD, PT_GNU_RELRO and PT_TLS segments can contain \ SHF_TLS sections. */ \ @@ -334,7 +336,19 @@ struct elf_segment_map <= (segment)->p_memsz - 1)) \ && (((sec_hdr)->sh_addr - (segment)->p_vaddr \ + ELF_SECTION_SIZE(sec_hdr, segment)) \ - <= (segment)->p_memsz)))) + <= (segment)->p_memsz))) \ + /* No zero size sections at start or end of PT_DYNAMIC. */ \ + && ((segment)->p_type != PT_DYNAMIC \ + || (sec_hdr)->sh_size != 0 \ + || (segment)->p_memsz == 0 \ + || (((sec_hdr)->sh_type == SHT_NOBITS \ + || ((bfd_vma) (sec_hdr)->sh_offset > (segment)->p_offset \ + && ((sec_hdr)->sh_offset - (segment)->p_offset \ + < (segment)->p_filesz))) \ + && (((sec_hdr)->sh_flags & SHF_ALLOC) == 0 \ + || ((sec_hdr)->sh_addr > (segment)->p_vaddr \ + && ((sec_hdr)->sh_addr - (segment)->p_vaddr \ + < (segment)->p_memsz)))))) #define ELF_SECTION_IN_SEGMENT(sec_hdr, segment) \ (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 0)) -- Alan Modra Australia Development Lab, IBM