This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Pass section name to elf_backend_section_flags


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:

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.221
diff -u -p -r1.221 elf.c
--- bfd/elf.c	22 Apr 2004 14:45:31 -0000	1.221
+++ bfd/elf.c	26 Apr 2004 11:44:12 -0000
@@ -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;
@@ -797,9 +800,6 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 	    }
 	}
     }
-
-  hdr->bfd_section = newsect;
-  elf_section_data (newsect)->this_hdr = *hdr;
 
   return TRUE;
 }

which makes the section name available to elf_backend_section_flags.
Also, make the hdr arg to elf_backend_section_flags const.  If testing
shows the patch is ok, consider this approach pre-approved for
mainline.  I've had a look at the effect of setting hdr->bfd_section
early, (ie. before we know the function is going to succeed) and can't
see any problem with doing that, or any need to clean up if we fail for
some reason.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]