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: Fwd: Problems with -ffunction-sections


On Tue, Jul 09, 2002 at 02:13:24PM +0930, Alan Modra wrote:
> It's a SEC_MERGE section, which is why sym_sec->output_section is
> set to bfd_abs_section.  I'll bet this problem affects binutils all
> over the place.  :-(

This (_bfd_merge_sections patch, the rest is cosmetic) should fix the
problem, although I can't test at the moment as gsyprf11 seems to be
down.  When SEC_EXCLUDE is set on an input section, its output section
is mapped to bfd_abs_section rather than the normal output.  I can't
see any reason why a zero length section mapped to its normal output
should cause any woe.

	* merge.c (_bfd_merge_section): Remove redundant output_section check.
	Formatting.
	(_bfd_merge_sections): Don't set SEC_EXCLUDE on unused sections.

Index: bfd/merge.c
===================================================================
RCS file: /cvs/src/src/bfd/merge.c,v
retrieving revision 1.12
diff -u -p -r1.12 merge.c
--- bfd/merge.c	4 Jul 2002 15:57:24 -0000	1.12
+++ bfd/merge.c	9 Jul 2002 07:18:56 -0000
@@ -383,14 +383,6 @@ _bfd_merge_section (abfd, psinfo, sec, p
       return true;
     }
 
-  if (sec->output_section != NULL
-      && bfd_is_abs_section (sec->output_section))
-    {
-      /* The section is being discarded from the link, so we should
-	 just ignore it.  */
-      return true;
-    }
-
   align = bfd_get_section_alignment (sec->owner, sec);
   if ((sec->entsize < (unsigned int)(1 << align)
        && ((sec->entsize & (sec->entsize - 1))
@@ -417,15 +409,14 @@ _bfd_merge_section (abfd, psinfo, sec, p
   if (sinfo == NULL)
     {
       /* Initialize the information we need to keep track of.  */
-      sinfo = (struct sec_merge_info *)
-	      bfd_alloc (abfd, (bfd_size_type) sizeof (struct sec_merge_info));
+      amt = sizeof (struct sec_merge_info);
+      sinfo = (struct sec_merge_info *) bfd_alloc (abfd, amt);
       if (sinfo == NULL)
 	goto error_return;
       sinfo->next = (struct sec_merge_info *) *psinfo;
       sinfo->chain = NULL;
       *psinfo = (PTR) sinfo;
-      sinfo->htab =
-	sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS));
+      sinfo->htab = sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS));
       if (sinfo->htab == NULL)
 	goto error_return;
     }
@@ -843,10 +834,7 @@ _bfd_merge_sections (abfd, xsinfo, remov
 	   the hash table at all.  */
 	for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
   	  if (secinfo->first == NULL)
-	    {
-	      secinfo->sec->_cooked_size = 0;
-	      secinfo->sec->flags |= SEC_EXCLUDE;
-	    }
+	    secinfo->sec->_cooked_size = 0;
     }
 
   return true;


-- 
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]