* fr30-desc.c, * fr30-desc.h, * fr30-opc.c,
[deliverable/binutils-gdb.git] / gold / gold.cc
CommitLineData
5a6f7e2d 1// gold.cc -- main linker functions
bae7f79e 2
62dfdd4d 3// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6cb15b7f
ILT
4// Written by Ian Lance Taylor <iant@google.com>.
5
6// This file is part of gold.
7
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.
12
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.
17
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.
22
bae7f79e
ILT
23#include "gold.h"
24
25#include <cstdlib>
26#include <cstdio>
27#include <cstring>
28#include <unistd.h>
fbfba508 29#include <algorithm>
75f2446e 30#include "libiberty.h"
bae7f79e
ILT
31
32#include "options.h"
494e05f4 33#include "debug.h"
bae7f79e
ILT
34#include "workqueue.h"
35#include "dirsearch.h"
36#include "readsyms.h"
14bfc3f5 37#include "symtab.h"
ead1e424 38#include "common.h"
54dc6425 39#include "object.h"
a2fb1b05 40#include "layout.h"
61ba1cf9 41#include "reloc.h"
ead1e424 42#include "defstd.h"
89fc3421 43#include "plugin.h"
f345227a 44#include "gc.h"
ef15dade 45#include "icf.h"
44453f85 46#include "incremental.h"
bae7f79e
ILT
47
48namespace gold
49{
50
51const char* program_name;
52
53void
54gold_exit(bool status)
55{
483620e8
CC
56 if (parameters != NULL
57 && parameters->options_valid()
58 && parameters->options().has_plugins())
59 parameters->options().plugins()->cleanup();
2d684091 60 if (!status && parameters != NULL && parameters->options_valid())
8851ecca 61 unlink_if_ordinary(parameters->options().output_file_name());
bae7f79e
ILT
62 exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
63}
64
bae7f79e
ILT
65void
66gold_nomem()
67{
68 // We are out of memory, so try hard to print a reasonable message.
69 // Note that we don't try to translate this message, since the
70 // translation process itself will require memory.
55ba0940
ILT
71
72 // LEN only exists to avoid a pointless warning when write is
73 // declared with warn_use_result, as when compiling with
74 // -D_USE_FORTIFY on GNU/Linux. Casting to void does not appear to
75 // work, at least not with gcc 4.3.0.
76
77 ssize_t len = write(2, program_name, strlen(program_name));
78 if (len >= 0)
79 {
80 const char* const s = ": out of memory\n";
81 len = write(2, s, strlen(s));
82 }
bae7f79e
ILT
83 gold_exit(false);
84}
85
a3ad94ed
ILT
86// Handle an unreachable case.
87
bae7f79e 88void
a3ad94ed 89do_gold_unreachable(const char* filename, int lineno, const char* function)
bae7f79e 90{
27b7985a 91 fprintf(stderr, _("%s: internal error in %s, at %s:%d\n"),
a3ad94ed
ILT
92 program_name, function, filename, lineno);
93 gold_exit(false);
bae7f79e
ILT
94}
95
92e059d8
ILT
96// This class arranges to run the functions done in the middle of the
97// link. It is just a closure.
bae7f79e 98
92e059d8 99class Middle_runner : public Task_function_runner
bae7f79e 100{
92e059d8
ILT
101 public:
102 Middle_runner(const General_options& options,
103 const Input_objects* input_objects,
104 Symbol_table* symtab,
7d9e3d98 105 Layout* layout, Mapfile* mapfile)
92e059d8 106 : options_(options), input_objects_(input_objects), symtab_(symtab),
7d9e3d98 107 layout_(layout), mapfile_(mapfile)
92e059d8
ILT
108 { }
109
110 void
17a1d0a9 111 run(Workqueue*, const Task*);
92e059d8
ILT
112
113 private:
114 const General_options& options_;
115 const Input_objects* input_objects_;
116 Symbol_table* symtab_;
117 Layout* layout_;
7d9e3d98 118 Mapfile* mapfile_;
92e059d8 119};
bae7f79e 120
92e059d8 121void
17a1d0a9 122Middle_runner::run(Workqueue* workqueue, const Task* task)
92e059d8 123{
17a1d0a9 124 queue_middle_tasks(this->options_, task, this->input_objects_, this->symtab_,
7d9e3d98 125 this->layout_, workqueue, this->mapfile_);
92e059d8 126}
bae7f79e 127
6d03d481
ST
128// This class arranges the tasks to process the relocs for garbage collection.
129
130class Gc_runner : public Task_function_runner
131{
132 public:
133 Gc_runner(const General_options& options,
134 const Input_objects* input_objects,
135 Symbol_table* symtab,
136 Layout* layout, Mapfile* mapfile)
137 : options_(options), input_objects_(input_objects), symtab_(symtab),
138 layout_(layout), mapfile_(mapfile)
139 { }
140
141 void
142 run(Workqueue*, const Task*);
143
144 private:
145 const General_options& options_;
146 const Input_objects* input_objects_;
147 Symbol_table* symtab_;
148 Layout* layout_;
149 Mapfile* mapfile_;
150};
151
152void
153Gc_runner::run(Workqueue* workqueue, const Task* task)
154{
155 queue_middle_gc_tasks(this->options_, task, this->input_objects_,
156 this->symtab_, this->layout_, workqueue,
157 this->mapfile_);
158}
159
bae7f79e
ILT
160// Queue up the initial set of tasks for this link job.
161
162void
163queue_initial_tasks(const General_options& options,
17a1d0a9 164 Dirsearch& search_path,
ead1e424 165 const Command_line& cmdline,
54dc6425 166 Workqueue* workqueue, Input_objects* input_objects,
7d9e3d98 167 Symbol_table* symtab, Layout* layout, Mapfile* mapfile)
bae7f79e 168{
e5366891 169 if (cmdline.begin() == cmdline.end())
459c9f1c
ILT
170 {
171 if (options.printed_version())
172 gold_exit(true);
173 gold_fatal(_("no input files"));
174 }
e5366891 175
fe9a4c12
ILT
176 int thread_count = options.thread_count_initial();
177 if (thread_count == 0)
e5366891 178 thread_count = cmdline.number_of_input_files();
fe9a4c12
ILT
179 workqueue->set_thread_count(thread_count);
180
44453f85
ILT
181 if (cmdline.options().incremental())
182 {
183 Incremental_checker incremental_checker(
c4aa1e2d
ILT
184 parameters->options().output_file_name(),
185 layout->incremental_inputs());
44453f85
ILT
186 if (incremental_checker.can_incrementally_link_output_file())
187 {
188 // TODO: remove when incremental linking implemented.
189 printf("Incremental linking might be possible "
190 "(not implemented yet)\n");
191 }
192 // TODO: If we decide on an incremental build, fewer tasks
193 // should be scheduled.
194 }
195
bae7f79e
ILT
196 // Read the input files. We have to add the symbols to the symbol
197 // table in order. We do this by creating a separate blocker for
198 // each input file. We associate the blocker with the following
199 // input file, to give us a convenient place to delete it.
200 Task_token* this_blocker = NULL;
ead1e424
ILT
201 for (Command_line::const_iterator p = cmdline.begin();
202 p != cmdline.end();
bae7f79e
ILT
203 ++p)
204 {
17a1d0a9 205 Task_token* next_blocker = new Task_token(true);
bae7f79e 206 next_blocker->add_blocker();
f1ed28fb 207 workqueue->queue(new Read_symbols(input_objects, symtab, layout,
15f8229b 208 &search_path, 0, mapfile, &*p, NULL,
7d9e3d98 209 this_blocker, next_blocker));
bae7f79e
ILT
210 this_blocker = next_blocker;
211 }
212
89fc3421
CC
213 if (options.has_plugins())
214 {
215 Task_token* next_blocker = new Task_token(true);
216 next_blocker->add_blocker();
217 workqueue->queue(new Plugin_hook(options, input_objects, symtab, layout,
218 &search_path, mapfile, this_blocker,
219 next_blocker));
220 this_blocker = next_blocker;
221 }
222
6d03d481 223 if (parameters->options().relocatable()
032ce4e9
ST
224 && (parameters->options().gc_sections()
225 || parameters->options().icf_enabled()))
ef15dade 226 gold_error(_("cannot mix -r with --gc-sections or --icf"));
6d03d481 227
032ce4e9
ST
228 if (parameters->options().gc_sections()
229 || parameters->options().icf_enabled())
6d03d481
ST
230 {
231 workqueue->queue(new Task_function(new Gc_runner(options,
ad0f2072 232 input_objects,
6d03d481
ST
233 symtab,
234 layout,
235 mapfile),
236 this_blocker,
237 "Task_function Gc_runner"));
238 }
239 else
240 {
241 workqueue->queue(new Task_function(new Middle_runner(options,
242 input_objects,
243 symtab,
244 layout,
245 mapfile),
246 this_blocker,
247 "Task_function Middle_runner"));
248 }
249}
250
44453f85
ILT
251// Queue up a set of tasks to be done before queueing the middle set
252// of tasks. This is only necessary when garbage collection
6d03d481
ST
253// (--gc-sections) of unused sections is desired. The relocs are read
254// and processed here early to determine the garbage sections before the
255// relocs can be scanned in later tasks.
256
257void
258queue_middle_gc_tasks(const General_options& options,
259 const Task* ,
260 const Input_objects* input_objects,
261 Symbol_table* symtab,
262 Layout* layout,
263 Workqueue* workqueue,
264 Mapfile* mapfile)
265{
266 // Read_relocs for all the objects must be done and processed to find
267 // unused sections before any scanning of the relocs can take place.
268 Task_token* blocker = new Task_token(true);
fa17a3f4 269 blocker->add_blockers(input_objects->number_of_relobjs());
6d03d481
ST
270 Task_token* symtab_lock = new Task_token(false);
271 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
272 p != input_objects->relobj_end();
273 ++p)
fa17a3f4
ILT
274 workqueue->queue(new Read_relocs(symtab, layout, *p, symtab_lock,
275 blocker));
6d03d481 276
92e059d8 277 workqueue->queue(new Task_function(new Middle_runner(options,
6d03d481
ST
278 input_objects,
279 symtab,
280 layout,
281 mapfile),
fa17a3f4 282 blocker,
6d03d481 283 "Task_function Middle_runner"));
bae7f79e
ILT
284}
285
92e059d8
ILT
286// Queue up the middle set of tasks. These are the tasks which run
287// after all the input objects have been found and all the symbols
288// have been read, but before we lay out the output file.
bae7f79e 289
92e059d8
ILT
290void
291queue_middle_tasks(const General_options& options,
17a1d0a9 292 const Task* task,
92e059d8
ILT
293 const Input_objects* input_objects,
294 Symbol_table* symtab,
295 Layout* layout,
7d9e3d98
ILT
296 Workqueue* workqueue,
297 Mapfile* mapfile)
61ba1cf9 298{
6d03d481
ST
299 // Add any symbols named with -u options to the symbol table.
300 symtab->add_undefined_symbols_from_command_line();
301
302 // If garbage collection was chosen, relocs have been read and processed
303 // at this point by pre_middle_tasks. Layout can then be done for all
304 // objects.
305 if (parameters->options().gc_sections())
306 {
307 // Find the start symbol if any.
308 Symbol* start_sym;
309 if (parameters->options().entry())
310 start_sym = symtab->lookup(parameters->options().entry());
311 else
312 start_sym = symtab->lookup("_start");
556bd683 313 if (start_sym != NULL)
6d03d481
ST
314 {
315 bool is_ordinary;
316 unsigned int shndx = start_sym->shndx(&is_ordinary);
317 if (is_ordinary)
318 {
319 symtab->gc()->worklist().push(
320 Section_id(start_sym->object(), shndx));
321 }
322 }
323 // Symbols named with -u should not be considered garbage.
324 symtab->gc_mark_undef_symbols();
325 gold_assert(symtab->gc() != NULL);
326 // Do a transitive closure on all references to determine the worklist.
327 symtab->gc()->do_transitive_closure();
ef15dade
ST
328 }
329
330 // If identical code folding (--icf) is chosen it makes sense to do it
331 // only after garbage collection (--gc-sections) as we do not want to
332 // be folding sections that will be garbage.
032ce4e9 333 if (parameters->options().icf_enabled())
ef15dade
ST
334 {
335 symtab->icf()->find_identical_sections(input_objects, symtab);
336 }
337
338 // Call Object::layout for the second time to determine the
339 // output_sections for all referenced input sections. When
340 // --gc-sections or --icf is turned on, Object::layout is
341 // called twice. It is called the first time when the
342 // symbols are added.
032ce4e9
ST
343 if (parameters->options().gc_sections()
344 || parameters->options().icf_enabled())
ef15dade 345 {
6d03d481
ST
346 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
347 p != input_objects->relobj_end();
348 ++p)
349 {
350 (*p)->layout(symtab, layout, NULL);
351 }
352 }
ef15dade 353
6d03d481
ST
354 // Layout deferred objects due to plugins.
355 if (parameters->options().has_plugins())
356 {
357 Plugin_manager* plugins = parameters->options().plugins();
358 gold_assert(plugins != NULL);
359 plugins->layout_deferred_objects();
360 }
ef15dade 361
032ce4e9
ST
362 if (parameters->options().gc_sections()
363 || parameters->options().icf_enabled())
6d03d481
ST
364 {
365 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
366 p != input_objects->relobj_end();
367 ++p)
368 {
369 // Update the value of output_section stored in rd.
370 Read_relocs_data *rd = (*p)->get_relocs_data();
371 for (Read_relocs_data::Relocs_list::iterator q = rd->relocs.begin();
372 q != rd->relocs.end();
373 ++q)
374 {
375 q->output_section = (*p)->output_section(q->data_shndx);
376 q->needs_special_offset_handling =
377 (*p)->is_output_section_offset_invalid(q->data_shndx);
378 }
379 }
380 }
381
fbfba508
ILT
382 // We have to support the case of not seeing any input objects, and
383 // generate an empty file. Existing builds depend on being able to
384 // pass an empty archive to the linker and get an empty object file
385 // out. In order to do this we need to use a default target.
2c0aeda4 386 if (input_objects->number_of_input_objects() == 0)
029ba973 387 parameters_force_valid_target();
2c0aeda4 388
fe9a4c12
ILT
389 int thread_count = options.thread_count_middle();
390 if (thread_count == 0)
fbfba508 391 thread_count = std::max(2, input_objects->number_of_input_objects());
fe9a4c12
ILT
392 workqueue->set_thread_count(thread_count);
393
b3b74ddc 394 // Now we have seen all the input files.
374ad285
ILT
395 const bool doing_static_link =
396 (!input_objects->any_dynamic()
397 && !parameters->options().output_is_position_independent());
4eff2974
ILT
398 set_parameters_doing_static_link(doing_static_link);
399 if (!doing_static_link && options.is_static())
400 {
401 // We print out just the first .so we see; there may be others.
4e1e25e0 402 gold_assert(input_objects->dynobj_begin() != input_objects->dynobj_end());
75f2446e
ILT
403 gold_error(_("cannot mix -static with dynamic object %s"),
404 (*input_objects->dynobj_begin())->name().c_str());
4eff2974 405 }
8851ecca 406 if (!doing_static_link && parameters->options().relocatable())
459c9f1c 407 gold_fatal(_("cannot mix -r with dynamic object %s"),
6a74a719 408 (*input_objects->dynobj_begin())->name().c_str());
516cb3d0 409 if (!doing_static_link
7cc619c3 410 && options.oformat_enum() != General_options::OBJECT_FORMAT_ELF)
516cb3d0
ILT
411 gold_fatal(_("cannot use non-ELF output format with dynamic object %s"),
412 (*input_objects->dynobj_begin())->name().c_str());
b3b74ddc 413
364c7fa5
ILT
414 if (parameters->options().relocatable())
415 {
416 Input_objects::Relobj_iterator p = input_objects->relobj_begin();
417 if (p != input_objects->relobj_end())
418 {
419 bool uses_split_stack = (*p)->uses_split_stack();
420 for (++p; p != input_objects->relobj_end(); ++p)
421 {
422 if ((*p)->uses_split_stack() != uses_split_stack)
423 gold_fatal(_("cannot mix split-stack '%s' and "
424 "non-split-stack '%s' when using -r"),
425 (*input_objects->relobj_begin())->name().c_str(),
426 (*p)->name().c_str());
427 }
428 }
429 }
430
494e05f4
ILT
431 if (is_debugging_enabled(DEBUG_SCRIPT))
432 layout->script_options()->print(stderr);
433
e2827e5f
ILT
434 // For each dynamic object, record whether we've seen all the
435 // dynamic objects that it depends upon.
436 input_objects->check_dynamic_dependencies();
437
70e654ba
ILT
438 // See if any of the input definitions violate the One Definition Rule.
439 // TODO: if this is too slow, do this as a task, rather than inline.
17a1d0a9 440 symtab->detect_odr_violations(task, options.output_file_name());
70e654ba 441
62dfdd4d
ILT
442 // Do the --no-undefined-version check.
443 if (!parameters->options().undefined_version())
444 {
445 Script_options* so = layout->script_options();
446 so->version_script_info()->check_unmatched_names(symtab);
447 }
448
9c547ec3
ILT
449 // Create any automatic note sections.
450 layout->create_notes();
451
919ed24c
ILT
452 // Create any output sections required by any linker script.
453 layout->create_script_sections();
454
a3ad94ed
ILT
455 // Define some sections and symbols needed for a dynamic link. This
456 // handles some cases we want to see before we read the relocs.
9b07f471 457 layout->create_initial_dynamic_sections(symtab);
a3ad94ed 458
a445fddf
ILT
459 // Define symbols from any linker scripts.
460 layout->define_script_symbols(symtab);
461
154e0e9a
ILT
462 // Attach sections to segments.
463 layout->attach_sections_to_segments();
464
8851ecca 465 if (!parameters->options().relocatable())
6a74a719
ILT
466 {
467 // Predefine standard symbols.
468 define_standard_symbols(symtab, layout);
ead1e424 469
6a74a719
ILT
470 // Define __start and __stop symbols for output sections where
471 // appropriate.
472 layout->define_section_symbols(symtab);
473 }
bfd58944 474
755ab8af
ILT
475 // Make sure we have symbols for any required group signatures.
476 layout->define_group_signatures(symtab);
477
17a1d0a9 478 Task_token* blocker = new Task_token(true);
fa17a3f4
ILT
479 blocker->add_blockers(input_objects->number_of_relobjs());
480 if (parameters->options().define_common())
481 blocker->add_blocker();
482
17a1d0a9 483 Task_token* symtab_lock = new Task_token(false);
6d03d481
ST
484
485 // If doing garbage collection, the relocations have already been read.
486 // Otherwise, read and scan the relocations.
032ce4e9
ST
487 if (parameters->options().gc_sections()
488 || parameters->options().icf_enabled())
92e059d8 489 {
6d03d481
ST
490 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
491 p != input_objects->relobj_end();
492 ++p)
fa17a3f4
ILT
493 workqueue->queue(new Scan_relocs(symtab, layout, *p,
494 (*p)->get_relocs_data(),
495 symtab_lock, blocker));
6d03d481
ST
496 }
497 else
498 {
499 // Read the relocations of the input files. We do this to find
500 // which symbols are used by relocations which require a GOT and/or
501 // a PLT entry, or a COPY reloc. When we implement garbage
502 // collection we will do it here by reading the relocations in a
503 // breadth first search by references.
504 //
505 // We could also read the relocations during the first pass, and
506 // mark symbols at that time. That is how the old GNU linker works.
507 // Doing that is more complex, since we may later decide to discard
508 // some of the sections, and thus change our minds about the types
509 // of references made to the symbols.
510 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
511 p != input_objects->relobj_end();
512 ++p)
513 {
514 // We can read and process the relocations in any order. But we
515 // only want one task to write to the symbol table at a time.
516 // So we queue up a task for each object to read the
517 // relocations. That task will in turn queue a task to wait
518 // until it can write to the symbol table.
ad0f2072
ILT
519 workqueue->queue(new Read_relocs(symtab, layout, *p, symtab_lock,
520 blocker));
6d03d481 521 }
92e059d8
ILT
522 }
523
524 // Allocate common symbols. This requires write access to the
525 // symbol table, but is independent of the relocation processing.
0dfbdef4 526 if (parameters->options().define_common())
fa17a3f4
ILT
527 workqueue->queue(new Allocate_commons_task(symtab, layout, mapfile,
528 symtab_lock, blocker));
92e059d8
ILT
529
530 // When all those tasks are complete, we can start laying out the
531 // output file.
8851ecca
ILT
532 // TODO(csilvers): figure out a more principled way to get the target
533 Target* target = const_cast<Target*>(&parameters->target());
92e059d8
ILT
534 workqueue->queue(new Task_function(new Layout_task_runner(options,
535 input_objects,
536 symtab,
8851ecca 537 target,
7d9e3d98
ILT
538 layout,
539 mapfile),
c7912668
ILT
540 blocker,
541 "Task_function Layout_task_runner"));
92e059d8 542}
61ba1cf9
ILT
543
544// Queue up the final set of tasks. This is called at the end of
545// Layout_task.
546
547void
548queue_final_tasks(const General_options& options,
549 const Input_objects* input_objects,
550 const Symbol_table* symtab,
27bc2bce 551 Layout* layout,
61ba1cf9
ILT
552 Workqueue* workqueue,
553 Output_file* of)
554{
fe9a4c12
ILT
555 int thread_count = options.thread_count_final();
556 if (thread_count == 0)
fbfba508 557 thread_count = std::max(2, input_objects->number_of_input_objects());
fe9a4c12
ILT
558 workqueue->set_thread_count(thread_count);
559
17a1d0a9
ILT
560 bool any_postprocessing_sections = layout->any_postprocessing_sections();
561
730cdc88
ILT
562 // Use a blocker to wait until all the input sections have been
563 // written out.
17a1d0a9
ILT
564 Task_token* input_sections_blocker = NULL;
565 if (!any_postprocessing_sections)
fa17a3f4
ILT
566 {
567 input_sections_blocker = new Task_token(true);
568 input_sections_blocker->add_blockers(input_objects->number_of_relobjs());
569 }
730cdc88
ILT
570
571 // Use a blocker to block any objects which have to wait for the
572 // output sections to complete before they can apply relocations.
17a1d0a9 573 Task_token* output_sections_blocker = new Task_token(true);
fa17a3f4 574 output_sections_blocker->add_blocker();
730cdc88 575
61ba1cf9 576 // Use a blocker to block the final cleanup task.
17a1d0a9 577 Task_token* final_blocker = new Task_token(true);
fa17a3f4
ILT
578 // Write_symbols_task, Write_sections_task, Write_data_task,
579 // Relocate_tasks.
580 final_blocker->add_blockers(3);
581 final_blocker->add_blockers(input_objects->number_of_relobjs());
582 if (!any_postprocessing_sections)
583 final_blocker->add_blocker();
61ba1cf9
ILT
584
585 // Queue a task to write out the symbol table.
d491d34e
ILT
586 workqueue->queue(new Write_symbols_task(layout,
587 symtab,
5fe2a0f5
ILT
588 input_objects,
589 layout->sympool(),
590 layout->dynpool(),
591 of,
592 final_blocker));
61ba1cf9 593
730cdc88 594 // Queue a task to write out the output sections.
730cdc88
ILT
595 workqueue->queue(new Write_sections_task(layout, of, output_sections_blocker,
596 final_blocker));
597
61ba1cf9 598 // Queue a task to write out everything else.
9025d29d 599 workqueue->queue(new Write_data_task(layout, symtab, of, final_blocker));
61ba1cf9 600
17a1d0a9
ILT
601 // Queue a task for each input object to relocate the sections and
602 // write out the local symbols.
603 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
604 p != input_objects->relobj_end();
605 ++p)
fa17a3f4
ILT
606 workqueue->queue(new Relocate_task(symtab, layout, *p, of,
607 input_sections_blocker,
608 output_sections_blocker,
609 final_blocker));
17a1d0a9 610
730cdc88 611 // Queue a task to write out the output sections which depend on
17a1d0a9
ILT
612 // input sections. If there are any sections which require
613 // postprocessing, then we need to do this last, since it may resize
614 // the output file.
615 if (!any_postprocessing_sections)
616 {
17a1d0a9
ILT
617 Task* t = new Write_after_input_sections_task(layout, of,
618 input_sections_blocker,
619 final_blocker);
620 workqueue->queue(t);
621 }
622 else
623 {
624 Task_token *new_final_blocker = new Task_token(true);
625 new_final_blocker->add_blocker();
626 Task* t = new Write_after_input_sections_task(layout, of,
627 final_blocker,
628 new_final_blocker);
629 workqueue->queue(t);
630 final_blocker = new_final_blocker;
631 }
730cdc88 632
61ba1cf9
ILT
633 // Queue a task to close the output file. This will be blocked by
634 // FINAL_BLOCKER.
516cb3d0
ILT
635 workqueue->queue(new Task_function(new Close_task_runner(&options, layout,
636 of),
c7912668
ILT
637 final_blocker,
638 "Task_function Close_task_runner"));
61ba1cf9
ILT
639}
640
641} // End namespace gold.
This page took 0.187887 seconds and 4 git commands to generate.