From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6465 invoked by alias); 21 Apr 2006 23:22:14 -0000 Received: (qmail 6457 invoked by uid 22791); 21 Apr 2006 23:22:13 -0000 X-Spam-Check-By: sourceware.org Received: from smtp108.sbc.mail.re2.yahoo.com (HELO smtp108.sbc.mail.re2.yahoo.com) (68.142.229.97) by sourceware.org (qpsmtpd/0.31) with SMTP; Fri, 21 Apr 2006 23:22:11 +0000 Received: (qmail 33238 invoked from network); 21 Apr 2006 23:22:10 -0000 Received: from unknown (HELO lucon.org) (hjjean@sbcglobal.net@75.0.171.244 with login) by smtp108.sbc.mail.re2.yahoo.com with SMTP; 21 Apr 2006 23:22:10 -0000 Received: by lucon.org (Postfix, from userid 1000) id 4C48064034; Fri, 21 Apr 2006 16:22:08 -0700 (PDT) Date: Sun, 23 Apr 2006 22:13:00 -0000 From: "H. J. Lu" To: Andrew STUBBS Cc: binutils@sources.redhat.com Subject: Re: Problem setting the CONTENTS flag Message-ID: <20060421232208.GA16651@lucon.org> References: <4448D6E0.2090907@st.com> <20060421143558.GA13559@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060421143558.GA13559@lucon.org> User-Agent: Mutt/1.4.2.1i Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00314.txt.bz2 On Fri, Apr 21, 2006 at 07:35:58AM -0700, H. J. Lu wrote: > On Fri, Apr 21, 2006 at 01:58:08PM +0100, Andrew STUBBS wrote: > > Hi all, > > > > I have encountered an error setting the CONTENTS and LOAD flags with > > relatively recent versions of objcopy/bfd. > > > > Could you please open a bug report with a simple testcase? This patch > should work. > > Thanks. > > Here is an updated patch. H.J. ---- 2006-04-21 H.J. Lu PR binutils/2593 * elf.c (_bfd_elf_new_section_hook): Don't set section ELF type and flags if its BFD flags has been set. (_bfd_elf_init_private_section_data): Don't copy the output ELF section type from input if it has been set to something different. --- bfd/elf.c.copy 2006-04-21 07:00:02.000000000 -0700 +++ bfd/elf.c 2006-04-21 16:15:41.000000000 -0700 @@ -2487,10 +2487,11 @@ _bfd_elf_new_section_hook (bfd *abfd, as bed = get_elf_backend_data (abfd); sec->use_rela_p = bed->default_use_rela_p; - /* When we read a file, we don't need section type and flags unless - it is a linker created section. They will be overridden in - _bfd_elf_make_section_from_shdr anyway. */ - if (abfd->direction != read_direction + /* When we read a file or section BFD flags have been set, we don't + need section type and flags unless it is a linker created section. + They will be overridden in _bfd_elf_make_section_from_shdr + anyway. */ + if ((!sec->flags && abfd->direction != read_direction) || (sec->flags & SEC_LINKER_CREATED) != 0) { ssect = (*bed->get_sec_type_attr) (abfd, sec); @@ -5906,9 +5907,9 @@ _bfd_elf_init_private_section_data (bfd || obfd->xvec->flavour != bfd_target_elf_flavour) return TRUE; - /* FIXME: What if the output ELF section type has been set to - something different? */ - if (elf_section_type (osec) == SHT_NULL) + /* Don't copy the output ELF section type from input if it has been + set to something different. */ + if (osec->flags == isec->flags || !osec->flags) elf_section_type (osec) = elf_section_type (isec); /* Set things up for objcopy and relocatable link. The output