diff options
author | Ian Lance Taylor <iant@google.com> | 2008-02-06 20:32:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2008-02-06 20:32:10 +0000 |
commit | fbfba5088712eb014b9051baa71f9636359d159e (patch) | |
tree | 6836ec1f682dc1c4954429d9be124c268d530526 /gold/gold.cc | |
parent | Fix group signature handling for relocatable link, add bootstrap (diff) | |
download | binutils-gdb-fbfba5088712eb014b9051baa71f9636359d159e.tar.gz binutils-gdb-fbfba5088712eb014b9051baa71f9636359d159e.tar.bz2 binutils-gdb-fbfba5088712eb014b9051baa71f9636359d159e.zip |
Support creating empty output when there are no input objects.
Diffstat (limited to 'gold/gold.cc')
-rw-r--r-- | gold/gold.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gold/gold.cc b/gold/gold.cc index 71dac861798..4b52b570abc 100644 --- a/gold/gold.cc +++ b/gold/gold.cc @@ -26,10 +26,12 @@ #include <cstdio> #include <cstring> #include <unistd.h> +#include <algorithm> #include "libiberty.h" #include "options.h" #include "debug.h" +#include "target-select.h" #include "workqueue.h" #include "dirsearch.h" #include "readsyms.h" @@ -160,16 +162,24 @@ queue_middle_tasks(const General_options& options, Layout* layout, Workqueue* workqueue) { + // 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) { - // We had some input files, but we weren't able to open any of - // them. - gold_fatal(_("no input files")); + // The GOLD_xx macros are defined by the configure script. + Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE, + GOLD_DEFAULT_SIZE, + GOLD_DEFAULT_BIG_ENDIAN, + 0, 0); + gold_assert(target != NULL); + set_parameters_target(target); } int thread_count = options.thread_count_middle(); if (thread_count == 0) - thread_count = input_objects->number_of_input_objects(); + thread_count = std::max(2, input_objects->number_of_input_objects()); workqueue->set_thread_count(thread_count); // Now we have seen all the input files. @@ -278,7 +288,7 @@ queue_final_tasks(const General_options& options, { int thread_count = options.thread_count_final(); if (thread_count == 0) - thread_count = input_objects->number_of_input_objects(); + thread_count = std::max(2, input_objects->number_of_input_objects()); workqueue->set_thread_count(thread_count); bool any_postprocessing_sections = layout->any_postprocessing_sections(); |