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


On Thu, May 27, 2004 at 09:42:34AM +0930, Alan Modra wrote:
> On Wed, May 26, 2004 at 08:46:52AM -0700, H. J. Lu wrote:
> > > objdump -n won't show SEC_EXCLUDE on SHT_GROUP sections now.
> 
> Hmm, I suppose it is better to leave SEC_EXCLUDE on SHT_GROUP sections,
> since they will be excluded from a final link.
> 
> > 	* elf.c (_bfd_elf_make_section_from_shdr): Undo the last
> > 	change.
> 
> OK.
> 
> > 	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Undo
> > 	the last change.
> 
> Not OK.  Make the condition match the one in lang_add_section, then it's
> OK.
> 
> > 	* ldlang.c (lang_add_section): Clear SEC_EXCLUDE on non-
> > 	SEC_DEBUGGING sections for relocatable link.
> 
> OK.
> 

I will check in this then.


H.J.
---
bfd/

2004-05-26  H.J. Lu  <hongjiu.lu@intel.com>

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

ld/

2004-05-26  H.J. Lu  <hongjiu.lu@intel.com>

	* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Clear
	SEC_EXCLUDE on non-SEC_DEBUGGING sections for relocatable link.
	* ldlang.c (lang_add_section): Likewise.

--- binutils/bfd/elf.c.exclude	2004-05-26 08:23:16.000000000 -0700
+++ binutils/bfd/elf.c	2004-05-26 08:29:32.000000000 -0700
@@ -697,7 +697,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
   if (hdr->sh_type != SHT_NOBITS)
     flags |= SEC_HAS_CONTENTS;
   if (hdr->sh_type == SHT_GROUP)
-    flags |= SEC_GROUP;
+    flags |= SEC_GROUP | SEC_EXCLUDE;
   if ((hdr->sh_flags & SHF_ALLOC) != 0)
     {
       flags |= SEC_ALLOC;
--- binutils/ld/emultempl/elf32.em.exclude	2004-05-26 08:21:22.000000000 -0700
+++ binutils/ld/emultempl/elf32.em	2004-05-26 22:34:48.479574799 -0700
@@ -1182,9 +1182,10 @@ gld${EMULATION_NAME}_place_orphan (lang_
 #define HAVE_SECTION(hold, name) \
 (hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL)
 
-  if (((s->flags & (SEC_EXCLUDE | SEC_GROUP)) != 0 && !link_info.relocatable)
-      || ((s->flags & (SEC_EXCLUDE | SEC_DEBUGGING))
-	  == (SEC_EXCLUDE | SEC_DEBUGGING)))
+  if (link_info.relocatable && (s->flags & SEC_DEBUGGING) == 0)
+    s->flags &= ~SEC_EXCLUDE;
+
+  if ((s->flags & SEC_EXCLUDE) != 0)
     {
       if (s->output_section == NULL)
 	s->output_section = bfd_abs_section_ptr;
--- binutils/ld/ldlang.c.exclude	2004-05-26 08:23:17.000000000 -0700
+++ binutils/ld/ldlang.c	2004-05-26 08:39:34.000000000 -0700
@@ -1169,29 +1169,20 @@ lang_add_section (lang_statement_list_ty
 
   flags = bfd_get_section_flags (section->owner, section);
 
-  discard = FALSE;
-
-  if (link_info.relocatable)
-    {
-      /* SEC_EXCLUDE is ignored when doing a relocatable link,
-	 except in the special case of debug info.  (See bfd/stabs.c)  */
-      if ((flags & SEC_DEBUGGING) == 0)
-	flags &= ~SEC_EXCLUDE;
-    }
-  else
-    {
-      /* SEC_GROUP sections should be dropped on a final link.  */
-      if ((flags & SEC_GROUP) != 0)
-	flags |= SEC_EXCLUDE;
+  /* SEC_EXCLUDE is ignored when doing a relocatable link, except in
+     the special case of debug info.  (See bfd/stabs.c)  */
+  if (link_info.relocatable && (flags & SEC_DEBUGGING) == 0)
+    {
+      flags &= ~SEC_EXCLUDE;
+
+      /* Write the modified flag back, to simplify later linker
+	 code.  */
+      if (section->owner != NULL)
+	bfd_set_section_flags (section->owner, section, flags);
     }
 
-  /* Write SEC_EXCLUDE flag back, to simplify later linker code.  */
-  if (section->owner != NULL)
-    bfd_set_section_flags (section->owner, section, flags);
-
   /* Discard sections marked with SEC_EXCLUDE.  */
-  if ((flags & SEC_EXCLUDE) != 0)
-    discard = TRUE;
+  discard = (flags & SEC_EXCLUDE) != 0;
 
   /* Discard input sections which are assigned to a section named
      DISCARD_SECTION_NAME.  */


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