[binutils-gdb] Fix bug where -u option with empty archive results in internal error.

Cary Coutant ccoutant@sourceware.org
Mon Nov 21 22:06:00 GMT 2016


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c13b08dbbcf752480a7621aa1f89bc5440c74c25

commit c13b08dbbcf752480a7621aa1f89bc5440c74c25
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Mon Nov 21 14:05:40 2016 -0800

    Fix bug where -u option with empty archive results in internal error.
    
    gold/
    	PR gold/20693
    	* gold.cc (queue_middle_tasks): Force valid target earlier.

Diff:
---
 gold/ChangeLog |  5 +++++
 gold/gold.cc   | 16 ++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index bb035f3..63476cd 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-21  Cary Coutant  <ccoutant@gmail.com>
+
+	PR gold/20693
+	* gold.cc (queue_middle_tasks): Force valid target earlier.
+
 2016-11-21  Igor Kudrin  <ikudrin@accesssoftek.com>
 
 	* layout.cc: Include windows.h and rpcdce.h (for MinGW32).
diff --git a/gold/gold.cc b/gold/gold.cc
index 123d79b..7b3414f 100644
--- a/gold/gold.cc
+++ b/gold/gold.cc
@@ -492,6 +492,14 @@ queue_middle_tasks(const General_options& options,
   if (timer != NULL)
     timer->stamp(0);
 
+  // We have to support the case of not seeing any input objects, and
+  // generate an empty file.  Existing builds depend on being able to
+  // pass an empty archive to the linker and get an empty object file
+  // out.  In order to do this we need to use a default target.
+  if (input_objects->number_of_input_objects() == 0
+      && layout->incremental_base() == NULL)
+    parameters_force_valid_target();
+
   // Add any symbols named with -u options to the symbol table.
   symtab->add_undefined_symbols_from_command_line(layout);
 
@@ -589,14 +597,6 @@ queue_middle_tasks(const General_options& options,
 	}
     }
 
-  // We have to support the case of not seeing any input objects, and
-  // generate an empty file.  Existing builds depend on being able to
-  // pass an empty archive to the linker and get an empty object file
-  // out.  In order to do this we need to use a default target.
-  if (input_objects->number_of_input_objects() == 0
-      && layout->incremental_base() == NULL)
-    parameters_force_valid_target();
-
   int thread_count = options.thread_count_middle();
   if (thread_count == 0)
     thread_count = std::max(2, input_objects->number_of_input_objects());



More information about the Binutils-cvs mailing list