From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28350 invoked by alias); 26 Apr 2004 15:29:04 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 28343 invoked from network); 26 Apr 2004 15:29:03 -0000 Received: from unknown (HELO sccrmhc13.comcast.net) (204.127.202.64) by sources.redhat.com with SMTP; 26 Apr 2004 15:29:03 -0000 Received: from lucon.org ([24.6.43.109]) by comcast.net (sccrmhc13) with ESMTP id <2004042615290201600d5r2be>; Mon, 26 Apr 2004 15:29:02 +0000 Received: by lucon.org (Postfix, from userid 1000) id 24D8B64CFF; Mon, 26 Apr 2004 08:29:01 -0700 (PDT) Date: Mon, 26 Apr 2004 18:38:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: Re: PATCH: Pass section name to elf_backend_section_flags Message-ID: <20040426152901.GA13923@lucon.org> References: <20040423191455.GA3925@lucon.org> <20040426115242.GA2615@bubble.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040426115242.GA2615@bubble.modra.org> User-Agent: Mutt/1.4.1i X-SW-Source: 2004-04/txt/msg00698.txt.bz2 On Mon, Apr 26, 2004 at 09:22:42PM +0930, Alan Modra wrote: > On Fri, Apr 23, 2004 at 12:14:55PM -0700, H. J. Lu wrote: > > This patch removes one FIXME in ELF linker. > > Thanks for looking at FIXMEs :) > > > * elf-bfd.h (elf_backend_section_flags): Also take section > > name. > > * elf64-alpha.c (elf64_alpha_section_flags): Updated. > > * elfxx-ia64.c (elfNN_ia64_section_flags): Likewise. > > > > * elf.c (_bfd_elf_make_section_from_shdr): Pass section name > > to elf_backend_section_flags. > > > > * elf32-sh64.c (elf_backend_section_flags): New. Defined. > > (sh64_elf_set_mach_from_flags): Remove the kludge for .cranges > > section. > > (sh64_elf_section_flags): New. Set SEC_DEBUGGING for > > .cranges section. > > I suggest instead that you move the assignment to hdr->bfd_section like > this: > How about this patch? H.J. ---- 2004-04-26 H.J. Lu * elf32-sh64.c (elf_backend_section_flags): New. Defined. (sh64_elf_set_mach_from_flags): Remove the kludge for .cranges section. (sh64_elf_section_flags): New. Set SEC_DEBUGGING for .cranges section. 2004-04-26 Alan Modra * elf.c (_bfd_elf_make_section_from_shdr): Set the bfd_section field before calling elf_backend_section_flags. --- bfd/elf.c.section 2004-04-26 08:02:32.000000000 -0700 +++ bfd/elf.c 2004-04-26 08:02:56.000000000 -0700 @@ -652,6 +652,9 @@ _bfd_elf_make_section_from_shdr (bfd *ab if (newsect == NULL) return FALSE; + hdr->bfd_section = newsect; + elf_section_data (newsect)->this_hdr = *hdr; + /* Always use the real type/flags. */ elf_section_type (newsect) = hdr->sh_type; elf_section_flags (newsect) = hdr->sh_flags; @@ -798,9 +801,6 @@ _bfd_elf_make_section_from_shdr (bfd *ab } } - hdr->bfd_section = newsect; - elf_section_data (newsect)->this_hdr = *hdr; - return TRUE; } --- bfd/elf32-sh64.c.flags 2004-03-26 08:36:25.000000000 -0800 +++ bfd/elf32-sh64.c 2004-04-26 08:12:09.000000000 -0700 @@ -89,6 +89,7 @@ static void sh64_find_section_for_addres #define elf_backend_final_write_processing sh64_elf_final_write_processing #define elf_backend_section_from_shdr sh64_backend_section_from_shdr #define elf_backend_special_sections sh64_elf_special_sections +#define elf_backend_section_flags sh64_elf_section_flags #define bfd_elf32_new_section_hook sh64_elf_new_section_hook @@ -149,7 +150,6 @@ static bfd_boolean sh64_elf_set_mach_from_flags (bfd *abfd) { flagword flags = elf_elfheader (abfd)->e_flags; - asection *cranges; switch (flags & EF_SH_MACH_MASK) { @@ -164,18 +164,19 @@ sh64_elf_set_mach_from_flags (bfd *abfd) return FALSE; } - /* We also need to set SEC_DEBUGGING on an incoming .cranges section. - We could have used elf_backend_section_flags if it had given us the - section name; the bfd_section member in the header argument is not - set at the point of the call. FIXME: Find out whether that is by - undocumented design or a bug. */ - cranges = bfd_get_section_by_name (abfd, SH64_CRANGES_SECTION_NAME); - if (cranges != NULL - && ! bfd_set_section_flags (abfd, cranges, - bfd_get_section_flags (abfd, cranges) - | SEC_DEBUGGING)) + return TRUE; +} + +static bfd_boolean +sh64_elf_section_flags (flagword *flags, + Elf_Internal_Shdr *hdr) +{ + if (hdr->bfd_section == NULL) return FALSE; + if (strcmp (hdr->bfd_section->name, SH64_CRANGES_SECTION_NAME) == 0) + *flags |= SEC_DEBUGGING; + return TRUE; }