[gold patch] Fix internal error with --start-lib and object file with no global syms

Cary Coutant ccoutant@google.com
Mon Aug 23 19:13:00 GMT 2010


If gold encounters an object file between --start-lib and --end-lib
that has no global symbols, it will trigger an assertion failure due
to a failure to lock the file before destroying the views in that
file. This patch fixes that problem and tweaks the --start-lib test
case to trigger the problem.

OK?

-cary

        * archive.cc (Lib_group::add_symbols): Lock object before deleting its
        symbols data.
        (Lib_group::include_member): Unlock object after deleting its
        symbols data.
        * testsuite/start_lib_test_3.c: Remove all global symbols to trigger
        the bug fixed here.
-------------- next part --------------
Index: archive.cc
===================================================================
RCS file: /cvs/src/src/gold/archive.cc,v
retrieving revision 1.57
diff -u -p -r1.57 archive.cc
--- archive.cc	20 Aug 2010 00:35:12 -0000	1.57
+++ archive.cc	23 Aug 2010 18:13:49 -0000
@@ -1057,7 +1057,14 @@ Lib_group::add_symbols(Symbol_table* sym
           else
             {
               if (member.sd_ != NULL)
-                delete member.sd_;
+		{
+		  // The file must be locked in order to destroy the views
+		  // associated with it.
+		  gold_assert (obj != NULL);
+		  obj->lock(this->task_);
+		  delete member.sd_;
+		  obj->unlock(this->task_);
+		}
             }
 
 	  this->members_[i] = this->members_.back();
@@ -1096,10 +1103,10 @@ Lib_group::include_member(Symbol_table* 
 	layout->incremental_inputs()->report_object(obj, NULL);
       obj->layout(symtab, layout, sd);
       obj->add_symbols(symtab, sd, layout);
-      // Unlock the file for the next task.
-      obj->unlock(this->task_);
     }
   delete sd;
+  // Unlock the file for the next task.
+  obj->unlock(this->task_);
 }
 
 // Print statistical information to stderr.  This is used for --stats.
Index: testsuite/start_lib_test_3.c
===================================================================
RCS file: /cvs/src/src/gold/testsuite/start_lib_test_3.c,v
retrieving revision 1.1
diff -u -p -r1.1 start_lib_test_3.c
--- testsuite/start_lib_test_3.c	20 Aug 2010 00:35:13 -0000	1.1
+++ testsuite/start_lib_test_3.c	23 Aug 2010 18:13:49 -0000
@@ -22,9 +22,4 @@
 
    This is a test of the --start-lib and --end-lib options.  */
 
-extern void t3 (void);
-
-void
-t3 (void)
-{
-}
+static char t3[] = "t3";


More information about the Binutils mailing list