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]

PATCH: Report locations for mixed ordered and unordered sections


When there are mixed ordered and unordered sections in input, ld
reports:

ld: .IA_64.unwind has both ordered and unordered sections
ld: final link failed: Bad value

It isn't very helpful. This patch changes it to

./ld: .IA_64.unwind has both ordered [`.IA_64.unwind' in obj/libnast.a(ztype.o)] and unordered [`.IA_64.unwind' in obj/libnast.a(cknec_ia64.o)] sections
./ld: final link failed: Bad value

We should also stop as soon as mixed input sections are found.

H.J.
----
2005-09-08  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (elf_fixup_link_order): Report locations for mixed
	ordered and unordered input sections.

--- bfd/elflink.c.order	2005-09-08 10:51:48.000000000 -0700
+++ bfd/elflink.c	2005-09-08 22:14:05.000000000 -0700
@@ -7708,41 +7708,54 @@ elf_fixup_link_order (bfd *abfd, asectio
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
   int elfsec;
   struct bfd_link_order **sections;
-  asection *s;
+  asection *s, *other_sec, *linkorder_sec;
   bfd_vma offset;
 
+  other_sec = NULL;
+  linkorder_sec = NULL;
   seen_other = 0;
   seen_linkorder = 0;
   for (p = o->map_head.link_order; p != NULL; p = p->next)
     {
-      if (p->type == bfd_indirect_link_order
-	  && (bfd_get_flavour ((sub = p->u.indirect.section->owner))
-	      == bfd_target_elf_flavour)
-	  && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass)
+      if (p->type == bfd_indirect_link_order)
 	{
 	  s = p->u.indirect.section;
-	  elfsec = _bfd_elf_section_from_bfd_section (sub, s);
-	  if (elfsec != -1
+	  sub = s->owner;
+	  if (bfd_get_flavour (sub) == bfd_target_elf_flavour
+	      && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass
+	      && (elfsec = _bfd_elf_section_from_bfd_section (sub, s)) != -1
 	      && elf_elfsections (sub)[elfsec]->sh_flags & SHF_LINK_ORDER)
-	    seen_linkorder++;
+	    {
+	      seen_linkorder++;
+	      linkorder_sec = s;
+	    }
 	  else
-	    seen_other++;
+	    {
+	      seen_other++;
+	      other_sec = s;
+	    }
 	}
       else
 	seen_other++;
+
+      if (seen_other && seen_linkorder)
+	{
+	  if (other_sec && linkorder_sec)
+	    (*_bfd_error_handler) (_("%A has both ordered [`%A' in %B] and unordered [`%A' in %B] sections"),
+				   o, linkorder_sec,
+				   linkorder_sec->owner, other_sec,
+				   other_sec->owner);
+	  else
+	    (*_bfd_error_handler) (_("%A has both ordered and unordered sections"),
+				   o);
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
+	}
     }
 
   if (!seen_linkorder)
     return TRUE;
 
-  if (seen_other && seen_linkorder)
-    {
-      (*_bfd_error_handler) (_("%A has both ordered and unordered sections"),
-			     o);
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
-
   sections = (struct bfd_link_order **)
     xmalloc (seen_linkorder * sizeof (struct bfd_link_order *));
   seen_linkorder = 0;


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