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: Linker is broken again


On Fri, May 28, 2004 at 03:33:06PM -0700, H. J. Lu wrote:
> Alan, linker is broken again. ld -r no longer preserves section group.

Yes, I'm a numbskull.  lang_gc_sections only looks at sections
mentioned in the link script, and so misses orphans.

	* ldlang.c (gc_section_callback): Move SEC_EXCLUDE twiddles..
	(lang_gc_sections): .. to a LANG_FOR_EACH_INPUT_STATEMENT loop here.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.152
diff -u -p -r1.152 ldlang.c
--- ld/ldlang.c	28 May 2004 10:34:17 -0000	1.152
+++ ld/ldlang.c	29 May 2004 03:56:14 -0000
@@ -4272,12 +4272,6 @@ gc_section_callback (lang_wild_statement
 		     lang_input_statement_type *file ATTRIBUTE_UNUSED,
 		     void *data ATTRIBUTE_UNUSED)
 {
-  /* SEC_EXCLUDE is ignored when doing a relocatable link, except in
-     the special case of debug info.  (See bfd/stabs.c)
-     Twiddle the flag here, to simplify later linker code.  */
-  if (link_info.relocatable && (section->flags & SEC_DEBUGGING) == 0)
-    section->flags &= ~SEC_EXCLUDE;
-
   /* If the wild pattern was marked KEEP, the member sections
      should be as well.  */
   if (ptr->keep_sections)
@@ -4338,6 +4332,20 @@ lang_gc_sections (void)
 	}
     }
 
+  /* SEC_EXCLUDE is ignored when doing a relocatable link, except in
+     the special case of debug info.  (See bfd/stabs.c)
+     Twiddle the flag here, to simplify later linker code.  */
+  if (link_info.relocatable)
+    {
+      LANG_FOR_EACH_INPUT_STATEMENT (f)
+	{
+	  asection *sec;
+	  for (sec = f->the_bfd->sections; sec != NULL; sec = sec->next)
+	    if ((sec->flags & SEC_DEBUGGING) == 0)
+	      sec->flags &= ~SEC_EXCLUDE;
+	}
+    }
+
   if (command_line.gc_sections)
     bfd_gc_sections (output_bfd, &link_info);
 }

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