From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27477 invoked by alias); 8 Oct 2008 08:32:31 -0000 Received: (qmail 27442 invoked by uid 22791); 8 Oct 2008 08:32:25 -0000 X-Spam-Check-By: sourceware.org Received: from nskntmtas05p.mx.bigpond.com (HELO nskntmtas05p.mx.bigpond.com) (61.9.168.149) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Oct 2008 08:31:42 +0000 Received: from nskntotgx02p.mx.bigpond.com ([121.209.36.216]) by nskntmtas05p.mx.bigpond.com with ESMTP id <20081008083135.YFJO19244.nskntmtas05p.mx.bigpond.com@nskntotgx02p.mx.bigpond.com>; Wed, 8 Oct 2008 08:31:35 +0000 Received: from bubble.grove.modra.org ([121.209.36.216]) by nskntotgx02p.mx.bigpond.com with ESMTP id <20081008083134.HDTY1284.nskntotgx02p.mx.bigpond.com@bubble.grove.modra.org>; Wed, 8 Oct 2008 08:31:34 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 400B5170C654; Wed, 8 Oct 2008 19:01:34 +1030 (CST) Date: Wed, 08 Oct 2008 08:32:00 -0000 From: Alan Modra To: Jan Blunck Cc: binutils@sourceware.org Subject: Re: [PATCH] Fix assign_file_positions_for_load_sections() for STRIP_NONDEBUG Message-ID: <20081008083134.GA18564@bubble.grove.modra.org> Mail-Followup-To: Jan Blunck , binutils@sourceware.org References: <20081007163844.GB19803@T61> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081007163844.GB19803@T61> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-RPD-ScanID: Class unknown; VirusThreatLevel unknown, RefID str=0001.0A150202.48EC6FE6.0106,ss=1,fgs=0 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: 2008-10/txt/msg00098.txt.bz2 On Tue, Oct 07, 2008 at 06:38:44PM +0200, Jan Blunck wrote: > When objcopy is called with the option --only-keep-debug it might happen that > the first section in a load segment isn't marked for loading since it is > stripped. This doesn't mean that all section in a segment are not marked for > loading. [snip] Thanks for the analysis and patch. I'm committing this simpler version. * elf.c (assign_file_positions_for_load_sections): When checking a segment for contents, don't assume that a non-TLS nobits section must only be followed by nobits sections. Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.465 diff -u -p -r1.465 elf.c --- bfd/elf.c 3 Oct 2008 09:40:48 -0000 1.465 +++ bfd/elf.c 8 Oct 2008 07:43:51 -0000 @@ -4288,21 +4288,14 @@ assign_file_positions_for_load_sections elf_section_type (m->sections[i]) = SHT_NOBITS; /* Find out whether this segment contains any loadable - sections. If the first section isn't loadable, the same - holds for any other sections. */ - i = 0; - while (elf_section_type (m->sections[i]) == SHT_NOBITS) - { - /* If a segment starts with .tbss, we need to look - at the next section to decide whether the segment - has any loadable sections. */ - if ((elf_section_flags (m->sections[i]) & SHF_TLS) == 0 - || ++i >= m->count) - { - no_contents = TRUE; - break; - } - } + sections. */ + no_contents = TRUE; + for (i = 0; i < m->count; i++) + if (elf_section_type (m->sections[i]) != SHT_NOBITS) + { + no_contents = FALSE; + break; + } off_adjust = vma_page_aligned_bias (m->sections[0]->vma, off, align); off += off_adjust;