This is the mail archive of the binutils@sourceware.org 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: _bfd_elf_init_private_section_data setting output section type improperly for .stabstr


On Thu, May 11, 2006 at 10:10:53AM -0700, H. J. Lu wrote:
> On Thu, May 11, 2006 at 09:45:41PM +0930, Alan Modra wrote:
> > On Wed, May 10, 2006 at 09:32:22PM -0700, Mike Bland wrote:
> > > Long and short of it, an update to this conditional in
> > > _bfd_elf_init_private_section_data was causing the section type of
> > > .stabstr to get set to SHT_PROGBITS, when it should have been
> > > SHT_STRTAB.
> > 
> > Yes, it appears that HJ checked this change in without approval.
> > 
> > > Hope this is in an acceptable format; let me know if there are any
> > > problems, questions, concerns, etc.
> > 
> > We normally want a changelog entry, and the testcase needed a little
> > teaking for 64-bit targets but other than that this is OK.  Thanks!
> > Committing.
> > 
> 
> Unfortunately, the fix is incorrect. The ELF backend creates a
> .stabstr section. But _bfd_link_section_stabs creates a new
> .stabstr section. When linker sets the output .stabstr section flags
> from the input .stabstr section, the wrong input .stabstr section
> is used. This patch makes sure that only one .stabstr section is used.
> 

bfd_make_section_anyway is used to create a new fake input .stabstr
section. The SEC_LINKER_CREATED bit should be passed to
_bfd_elf_new_section_hook so that the proper ELF fields will be
set. This patch calls bfd_make_section_anyway_with_flags so that
the ELF fields of the new fake input .stabstr section will be set
properly.


H.J.
---
2006-05-11  H.J. Lu  <hongjiu.lu@intel.com>

	* elf.c (_bfd_elf_init_private_section_data): Undo the last
	change.

	* stabs.c (_bfd_link_section_stabs): Call
	bfd_make_section_anyway_with_flags instead of
	bfd_make_section_anyway.

--- bfd/elf.c.stabs	2006-05-11 08:52:56.000000000 -0700
+++ bfd/elf.c	2006-05-11 09:26:36.000000000 -0700
@@ -5911,8 +5911,7 @@ _bfd_elf_init_private_section_data (bfd 
      output BFD section flags has been set to something different.
      elf_fake_sections will set ELF section type based on BFD
      section flags.  */
-  if (osec->flags == isec->flags
-      || (osec->flags == 0 && elf_section_type (osec) == SHT_NULL))
+  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
--- bfd/stabs.c.stabs	2006-03-16 12:37:43.000000000 -0800
+++ bfd/stabs.c	2006-05-11 11:53:54.000000000 -0700
@@ -198,11 +198,14 @@ _bfd_link_section_stabs (bfd *abfd,
 				 stab_link_includes_newfunc,
 				 sizeof (struct stab_link_includes_entry)))
 	goto error_return;
-      sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
+      sinfo->stabstr = bfd_make_section_anyway_with_flags (abfd,
+							   ".stabstr",
+							   (SEC_HAS_CONTENTS
+							    | SEC_READONLY
+							    | SEC_DEBUGGING |
+							    SEC_LINKER_CREATED));
       if (sinfo->stabstr == NULL)
 	goto error_return;
-      sinfo->stabstr->flags |= (SEC_HAS_CONTENTS | SEC_READONLY
-				| SEC_DEBUGGING | SEC_LINKER_CREATED);
     }
 
   /* Initialize the information we are going to store for this .stab


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