#include "options.h"
#include "debug.h"
-#include "target-select.h"
#include "workqueue.h"
#include "dirsearch.h"
#include "readsyms.h"
gold_exit(bool status)
{
if (!status && parameters != NULL && parameters->options_valid())
- unlink_if_ordinary(parameters->output_file_name());
+ unlink_if_ordinary(parameters->options().output_file_name());
exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
}
// 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)
- {
- // 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);
- }
+ set_parameters_target(¶meters->default_target());
int thread_count = options.thread_count_middle();
if (thread_count == 0)
// Now we have seen all the input files.
const bool doing_static_link = (!input_objects->any_dynamic()
- && !parameters->output_is_shared());
+ && !parameters->options().shared());
set_parameters_doing_static_link(doing_static_link);
if (!doing_static_link && options.is_static())
{
gold_error(_("cannot mix -static with dynamic object %s"),
(*input_objects->dynobj_begin())->name().c_str());
}
- if (!doing_static_link && parameters->output_is_object())
+ if (!doing_static_link && parameters->options().relocatable())
gold_error(_("cannot mix -r with dynamic object %s"),
(*input_objects->dynobj_begin())->name().c_str());
+ if (!doing_static_link
+ && options.oformat_enum() != General_options::OBJECT_FORMAT_ELF)
+ gold_fatal(_("cannot use non-ELF output format with dynamic object %s"),
+ (*input_objects->dynobj_begin())->name().c_str());
if (is_debugging_enabled(DEBUG_SCRIPT))
layout->script_options()->print(stderr);
// TODO: if this is too slow, do this as a task, rather than inline.
symtab->detect_odr_violations(task, options.output_file_name());
+ // Create any output sections required by any linker script.
+ layout->create_script_sections();
+
// Define some sections and symbols needed for a dynamic link. This
// handles some cases we want to see before we read the relocs.
layout->create_initial_dynamic_sections(symtab);
// Define symbols from any linker scripts.
layout->define_script_symbols(symtab);
- if (!parameters->output_is_object())
+ // Attach sections to segments.
+ layout->attach_sections_to_segments();
+
+ if (!parameters->options().relocatable())
{
// Predefine standard symbols.
define_standard_symbols(symtab, layout);
// Allocate common symbols. This requires write access to the
// symbol table, but is independent of the relocation processing.
- // FIXME: We should have an option to do this even for a relocatable
- // link.
- if (!parameters->output_is_object())
+ if (parameters->options().define_common())
{
blocker->add_blocker();
- workqueue->queue(new Allocate_commons_task(options, symtab, layout,
- symtab_lock, blocker));
+ workqueue->queue(new Allocate_commons_task(symtab, layout, symtab_lock,
+ blocker));
}
// When all those tasks are complete, we can start laying out the
// output file.
+ // TODO(csilvers): figure out a more principled way to get the target
+ Target* target = const_cast<Target*>(¶meters->target());
workqueue->queue(new Task_function(new Layout_task_runner(options,
input_objects,
symtab,
+ target,
layout),
blocker,
"Task_function Layout_task_runner"));
// Queue a task to close the output file. This will be blocked by
// FINAL_BLOCKER.
- workqueue->queue(new Task_function(new Close_task_runner(of),
+ workqueue->queue(new Task_function(new Close_task_runner(&options, layout,
+ of),
final_blocker,
"Task_function Close_task_runner"));
}