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: .stabstr listed as discarded


On Mon, Oct 16, 2006 at 08:47:22PM +0100, John Parkes wrote:
> Should section  .stabstr be listed in the discarded input sections of
> the map ?

Probably not.  Their contents are not discarded, just merged with like
sections.  The same goes for a number of other sections.

bfd/
	* section.c (SEC_KEEP): Update comment.
	* bfd-in2.h: Regenerate.
	* elflink.c (bfd_elf_gc_sections): Ignore SEC_EXCLUDE sections.
	* merge.c (_bfd_merge_sections): Set SEC_KEEP on excluded sections.
	* stabs.c (_bfd_discard_section_stabs): Likewise.
	(_bfd_link_section_stabs): Likewise.  Simplify abs_section check.

ld/
	* ldlang.c (lang_map): Don't say SEC_LINKER_CREATED and SEC_KEEP
	sections have been discarded.
	(lang_do_version_exports_section): Set SEC_KEEP on export section.
	* emultempl/elf32.em (before_allocation): Set SEC_KEEP on warning
	sections.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.235
diff -u -p -r1.235 elflink.c
--- bfd/elflink.c	19 Oct 2006 02:40:13 -0000	1.235
+++ bfd/elflink.c	27 Oct 2006 02:45:12 -0000
@@ -9794,7 +9794,7 @@ bfd_elf_gc_sections (bfd *abfd, struct b
 	continue;
 
       for (o = sub->sections; o != NULL; o = o->next)
-	if ((o->flags & SEC_KEEP) != 0 && !o->gc_mark)
+	if ((o->flags & (SEC_EXCLUDE | SEC_KEEP)) == SEC_KEEP && !o->gc_mark)
 	  if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
 	    return FALSE;
     }
Index: bfd/merge.c
===================================================================
RCS file: /cvs/src/src/bfd/merge.c,v
retrieving revision 1.29
diff -u -p -r1.29 merge.c
--- bfd/merge.c	16 Mar 2006 12:20:16 -0000	1.29
+++ bfd/merge.c	27 Oct 2006 02:45:12 -0000
@@ -766,7 +766,7 @@ _bfd_merge_sections (bfd *abfd ATTRIBUTE
 	   the hash table at all.  */
 	for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
 	  if (secinfo->first_str == NULL)
-	    secinfo->sec->flags |= SEC_EXCLUDE;
+	    secinfo->sec->flags |= SEC_EXCLUDE | SEC_KEEP;
     }
 
   return TRUE;
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.92
diff -u -p -r1.92 section.c
--- bfd/section.c	3 May 2006 14:26:39 -0000	1.92
+++ bfd/section.c	27 Oct 2006 02:45:13 -0000
@@ -294,7 +294,9 @@ CODE_FRAGMENT
 .     else up the line will take care of it later.  *}
 .#define SEC_LINKER_CREATED 0x200000
 .
-.  {* This section should not be subject to garbage collection.  *}
+.  {* This section should not be subject to garbage collection.
+.     Also set to inform the linker that this section should not be
+.     listed in the link map as discarded.  *}
 .#define SEC_KEEP 0x400000
 .
 .  {* This section contains "short" data, and should be placed
Index: bfd/stabs.c
===================================================================
RCS file: /cvs/src/src/bfd/stabs.c,v
retrieving revision 1.27
diff -u -p -r1.27 stabs.c
--- bfd/stabs.c	1 Jun 2006 03:45:58 -0000	1.27
+++ bfd/stabs.c	27 Oct 2006 03:17:10 -0000
@@ -175,10 +175,8 @@ _bfd_link_section_stabs (bfd *abfd,
        prepared to handle them.  */
     return TRUE;
 
-  if ((stabsec->output_section != NULL
-       && bfd_is_abs_section (stabsec->output_section))
-      || (stabstrsec->output_section != NULL
-	  && bfd_is_abs_section (stabstrsec->output_section)))
+  if (bfd_is_abs_section (stabsec->output_section)
+      || bfd_is_abs_section (stabstrsec->output_section))
     /* At least one of the sections is being discarded from the
        link, so we should just ignore them.  */
     return TRUE;
@@ -433,7 +431,7 @@ _bfd_link_section_stabs (bfd *abfd,
 		    ++nest;
 		  else if (incl_type == (int) N_EXCL)
 		    /* Keep existing exclusion marks.  */
-		    continue;   
+		    continue;
 		  else if (nest == 0)
 		    {
 		      *incl_pstridx = (bfd_size_type) -1;
@@ -458,8 +456,8 @@ _bfd_link_section_stabs (bfd *abfd,
      for that section.  */
   stabsec->size = (count - skip) * STABSIZE;
   if (stabsec->size == 0)
-    stabsec->flags |= SEC_EXCLUDE;
-  stabstrsec->flags |= SEC_EXCLUDE;
+    stabsec->flags |= SEC_EXCLUDE | SEC_KEEP;
+  stabstrsec->flags |= SEC_EXCLUDE | SEC_KEEP;
   sinfo->stabstr->size = _bfd_stringtab_size (sinfo->strings);
 
   /* Calculate the `cumulative_skips' array now that stabs have been
@@ -611,7 +609,7 @@ _bfd_discard_section_stabs (bfd *abfd,
   /* Shrink the stabsec as needed.  */
   stabsec->size -= skip * STABSIZE;
   if (stabsec->size == 0)
-    stabsec->flags |= SEC_EXCLUDE;
+    stabsec->flags |= SEC_EXCLUDE | SEC_KEEP;
 
   /* Recalculate the `cumulative_skips' array now that stabs have been
      deleted for this section.  */
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.244
diff -u -p -r1.244 ldlang.c
--- ld/ldlang.c	25 Oct 2006 06:49:21 -0000	1.244
+++ ld/ldlang.c	27 Oct 2006 02:45:37 -0000
@@ -1736,8 +1736,9 @@ lang_map (void)
 	continue;
 
       for (s = file->the_bfd->sections; s != NULL; s = s->next)
-	if (s->output_section == NULL
-	    || s->output_section->owner != output_bfd)
+	if ((s->output_section == NULL
+	     || s->output_section->owner != output_bfd)
+	    && (s->flags & (SEC_LINKER_CREATED | SEC_KEEP)) == 0)
 	  {
 	    if (! dis_header_printed)
 	      {
@@ -6922,7 +6923,7 @@ lang_do_version_exports_section (void)
       /* Do not free the contents, as we used them creating the regex.  */
 
       /* Do not include this section in the link.  */
-      sec->flags |= SEC_EXCLUDE;
+      sec->flags |= SEC_EXCLUDE | SEC_KEEP;
     }
 
   lreg = lang_new_vers_pattern (NULL, "*", NULL, FALSE);
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.171
diff -u -p -r1.171 elf32.em
--- ld/emultempl/elf32.em	16 Sep 2006 18:12:16 -0000	1.171
+++ ld/emultempl/elf32.em	27 Oct 2006 02:45:39 -0000
@@ -1214,7 +1214,7 @@ ${ELF_INTERPRETER_SET_DEFAULT}
 
 	/* Also set SEC_EXCLUDE, so that symbols defined in the warning
 	   section don't get copied to the output.  */
-	s->flags |= SEC_EXCLUDE;
+	s->flags |= SEC_EXCLUDE | SEC_KEEP;
       }
   }
 


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