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]

gold patch committed: Give error for target mismatch in archive


When gold finds that the first object in an archive found via -l has the
wrong target, it skips to the next archive found in the -l search.
Unfortunately, in other cases where the object has the wrong target,
gold fails to give an error message, and simply silently ignores the
archive member.  This patch fixes that.  Committed to mainline.

Ian

2010-12-07  Ian Lance Taylor  <iant@google.com>

	* archive.cc (Archive::get_elf_object_for_member): Permit
	punconfigured to be NULL.
	(Archive::read_symbols): Pass NULL to get_elf_object_for_member.
	(Archive::include_member): Pass NULL to get_elf_object_for_member
	if we searched for the archive and this is the first included
	object.


Index: archive.cc
===================================================================
RCS file: /cvs/src/src/gold/archive.cc,v
retrieving revision 1.60
diff -p -u -r1.60 archive.cc
--- archive.cc	3 Nov 2010 17:18:23 -0000	1.60
+++ archive.cc	7 Dec 2010 15:45:04 -0000
@@ -527,14 +527,16 @@ Archive::get_file_and_offset(off_t off, 
   return true;
 }
 
-// Return an ELF object for the member at offset OFF.  If the ELF
-// object has an unsupported target type, set *PUNCONFIGURED to true
-// and return NULL.
+// Return an ELF object for the member at offset OFF.  If
+// PUNCONFIGURED is not NULL, then if the ELF object has an
+// unsupported target type, set *PUNCONFIGURED to true and return
+// NULL.
 
 Object*
 Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
 {
-  *punconfigured = false;
+  if (punconfigured != NULL)
+    *punconfigured = false;
 
   Input_file* input_file;
   off_t memoff;
@@ -593,9 +595,7 @@ Archive::read_all_symbols()
 void
 Archive::read_symbols(off_t off)
 {
-  bool dummy;
-  Object* obj = this->get_elf_object_for_member(off, &dummy);
-
+  Object* obj = this->get_elf_object_for_member(off, NULL);
   if (obj == NULL)
     return;
 
@@ -863,17 +863,22 @@ Archive::include_member(Symbol_table* sy
       return true;
     }
 
-  bool unconfigured;
-  Object* obj = this->get_elf_object_for_member(off, &unconfigured);
-
-  if (!this->included_member_
-      && this->searched_for()
-      && obj == NULL
-      && unconfigured)
-    return false;
+  // If this is the first object we are including from this archive,
+  // and we searched for this archive, most likely because it was
+  // found via a -l option, then if the target is incompatible we want
+  // to move on to the next archive found in the search path.
+  bool unconfigured = false;
+  bool* punconfigured = NULL;
+  if (!this->included_member_ && this->searched_for())
+    punconfigured = &unconfigured;
 
+  Object* obj = this->get_elf_object_for_member(off, punconfigured);
   if (obj == NULL)
-    return true;
+    {
+      // Return false to search for another archive, true if we found
+      // an error.
+      return unconfigured ? false : true;
+    }
 
   if (mapfile != NULL)
     mapfile->report_include_archive_member(obj->name(), sym, why);

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