1 // gold.cc -- main linker functions
3 // Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
30 #include "libiberty.h"
33 #include "target-select.h"
35 #include "workqueue.h"
36 #include "dirsearch.h"
47 #include "incremental.h"
54 const char* program_name
;
57 process_incremental_input(Incremental_binary
*, unsigned int, Input_objects
*,
58 Symbol_table
*, Layout
*, Dirsearch
*, Mapfile
*,
59 Task_token
*, Task_token
*);
62 gold_exit(Exit_status status
)
64 if (parameters
!= NULL
65 && parameters
->options_valid()
66 && parameters
->options().has_plugins())
67 parameters
->options().plugins()->cleanup();
68 if (status
!= GOLD_OK
&& parameters
!= NULL
&& parameters
->options_valid())
69 unlink_if_ordinary(parameters
->options().output_file_name());
76 // We are out of memory, so try hard to print a reasonable message.
77 // Note that we don't try to translate this message, since the
78 // translation process itself will require memory.
80 // LEN only exists to avoid a pointless warning when write is
81 // declared with warn_use_result, as when compiling with
82 // -D_USE_FORTIFY on GNU/Linux. Casting to void does not appear to
83 // work, at least not with gcc 4.3.0.
85 ssize_t len
= write(2, program_name
, strlen(program_name
));
88 const char* const s
= ": out of memory\n";
89 len
= write(2, s
, strlen(s
));
94 // Handle an unreachable case.
97 do_gold_unreachable(const char* filename
, int lineno
, const char* function
)
99 fprintf(stderr
, _("%s: internal error in %s, at %s:%d\n"),
100 program_name
, function
, filename
, lineno
);
104 // This class arranges to run the functions done in the middle of the
105 // link. It is just a closure.
107 class Middle_runner
: public Task_function_runner
110 Middle_runner(const General_options
& options
,
111 const Input_objects
* input_objects
,
112 Symbol_table
* symtab
,
113 Layout
* layout
, Mapfile
* mapfile
)
114 : options_(options
), input_objects_(input_objects
), symtab_(symtab
),
115 layout_(layout
), mapfile_(mapfile
)
119 run(Workqueue
*, const Task
*);
122 const General_options
& options_
;
123 const Input_objects
* input_objects_
;
124 Symbol_table
* symtab_
;
130 Middle_runner::run(Workqueue
* workqueue
, const Task
* task
)
132 queue_middle_tasks(this->options_
, task
, this->input_objects_
, this->symtab_
,
133 this->layout_
, workqueue
, this->mapfile_
);
136 // This class arranges the tasks to process the relocs for garbage collection.
138 class Gc_runner
: public Task_function_runner
141 Gc_runner(const General_options
& options
,
142 const Input_objects
* input_objects
,
143 Symbol_table
* symtab
,
144 Layout
* layout
, Mapfile
* mapfile
)
145 : options_(options
), input_objects_(input_objects
), symtab_(symtab
),
146 layout_(layout
), mapfile_(mapfile
)
150 run(Workqueue
*, const Task
*);
153 const General_options
& options_
;
154 const Input_objects
* input_objects_
;
155 Symbol_table
* symtab_
;
161 Gc_runner::run(Workqueue
* workqueue
, const Task
* task
)
163 queue_middle_gc_tasks(this->options_
, task
, this->input_objects_
,
164 this->symtab_
, this->layout_
, workqueue
,
168 // Queue up the initial set of tasks for this link job.
171 queue_initial_tasks(const General_options
& options
,
172 Dirsearch
& search_path
,
173 const Command_line
& cmdline
,
174 Workqueue
* workqueue
, Input_objects
* input_objects
,
175 Symbol_table
* symtab
, Layout
* layout
, Mapfile
* mapfile
)
177 if (cmdline
.begin() == cmdline
.end())
180 if (options
.printed_version())
182 if (options
.print_output_format())
184 print_output_format();
189 gold_fatal(_("no input files"));
192 int thread_count
= options
.thread_count_initial();
193 if (thread_count
== 0)
194 thread_count
= cmdline
.number_of_input_files();
195 workqueue
->set_thread_count(thread_count
);
197 // For incremental links, the base output file.
198 Incremental_binary
* ibase
= NULL
;
200 if (parameters
->incremental_update())
202 Output_file
* of
= new Output_file(options
.output_file_name());
203 if (of
->open_base_file(options
.incremental_base(), true))
205 ibase
= open_incremental_binary(of
);
207 && ibase
->check_inputs(cmdline
, layout
->incremental_inputs()))
208 ibase
->init_layout(layout
);
218 if (set_parameters_incremental_full())
219 gold_info(_("linking with --incremental-full"));
221 gold_fallback(_("restart link with --incremental-full"));
225 // Read the input files. We have to add the symbols to the symbol
226 // table in order. We do this by creating a separate blocker for
227 // each input file. We associate the blocker with the following
228 // input file, to give us a convenient place to delete it.
229 Task_token
* this_blocker
= NULL
;
232 // Normal link. Queue a Read_symbols task for each input file
233 // on the command line.
234 for (Command_line::const_iterator p
= cmdline
.begin();
238 Task_token
* next_blocker
= new Task_token(true);
239 next_blocker
->add_blocker();
240 workqueue
->queue(new Read_symbols(input_objects
, symtab
, layout
,
241 &search_path
, 0, mapfile
, &*p
, NULL
,
242 NULL
, this_blocker
, next_blocker
));
243 this_blocker
= next_blocker
;
248 // Incremental update link. Process the list of input files
249 // stored in the base file, and queue a task for each file:
250 // a Read_symbols task for a changed file, and an Add_symbols task
251 // for an unchanged file. We need to mark all the space used by
252 // unchanged files before we can start any tasks running.
253 unsigned int input_file_count
= ibase
->input_file_count();
254 std::vector
<Task
*> tasks
;
255 tasks
.reserve(input_file_count
);
256 for (unsigned int i
= 0; i
< input_file_count
; ++i
)
258 Task_token
* next_blocker
= new Task_token(true);
259 next_blocker
->add_blocker();
260 Task
* t
= process_incremental_input(ibase
, i
, input_objects
, symtab
,
261 layout
, &search_path
, mapfile
,
262 this_blocker
, next_blocker
);
264 this_blocker
= next_blocker
;
266 // Now we can queue the tasks.
267 for (unsigned int i
= 0; i
< tasks
.size(); i
++)
268 workqueue
->queue(tasks
[i
]);
271 if (options
.has_plugins())
273 Task_token
* next_blocker
= new Task_token(true);
274 next_blocker
->add_blocker();
275 workqueue
->queue(new Plugin_hook(options
, input_objects
, symtab
, layout
,
276 &search_path
, mapfile
, this_blocker
,
278 this_blocker
= next_blocker
;
281 if (options
.relocatable()
282 && (options
.gc_sections() || options
.icf_enabled()))
283 gold_error(_("cannot mix -r with --gc-sections or --icf"));
285 if (options
.gc_sections() || options
.icf_enabled())
287 workqueue
->queue(new Task_function(new Gc_runner(options
,
293 "Task_function Gc_runner"));
297 workqueue
->queue(new Task_function(new Middle_runner(options
,
303 "Task_function Middle_runner"));
307 // Process an incremental input file: if it is unchanged from the previous
308 // link, return a task to add its symbols from the base file's incremental
309 // info; if it has changed, return a normal Read_symbols task. We create a
310 // task for every input file, if only to report the file for rebuilding the
314 process_incremental_input(Incremental_binary
* ibase
,
315 unsigned int input_file_index
,
316 Input_objects
* input_objects
,
317 Symbol_table
* symtab
,
319 Dirsearch
* search_path
,
321 Task_token
* this_blocker
,
322 Task_token
* next_blocker
)
324 const Incremental_binary::Input_reader
* input_reader
=
325 ibase
->get_input_reader(input_file_index
);
326 Incremental_input_type input_type
= input_reader
->type();
328 // Get the input argument corresponding to this input file, matching on
329 // the argument serial number. If the input file cannot be matched
330 // to an existing input argument, synthesize a new one.
331 const Input_argument
* input_argument
=
332 ibase
->get_input_argument(input_file_index
);
333 if (input_argument
== NULL
)
335 Input_file_argument
file(input_reader
->filename(),
336 Input_file_argument::INPUT_FILE_TYPE_FILE
,
337 "", false, parameters
->options());
338 Input_argument
* arg
= new Input_argument(file
);
339 arg
->set_script_info(ibase
->get_script_info(input_file_index
));
340 input_argument
= arg
;
343 gold_debug(DEBUG_INCREMENTAL
, "Incremental object: %s, type %d",
344 input_reader
->filename(), input_type
);
346 if (input_type
== INCREMENTAL_INPUT_SCRIPT
)
348 // Incremental_binary::check_inputs should have cancelled the
349 // incremental update if the script has changed.
350 gold_assert(!ibase
->file_has_changed(input_file_index
));
351 return new Check_script(layout
, ibase
, input_file_index
, input_reader
,
352 this_blocker
, next_blocker
);
355 if (input_type
== INCREMENTAL_INPUT_ARCHIVE
)
357 Incremental_library
* lib
= ibase
->get_library(input_file_index
);
358 gold_assert(lib
!= NULL
);
359 if (lib
->filename() == "/group/"
360 || !ibase
->file_has_changed(input_file_index
))
362 // Queue a task to check that no references have been added to any
363 // of the library's unused symbols.
364 return new Check_library(symtab
, layout
, ibase
, input_file_index
,
365 input_reader
, this_blocker
, next_blocker
);
369 // Queue a Read_symbols task to process the archive normally.
370 return new Read_symbols(input_objects
, symtab
, layout
, search_path
,
371 0, mapfile
, input_argument
, NULL
, NULL
,
372 this_blocker
, next_blocker
);
376 if (input_type
== INCREMENTAL_INPUT_ARCHIVE_MEMBER
)
378 // For archive members, check the timestamp of the containing archive.
379 Incremental_library
* lib
= ibase
->get_library(input_file_index
);
380 gold_assert(lib
!= NULL
);
381 // Process members of a --start-lib/--end-lib group as normal objects.
382 if (lib
->filename() != "/group/")
384 if (ibase
->file_has_changed(lib
->input_file_index()))
386 return new Read_member(input_objects
, symtab
, layout
, mapfile
,
387 input_reader
, this_blocker
, next_blocker
);
391 // The previous contributions from this file will be kept.
392 // Mark the pieces of output sections contributed by this
394 ibase
->reserve_layout(input_file_index
);
395 Object
* obj
= make_sized_incremental_object(ibase
,
399 return new Add_symbols(input_objects
, symtab
, layout
,
400 search_path
, 0, mapfile
, input_argument
,
401 obj
, lib
, NULL
, this_blocker
,
407 // Normal object file or shared library. Check if the file has changed
408 // since the last incremental link.
409 if (ibase
->file_has_changed(input_file_index
))
411 return new Read_symbols(input_objects
, symtab
, layout
, search_path
, 0,
412 mapfile
, input_argument
, NULL
, NULL
,
413 this_blocker
, next_blocker
);
417 // The previous contributions from this file will be kept.
418 // Mark the pieces of output sections contributed by this object.
419 ibase
->reserve_layout(input_file_index
);
420 Object
* obj
= make_sized_incremental_object(ibase
,
424 return new Add_symbols(input_objects
, symtab
, layout
, search_path
, 0,
425 mapfile
, input_argument
, obj
, NULL
, NULL
,
426 this_blocker
, next_blocker
);
430 // Queue up a set of tasks to be done before queueing the middle set
431 // of tasks. This is only necessary when garbage collection
432 // (--gc-sections) of unused sections is desired. The relocs are read
433 // and processed here early to determine the garbage sections before the
434 // relocs can be scanned in later tasks.
437 queue_middle_gc_tasks(const General_options
& options
,
439 const Input_objects
* input_objects
,
440 Symbol_table
* symtab
,
442 Workqueue
* workqueue
,
445 // Read_relocs for all the objects must be done and processed to find
446 // unused sections before any scanning of the relocs can take place.
447 Task_token
* this_blocker
= NULL
;
448 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
449 p
!= input_objects
->relobj_end();
452 Task_token
* next_blocker
= new Task_token(true);
453 next_blocker
->add_blocker();
454 workqueue
->queue(new Read_relocs(symtab
, layout
, *p
, this_blocker
,
456 this_blocker
= next_blocker
;
459 // If we are given only archives in input, we have no regular
460 // objects and THIS_BLOCKER is NULL here. Create a dummy
461 // blocker here so that we can run the middle tasks immediately.
462 if (this_blocker
== NULL
)
464 gold_assert(input_objects
->number_of_relobjs() == 0);
465 this_blocker
= new Task_token(true);
468 workqueue
->queue(new Task_function(new Middle_runner(options
,
474 "Task_function Middle_runner"));
477 // Queue up the middle set of tasks. These are the tasks which run
478 // after all the input objects have been found and all the symbols
479 // have been read, but before we lay out the output file.
482 queue_middle_tasks(const General_options
& options
,
484 const Input_objects
* input_objects
,
485 Symbol_table
* symtab
,
487 Workqueue
* workqueue
,
490 // Add any symbols named with -u options to the symbol table.
491 symtab
->add_undefined_symbols_from_command_line(layout
);
493 // If garbage collection was chosen, relocs have been read and processed
494 // at this point by pre_middle_tasks. Layout can then be done for all
496 if (parameters
->options().gc_sections())
498 // Find the start symbol if any.
499 Symbol
* start_sym
= symtab
->lookup(parameters
->entry());
500 if (start_sym
!= NULL
)
503 unsigned int shndx
= start_sym
->shndx(&is_ordinary
);
506 symtab
->gc()->worklist().push(
507 Section_id(start_sym
->object(), shndx
));
510 // Symbols named with -u should not be considered garbage.
511 symtab
->gc_mark_undef_symbols(layout
);
512 gold_assert(symtab
->gc() != NULL
);
513 // Do a transitive closure on all references to determine the worklist.
514 symtab
->gc()->do_transitive_closure();
517 // If identical code folding (--icf) is chosen it makes sense to do it
518 // only after garbage collection (--gc-sections) as we do not want to
519 // be folding sections that will be garbage.
520 if (parameters
->options().icf_enabled())
522 symtab
->icf()->find_identical_sections(input_objects
, symtab
);
525 // Call Object::layout for the second time to determine the
526 // output_sections for all referenced input sections. When
527 // --gc-sections or --icf is turned on, Object::layout is
528 // called twice. It is called the first time when the
529 // symbols are added.
530 if (parameters
->options().gc_sections()
531 || parameters
->options().icf_enabled())
533 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
534 p
!= input_objects
->relobj_end();
537 Task_lock_obj
<Object
> tlo(task
, *p
);
538 (*p
)->layout(symtab
, layout
, NULL
);
542 // Layout deferred objects due to plugins.
543 if (parameters
->options().has_plugins())
545 Plugin_manager
* plugins
= parameters
->options().plugins();
546 gold_assert(plugins
!= NULL
);
547 plugins
->layout_deferred_objects();
550 if (parameters
->options().gc_sections()
551 || parameters
->options().icf_enabled())
553 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
554 p
!= input_objects
->relobj_end();
557 // Update the value of output_section stored in rd.
558 Read_relocs_data
* rd
= (*p
)->get_relocs_data();
559 for (Read_relocs_data::Relocs_list::iterator q
= rd
->relocs
.begin();
560 q
!= rd
->relocs
.end();
563 q
->output_section
= (*p
)->output_section(q
->data_shndx
);
564 q
->needs_special_offset_handling
=
565 (*p
)->is_output_section_offset_invalid(q
->data_shndx
);
570 // We have to support the case of not seeing any input objects, and
571 // generate an empty file. Existing builds depend on being able to
572 // pass an empty archive to the linker and get an empty object file
573 // out. In order to do this we need to use a default target.
574 if (input_objects
->number_of_input_objects() == 0
575 && layout
->incremental_base() == NULL
)
576 parameters_force_valid_target();
578 int thread_count
= options
.thread_count_middle();
579 if (thread_count
== 0)
580 thread_count
= std::max(2, input_objects
->number_of_input_objects());
581 workqueue
->set_thread_count(thread_count
);
583 // Now we have seen all the input files.
584 const bool doing_static_link
=
585 (!input_objects
->any_dynamic()
586 && !parameters
->options().output_is_position_independent());
587 set_parameters_doing_static_link(doing_static_link
);
588 if (!doing_static_link
&& options
.is_static())
590 // We print out just the first .so we see; there may be others.
591 gold_assert(input_objects
->dynobj_begin() != input_objects
->dynobj_end());
592 gold_error(_("cannot mix -static with dynamic object %s"),
593 (*input_objects
->dynobj_begin())->name().c_str());
595 if (!doing_static_link
&& parameters
->options().relocatable())
596 gold_fatal(_("cannot mix -r with dynamic object %s"),
597 (*input_objects
->dynobj_begin())->name().c_str());
598 if (!doing_static_link
599 && options
.oformat_enum() != General_options::OBJECT_FORMAT_ELF
)
600 gold_fatal(_("cannot use non-ELF output format with dynamic object %s"),
601 (*input_objects
->dynobj_begin())->name().c_str());
603 if (parameters
->options().relocatable())
605 Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
606 if (p
!= input_objects
->relobj_end())
608 bool uses_split_stack
= (*p
)->uses_split_stack();
609 for (++p
; p
!= input_objects
->relobj_end(); ++p
)
611 if ((*p
)->uses_split_stack() != uses_split_stack
)
612 gold_fatal(_("cannot mix split-stack '%s' and "
613 "non-split-stack '%s' when using -r"),
614 (*input_objects
->relobj_begin())->name().c_str(),
615 (*p
)->name().c_str());
620 // For incremental updates, record the existing GOT and PLT entries,
621 // and the COPY relocations.
622 if (parameters
->incremental_update())
624 Incremental_binary
* ibase
= layout
->incremental_base();
625 ibase
->process_got_plt(symtab
, layout
);
626 ibase
->emit_copy_relocs(symtab
);
629 if (is_debugging_enabled(DEBUG_SCRIPT
))
630 layout
->script_options()->print(stderr
);
632 // For each dynamic object, record whether we've seen all the
633 // dynamic objects that it depends upon.
634 input_objects
->check_dynamic_dependencies();
636 // See if any of the input definitions violate the One Definition Rule.
637 // TODO: if this is too slow, do this as a task, rather than inline.
638 symtab
->detect_odr_violations(task
, options
.output_file_name());
640 // Do the --no-undefined-version check.
641 if (!parameters
->options().undefined_version())
643 Script_options
* so
= layout
->script_options();
644 so
->version_script_info()->check_unmatched_names(symtab
);
647 // Create any automatic note sections.
648 layout
->create_notes();
650 // Create any output sections required by any linker script.
651 layout
->create_script_sections();
653 // Define some sections and symbols needed for a dynamic link. This
654 // handles some cases we want to see before we read the relocs.
655 layout
->create_initial_dynamic_sections(symtab
);
657 // Define symbols from any linker scripts.
658 layout
->define_script_symbols(symtab
);
660 // Attach sections to segments.
661 layout
->attach_sections_to_segments();
663 if (!parameters
->options().relocatable())
665 // Predefine standard symbols.
666 define_standard_symbols(symtab
, layout
);
668 // Define __start and __stop symbols for output sections where
670 layout
->define_section_symbols(symtab
);
673 // Make sure we have symbols for any required group signatures.
674 layout
->define_group_signatures(symtab
);
676 Task_token
* this_blocker
= NULL
;
678 // Allocate common symbols. We use a blocker to run this before the
679 // Scan_relocs tasks, because it writes to the symbol table just as
681 if (parameters
->options().define_common())
683 this_blocker
= new Task_token(true);
684 this_blocker
->add_blocker();
685 workqueue
->queue(new Allocate_commons_task(symtab
, layout
, mapfile
,
689 // If doing garbage collection, the relocations have already been read.
690 // Otherwise, read and scan the relocations.
691 if (parameters
->options().gc_sections()
692 || parameters
->options().icf_enabled())
694 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
695 p
!= input_objects
->relobj_end();
698 Task_token
* next_blocker
= new Task_token(true);
699 next_blocker
->add_blocker();
700 workqueue
->queue(new Scan_relocs(symtab
, layout
, *p
,
701 (*p
)->get_relocs_data(),
702 this_blocker
, next_blocker
));
703 this_blocker
= next_blocker
;
708 // Read the relocations of the input files. We do this to find
709 // which symbols are used by relocations which require a GOT and/or
710 // a PLT entry, or a COPY reloc. When we implement garbage
711 // collection we will do it here by reading the relocations in a
712 // breadth first search by references.
714 // We could also read the relocations during the first pass, and
715 // mark symbols at that time. That is how the old GNU linker works.
716 // Doing that is more complex, since we may later decide to discard
717 // some of the sections, and thus change our minds about the types
718 // of references made to the symbols.
719 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
720 p
!= input_objects
->relobj_end();
723 Task_token
* next_blocker
= new Task_token(true);
724 next_blocker
->add_blocker();
725 workqueue
->queue(new Read_relocs(symtab
, layout
, *p
, this_blocker
,
727 this_blocker
= next_blocker
;
731 if (this_blocker
== NULL
)
733 if (input_objects
->number_of_relobjs() == 0)
735 // If we are given only archives in input, we have no regular
736 // objects and THIS_BLOCKER is NULL here. Create a dummy
737 // blocker here so that we can run the layout task immediately.
738 this_blocker
= new Task_token(true);
742 // If we failed to open any input files, it's possible for
743 // THIS_BLOCKER to be NULL here. There's no real point in
744 // continuing if that happens.
745 gold_assert(parameters
->errors()->error_count() > 0);
750 // When all those tasks are complete, we can start laying out the
752 // TODO(csilvers): figure out a more principled way to get the target
753 Target
* target
= const_cast<Target
*>(¶meters
->target());
754 workqueue
->queue(new Task_function(new Layout_task_runner(options
,
761 "Task_function Layout_task_runner"));
764 // Queue up the final set of tasks. This is called at the end of
768 queue_final_tasks(const General_options
& options
,
769 const Input_objects
* input_objects
,
770 const Symbol_table
* symtab
,
772 Workqueue
* workqueue
,
775 int thread_count
= options
.thread_count_final();
776 if (thread_count
== 0)
777 thread_count
= std::max(2, input_objects
->number_of_input_objects());
778 workqueue
->set_thread_count(thread_count
);
780 bool any_postprocessing_sections
= layout
->any_postprocessing_sections();
782 // Use a blocker to wait until all the input sections have been
784 Task_token
* input_sections_blocker
= NULL
;
785 if (!any_postprocessing_sections
)
787 input_sections_blocker
= new Task_token(true);
788 input_sections_blocker
->add_blockers(input_objects
->number_of_relobjs());
791 // Use a blocker to block any objects which have to wait for the
792 // output sections to complete before they can apply relocations.
793 Task_token
* output_sections_blocker
= new Task_token(true);
794 output_sections_blocker
->add_blocker();
796 // Use a blocker to block the final cleanup task.
797 Task_token
* final_blocker
= new Task_token(true);
798 // Write_symbols_task, Write_sections_task, Write_data_task,
800 final_blocker
->add_blockers(3);
801 final_blocker
->add_blockers(input_objects
->number_of_relobjs());
802 if (!any_postprocessing_sections
)
803 final_blocker
->add_blocker();
805 // Queue a task to write out the symbol table.
806 workqueue
->queue(new Write_symbols_task(layout
,
814 // Queue a task to write out the output sections.
815 workqueue
->queue(new Write_sections_task(layout
, of
, output_sections_blocker
,
818 // Queue a task to write out everything else.
819 workqueue
->queue(new Write_data_task(layout
, symtab
, of
, final_blocker
));
821 // Queue a task for each input object to relocate the sections and
822 // write out the local symbols.
823 for (Input_objects::Relobj_iterator p
= input_objects
->relobj_begin();
824 p
!= input_objects
->relobj_end();
826 workqueue
->queue(new Relocate_task(symtab
, layout
, *p
, of
,
827 input_sections_blocker
,
828 output_sections_blocker
,
831 // Queue a task to write out the output sections which depend on
832 // input sections. If there are any sections which require
833 // postprocessing, then we need to do this last, since it may resize
835 if (!any_postprocessing_sections
)
837 Task
* t
= new Write_after_input_sections_task(layout
, of
,
838 input_sections_blocker
,
844 Task_token
* new_final_blocker
= new Task_token(true);
845 new_final_blocker
->add_blocker();
846 Task
* t
= new Write_after_input_sections_task(layout
, of
,
850 final_blocker
= new_final_blocker
;
853 // Queue a task to close the output file. This will be blocked by
855 workqueue
->queue(new Task_function(new Close_task_runner(&options
, layout
,
858 "Task_function Close_task_runner"));
861 } // End namespace gold.