From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29786 invoked by alias); 25 Apr 2006 15:21:02 -0000 Received: (qmail 29778 invoked by uid 22791); 25 Apr 2006 15:21:01 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Apr 2006 15:20:59 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k3PFKv1D014463; Tue, 25 Apr 2006 11:20:57 -0400 Received: from pobox.surrey.redhat.com (pobox.surrey.redhat.com [172.16.10.17]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.11.6) with ESMTP id k3PFKu97027372; Tue, 25 Apr 2006 11:20:56 -0400 Received: from [10.32.68.9] (vpn-68-9.surrey.redhat.com [10.32.68.9]) by pobox.surrey.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k3PFKslJ008086; Tue, 25 Apr 2006 16:20:54 +0100 Message-ID: <444E3E55.2080308@redhat.com> Date: Tue, 25 Apr 2006 16:37:00 -0000 From: Nick Clifton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: "H. J. Lu" CC: Andrew STUBBS , binutils@sources.redhat.com Subject: Re: Problem setting the CONTENTS flag References: <4448D6E0.2090907@st.com> <20060421143558.GA13559@lucon.org> <20060421232208.GA16651@lucon.org> In-Reply-To: <20060421232208.GA16651@lucon.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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/msg00335.txt.bz2 HI H.J. > Here is an updated patch. There are a couple of minor problems with this version of the patch: > + /* 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) I think that the comment could be reworded to be clearer. For example: A section without any flags or with the SEC_LINKER_CREATED flag must have its type and other flags set. Skip this for sections with no flags that have been read in, as this state must have been requested by the user, and it will be overridden by _bfd_elf_make_section_from_shdr anyway. > - /* 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); A section's type is not determined by its flags. Therefore it seems to be counter-intuitive to be testing the flags when we are concerned about the type. Also what happens if the output sections flags have been set to something other than the input section's flags, but the output section's type is SHT_NULL ? According to the ELF spec this would mean that the flags are undefined as well. I think that for this part of the patch the comment ought to be reworded and you ought to test for SHT_NULL and either change it or issue an error message. eg: /* Copy the output ELF section type from the input section type if the output section flags were copied from the input, or if the output section has no type or flags. */ if (osec->flags == isec->flags || osec->flags == 0 || elf_section_type (osec) == SHT_NULL) elf_section_type (osec) = elf_section_type (isec); Cheers Nick