*** empty log message ***
[deliverable/binutils-gdb.git] / gold / layout.h
CommitLineData
a2fb1b05
ILT
1// layout.h -- lay out output file sections for gold -*- C++ -*-
2
09ec0418 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
a2fb1b05
ILT
23#ifndef GOLD_LAYOUT_H
24#define GOLD_LAYOUT_H
25
e94cf127 26#include <cstring>
a2fb1b05 27#include <list>
1ef4d87f 28#include <map>
a2fb1b05
ILT
29#include <string>
30#include <utility>
31#include <vector>
32
e5756efb 33#include "script.h"
a2fb1b05
ILT
34#include "workqueue.h"
35#include "object.h"
14b31740 36#include "dynobj.h"
a2fb1b05
ILT
37#include "stringpool.h"
38
39namespace gold
40{
41
ead1e424 42class General_options;
3ce2c28e 43class Incremental_inputs;
54dc6425 44class Input_objects;
7d9e3d98 45class Mapfile;
75f65a3e 46class Symbol_table;
ead1e424 47class Output_section_data;
a2fb1b05 48class Output_section;
75f65a3e 49class Output_section_headers;
20e6d0d6
DK
50class Output_segment_headers;
51class Output_file_header;
a2fb1b05 52class Output_segment;
54dc6425 53class Output_data;
3a44184e 54class Output_data_reloc_generic;
a3ad94ed 55class Output_data_dynamic;
d491d34e 56class Output_symtab_xindex;
62b01cb5
ILT
57class Output_reduced_debug_abbrev_section;
58class Output_reduced_debug_info_section;
730cdc88 59class Eh_frame;
61ba1cf9 60class Target;
09ec0418 61struct Timespec;
a2fb1b05 62
a2e47362
CC
63// Return TRUE if SECNAME is the name of a compressed debug section.
64extern bool
65is_compressed_debug_section(const char* secname);
66
92e059d8
ILT
67// This task function handles mapping the input sections to output
68// sections and laying them out in memory.
a2fb1b05 69
92e059d8 70class Layout_task_runner : public Task_function_runner
a2fb1b05
ILT
71{
72 public:
73 // OPTIONS is the command line options, INPUT_OBJECTS is the list of
92e059d8
ILT
74 // input objects, SYMTAB is the symbol table, LAYOUT is the layout
75 // object.
76 Layout_task_runner(const General_options& options,
77 const Input_objects* input_objects,
78 Symbol_table* symtab,
8851ecca 79 Target* target,
7d9e3d98
ILT
80 Layout* layout,
81 Mapfile* mapfile)
75f65a3e 82 : options_(options), input_objects_(input_objects), symtab_(symtab),
7d9e3d98 83 target_(target), layout_(layout), mapfile_(mapfile)
a2fb1b05
ILT
84 { }
85
92e059d8 86 // Run the operation.
a2fb1b05 87 void
17a1d0a9 88 run(Workqueue*, const Task*);
a2fb1b05
ILT
89
90 private:
92e059d8
ILT
91 Layout_task_runner(const Layout_task_runner&);
92 Layout_task_runner& operator=(const Layout_task_runner&);
a2fb1b05
ILT
93
94 const General_options& options_;
54dc6425 95 const Input_objects* input_objects_;
75f65a3e 96 Symbol_table* symtab_;
8851ecca 97 Target* target_;
12e14209 98 Layout* layout_;
7d9e3d98 99 Mapfile* mapfile_;
a2fb1b05
ILT
100};
101
1ef4d87f
ILT
102// This class holds information about the comdat group or
103// .gnu.linkonce section that will be kept for a given signature.
8a4c0b0d 104
1ef4d87f 105class Kept_section
8a4c0b0d 106{
1ef4d87f
ILT
107 private:
108 // For a comdat group, we build a mapping from the name of each
109 // section in the group to the section index and the size in object.
110 // When we discard a group in some other object file, we use this
111 // map to figure out which kept section the discarded section is
112 // associated with. We then use that mapping when processing relocs
113 // against discarded sections.
114 struct Comdat_section_info
115 {
116 // The section index.
117 unsigned int shndx;
118 // The section size.
119 uint64_t size;
120
121 Comdat_section_info(unsigned int a_shndx, uint64_t a_size)
122 : shndx(a_shndx), size(a_size)
123 { }
124 };
125
126 // Most comdat groups have only one or two sections, so we use a
127 // std::map rather than an Unordered_map to optimize for that case
128 // without paying too heavily for groups with more sections.
129 typedef std::map<std::string, Comdat_section_info> Comdat_group;
130
131 public:
8a4c0b0d 132 Kept_section()
1ef4d87f
ILT
133 : object_(NULL), shndx_(0), is_comdat_(false), is_group_name_(false)
134 { this->u_.linkonce_size = 0; }
135
136 // We need to support copies for the signature map in the Layout
137 // object, but we should never copy an object after it has been
138 // marked as a comdat section.
139 Kept_section(const Kept_section& k)
140 : object_(k.object_), shndx_(k.shndx_), is_comdat_(false),
141 is_group_name_(k.is_group_name_)
142 {
143 gold_assert(!k.is_comdat_);
144 this->u_.linkonce_size = 0;
145 }
146
147 ~Kept_section()
148 {
149 if (this->is_comdat_)
150 delete this->u_.group_sections;
151 }
152
153 // The object where this section lives.
154 Relobj*
155 object() const
156 { return this->object_; }
8a4c0b0d 157
1ef4d87f
ILT
158 // Set the object.
159 void
2ea97941 160 set_object(Relobj* object)
1ef4d87f
ILT
161 {
162 gold_assert(this->object_ == NULL);
2ea97941 163 this->object_ = object;
1ef4d87f
ILT
164 }
165
166 // The section index.
167 unsigned int
168 shndx() const
169 { return this->shndx_; }
170
171 // Set the section index.
172 void
2ea97941 173 set_shndx(unsigned int shndx)
1ef4d87f
ILT
174 {
175 gold_assert(this->shndx_ == 0);
2ea97941 176 this->shndx_ = shndx;
1ef4d87f
ILT
177 }
178
179 // Whether this is a comdat group.
180 bool
181 is_comdat() const
182 { return this->is_comdat_; }
183
184 // Set that this is a comdat group.
185 void
186 set_is_comdat()
187 {
188 gold_assert(!this->is_comdat_);
189 this->is_comdat_ = true;
190 this->u_.group_sections = new Comdat_group();
191 }
8a4c0b0d 192
1ef4d87f
ILT
193 // Whether this is associated with the name of a group or section
194 // rather than the symbol name derived from a linkonce section.
195 bool
196 is_group_name() const
197 { return this->is_group_name_; }
198
199 // Note that this represents a comdat group rather than a single
200 // linkonce section.
201 void
202 set_is_group_name()
203 { this->is_group_name_ = true; }
204
205 // Add a section to the group list.
206 void
2ea97941 207 add_comdat_section(const std::string& name, unsigned int shndx,
1ef4d87f
ILT
208 uint64_t size)
209 {
210 gold_assert(this->is_comdat_);
2ea97941 211 Comdat_section_info sinfo(shndx, size);
1ef4d87f
ILT
212 this->u_.group_sections->insert(std::make_pair(name, sinfo));
213 }
214
215 // Look for a section name in the group list, and return whether it
216 // was found. If found, returns the section index and size.
217 bool
ca09d69a
NC
218 find_comdat_section(const std::string& name, unsigned int* pshndx,
219 uint64_t* psize) const
1ef4d87f
ILT
220 {
221 gold_assert(this->is_comdat_);
222 Comdat_group::const_iterator p = this->u_.group_sections->find(name);
223 if (p == this->u_.group_sections->end())
224 return false;
225 *pshndx = p->second.shndx;
226 *psize = p->second.size;
227 return true;
228 }
229
230 // If there is only one section in the group list, return true, and
231 // return the section index and size.
232 bool
ca09d69a 233 find_single_comdat_section(unsigned int* pshndx, uint64_t* psize) const
1ef4d87f
ILT
234 {
235 gold_assert(this->is_comdat_);
236 if (this->u_.group_sections->size() != 1)
237 return false;
238 Comdat_group::const_iterator p = this->u_.group_sections->begin();
239 *pshndx = p->second.shndx;
240 *psize = p->second.size;
241 return true;
242 }
243
244 // Return the size of a linkonce section.
245 uint64_t
246 linkonce_size() const
247 {
248 gold_assert(!this->is_comdat_);
249 return this->u_.linkonce_size;
250 }
251
252 // Set the size of a linkonce section.
253 void
254 set_linkonce_size(uint64_t size)
255 {
256 gold_assert(!this->is_comdat_);
257 this->u_.linkonce_size = size;
258 }
259
260 private:
261 // No assignment.
262 Kept_section& operator=(const Kept_section&);
263
264 // The object containing the comdat group or .gnu.linkonce section.
265 Relobj* object_;
266 // Index of the group section for comdats and the section itself for
8a4c0b0d 267 // .gnu.linkonce.
1ef4d87f
ILT
268 unsigned int shndx_;
269 // True if this is for a comdat group rather than a .gnu.linkonce
270 // section.
271 bool is_comdat_;
8a4c0b0d
ILT
272 // The Kept_sections are values of a mapping, that maps names to
273 // them. This field is true if this struct is associated with the
274 // name of a comdat or .gnu.linkonce, false if it is associated with
275 // the name of a symbol obtained from the .gnu.linkonce.* name
276 // through some heuristics.
1ef4d87f
ILT
277 bool is_group_name_;
278 union
279 {
280 // If the is_comdat_ field is true, this holds a map from names of
281 // the sections in the group to section indexes in object_ and to
282 // section sizes.
283 Comdat_group* group_sections;
284 // If the is_comdat_ field is false, this holds the size of the
285 // single section.
286 uint64_t linkonce_size;
287 } u_;
8a4c0b0d
ILT
288};
289
22f0da72
ILT
290// The ordering for output sections. This controls how output
291// sections are ordered within a PT_LOAD output segment.
292
293enum Output_section_order
294{
295 // Unspecified. Used for non-load segments. Also used for the file
296 // and segment headers.
297 ORDER_INVALID,
298
299 // The PT_INTERP section should come first, so that the dynamic
300 // linker can pick it up quickly.
301 ORDER_INTERP,
302
303 // Loadable read-only note sections come next so that the PT_NOTE
304 // segment is on the first page of the executable.
305 ORDER_RO_NOTE,
306
307 // Put read-only sections used by the dynamic linker early in the
308 // executable to minimize paging.
309 ORDER_DYNAMIC_LINKER,
310
311 // Put reloc sections used by the dynamic linker after other
312 // sections used by the dynamic linker; otherwise, objcopy and strip
313 // get confused.
314 ORDER_DYNAMIC_RELOCS,
315
316 // Put the PLT reloc section after the other dynamic relocs;
9a2743de 317 // otherwise, prelink gets confused.
22f0da72
ILT
318 ORDER_DYNAMIC_PLT_RELOCS,
319
320 // The .init section.
321 ORDER_INIT,
322
323 // The PLT.
324 ORDER_PLT,
325
326 // The regular text sections.
327 ORDER_TEXT,
328
329 // The .fini section.
330 ORDER_FINI,
331
332 // The read-only sections.
333 ORDER_READONLY,
334
335 // The exception frame sections.
336 ORDER_EHFRAME,
337
338 // The TLS sections come first in the data section.
339 ORDER_TLS_DATA,
340 ORDER_TLS_BSS,
341
342 // Local RELRO (read-only after relocation) sections come before
343 // non-local RELRO sections. This data will be fully resolved by
344 // the prelinker.
345 ORDER_RELRO_LOCAL,
346
347 // Non-local RELRO sections are grouped together after local RELRO
348 // sections. All RELRO sections must be adjacent so that they can
349 // all be put into a PT_GNU_RELRO segment.
350 ORDER_RELRO,
351
352 // We permit marking exactly one output section as the last RELRO
353 // section. We do this so that the read-only GOT can be adjacent to
354 // the writable GOT.
355 ORDER_RELRO_LAST,
356
357 // Similarly, we permit marking exactly one output section as the
358 // first non-RELRO section.
359 ORDER_NON_RELRO_FIRST,
360
361 // The regular data sections come after the RELRO sections.
362 ORDER_DATA,
363
364 // Large data sections normally go in large data segments.
365 ORDER_LARGE_DATA,
366
367 // Group writable notes so that we can have a single PT_NOTE
368 // segment.
369 ORDER_RW_NOTE,
370
371 // The small data sections must be at the end of the data sections,
372 // so that they can be adjacent to the small BSS sections.
373 ORDER_SMALL_DATA,
374
375 // The BSS sections start here.
376
377 // The small BSS sections must be at the start of the BSS sections,
378 // so that they can be adjacent to the small data sections.
379 ORDER_SMALL_BSS,
380
381 // The regular BSS sections.
382 ORDER_BSS,
383
384 // The large BSS sections come after the other BSS sections.
385 ORDER_LARGE_BSS,
386
387 // Maximum value.
388 ORDER_MAX
389};
390
a2fb1b05
ILT
391// This class handles the details of laying out input sections.
392
393class Layout
394{
395 public:
e55bde5e 396 Layout(int number_of_input_files, Script_options*);
54dc6425 397
20e6d0d6
DK
398 ~Layout()
399 {
400 delete this->relaxation_debug_check_;
401 delete this->segment_states_;
402 }
403
ead1e424
ILT
404 // Given an input section SHNDX, named NAME, with data in SHDR, from
405 // the object file OBJECT, return the output section where this
730cdc88
ILT
406 // input section should go. RELOC_SHNDX is the index of a
407 // relocation section which applies to this section, or 0 if none,
408 // or -1U if more than one. RELOC_TYPE is the type of the
409 // relocation section if there is one. Set *OFFSET to the offset
410 // within the output section.
a2fb1b05
ILT
411 template<int size, bool big_endian>
412 Output_section*
730cdc88
ILT
413 layout(Sized_relobj<size, big_endian> *object, unsigned int shndx,
414 const char* name, const elfcpp::Shdr<size, big_endian>& shdr,
415 unsigned int reloc_shndx, unsigned int reloc_type, off_t* offset);
416
6e9ba2ca
ST
417 unsigned int
418 find_section_order_index(const std::string&);
419
420 void
421 read_layout_from_file();
422
6a74a719
ILT
423 // Layout an input reloc section when doing a relocatable link. The
424 // section is RELOC_SHNDX in OBJECT, with data in SHDR.
425 // DATA_SECTION is the reloc section to which it refers. RR is the
426 // relocatable information.
427 template<int size, bool big_endian>
428 Output_section*
429 layout_reloc(Sized_relobj<size, big_endian>* object,
430 unsigned int reloc_shndx,
431 const elfcpp::Shdr<size, big_endian>& shdr,
432 Output_section* data_section,
433 Relocatable_relocs* rr);
434
435 // Layout a group section when doing a relocatable link.
436 template<int size, bool big_endian>
437 void
438 layout_group(Symbol_table* symtab,
439 Sized_relobj<size, big_endian>* object,
440 unsigned int group_shndx,
441 const char* group_section_name,
442 const char* signature,
443 const elfcpp::Shdr<size, big_endian>& shdr,
8825ac63
ILT
444 elfcpp::Elf_Word flags,
445 std::vector<unsigned int>* shndxes);
6a74a719 446
730cdc88
ILT
447 // Like layout, only for exception frame sections. OBJECT is an
448 // object file. SYMBOLS is the contents of the symbol table
449 // section, with size SYMBOLS_SIZE. SYMBOL_NAMES is the contents of
450 // the symbol name section, with size SYMBOL_NAMES_SIZE. SHNDX is a
451 // .eh_frame section in OBJECT. SHDR is the section header.
452 // RELOC_SHNDX is the index of a relocation section which applies to
453 // this section, or 0 if none, or -1U if more than one. RELOC_TYPE
454 // is the type of the relocation section if there is one. This
455 // returns the output section, and sets *OFFSET to the offset.
456 template<int size, bool big_endian>
457 Output_section*
458 layout_eh_frame(Sized_relobj<size, big_endian>* object,
459 const unsigned char* symbols,
460 off_t symbols_size,
461 const unsigned char* symbol_names,
462 off_t symbol_names_size,
463 unsigned int shndx,
464 const elfcpp::Shdr<size, big_endian>& shdr,
465 unsigned int reloc_shndx, unsigned int reloc_type,
466 off_t* offset);
a2fb1b05 467
35cdfc9a
ILT
468 // Handle a GNU stack note. This is called once per input object
469 // file. SEEN_GNU_STACK is true if the object file has a
470 // .note.GNU-stack section. GNU_STACK_FLAGS is the section flags
471 // from that section if there was one.
472 void
83e17bd5
CC
473 layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags,
474 const Object*);
35cdfc9a 475
ead1e424 476 // Add an Output_section_data to the layout. This is used for
22f0da72
ILT
477 // special sections like the GOT section. ORDER is where the
478 // section should wind up in the output segment. IS_RELRO is true
479 // for relro sections.
9f1d377b 480 Output_section*
ead1e424
ILT
481 add_output_section_data(const char* name, elfcpp::Elf_Word type,
482 elfcpp::Elf_Xword flags,
22f0da72
ILT
483 Output_section_data*, Output_section_order order,
484 bool is_relro);
1a2dff53
ILT
485
486 // Increase the size of the relro segment by this much.
487 void
488 increase_relro(unsigned int s)
489 { this->increase_relro_ += s; }
ead1e424 490
a3ad94ed
ILT
491 // Create dynamic sections if necessary.
492 void
9b07f471 493 create_initial_dynamic_sections(Symbol_table*);
a3ad94ed 494
bfd58944
ILT
495 // Define __start and __stop symbols for output sections.
496 void
9b07f471 497 define_section_symbols(Symbol_table*);
bfd58944 498
9c547ec3
ILT
499 // Create automatic note sections.
500 void
501 create_notes();
502
919ed24c
ILT
503 // Create sections for linker scripts.
504 void
505 create_script_sections()
506 { this->script_options_->create_script_sections(this); }
507
e5756efb
ILT
508 // Define symbols from any linker script.
509 void
9b07f471
ILT
510 define_script_symbols(Symbol_table* symtab)
511 { this->script_options_->add_symbols_to_table(symtab); }
e5756efb 512
755ab8af
ILT
513 // Define symbols for group signatures.
514 void
515 define_group_signatures(Symbol_table*);
516
61ba1cf9
ILT
517 // Return the Stringpool used for symbol names.
518 const Stringpool*
519 sympool() const
520 { return &this->sympool_; }
521
16649710
ILT
522 // Return the Stringpool used for dynamic symbol names and dynamic
523 // tags.
524 const Stringpool*
525 dynpool() const
526 { return &this->dynpool_; }
527
d491d34e
ILT
528 // Return the symtab_xindex section used to hold large section
529 // indexes for the normal symbol table.
530 Output_symtab_xindex*
531 symtab_xindex() const
532 { return this->symtab_xindex_; }
533
534 // Return the dynsym_xindex section used to hold large section
535 // indexes for the dynamic symbol table.
536 Output_symtab_xindex*
537 dynsym_xindex() const
538 { return this->dynsym_xindex_; }
539
a2fb1b05
ILT
540 // Return whether a section is a .gnu.linkonce section, given the
541 // section name.
542 static inline bool
543 is_linkonce(const char* name)
544 { return strncmp(name, ".gnu.linkonce", sizeof(".gnu.linkonce") - 1) == 0; }
545
d7bb5745
ILT
546 // Whether we have added an input section.
547 bool
548 have_added_input_section() const
549 { return this->have_added_input_section_; }
550
e94cf127
CC
551 // Return true if a section is a debugging section.
552 static inline bool
553 is_debug_info_section(const char* name)
554 {
555 // Debugging sections can only be recognized by name.
556 return (strncmp(name, ".debug", sizeof(".debug") - 1) == 0
a2e47362 557 || strncmp(name, ".zdebug", sizeof(".zdebug") - 1) == 0
8a4c0b0d 558 || strncmp(name, ".gnu.linkonce.wi.",
e94cf127
CC
559 sizeof(".gnu.linkonce.wi.") - 1) == 0
560 || strncmp(name, ".line", sizeof(".line") - 1) == 0
561 || strncmp(name, ".stab", sizeof(".stab") - 1) == 0);
562 }
563
8a4c0b0d
ILT
564 // Check if a comdat group or .gnu.linkonce section with the given
565 // NAME is selected for the link. If there is already a section,
566 // *KEPT_SECTION is set to point to the signature and the function
1ef4d87f
ILT
567 // returns false. Otherwise, OBJECT, SHNDX,IS_COMDAT, and
568 // IS_GROUP_NAME are recorded for this NAME in the layout object,
569 // *KEPT_SECTION is set to the internal copy and the function return
570 // false.
a2fb1b05 571 bool
1ef4d87f
ILT
572 find_or_add_kept_section(const std::string& name, Relobj* object,
573 unsigned int shndx, bool is_comdat,
574 bool is_group_name, Kept_section** kept_section);
a2fb1b05 575
54dc6425 576 // Finalize the layout after all the input sections have been added.
75f65a3e 577 off_t
8851ecca 578 finalize(const Input_objects*, Symbol_table*, Target*, const Task*);
17a1d0a9
ILT
579
580 // Return whether any sections require postprocessing.
581 bool
582 any_postprocessing_sections() const
583 { return this->any_postprocessing_sections_; }
54dc6425 584
e44fcf3b
ILT
585 // Return the size of the output file.
586 off_t
587 output_file_size() const
588 { return this->output_file_size_; }
589
16649710
ILT
590 // Return the TLS segment. This will return NULL if there isn't
591 // one.
92e059d8
ILT
592 Output_segment*
593 tls_segment() const
594 { return this->tls_segment_; }
595
16649710
ILT
596 // Return the normal symbol table.
597 Output_section*
598 symtab_section() const
599 {
600 gold_assert(this->symtab_section_ != NULL);
601 return this->symtab_section_;
602 }
603
604 // Return the dynamic symbol table.
605 Output_section*
606 dynsym_section() const
607 {
608 gold_assert(this->dynsym_section_ != NULL);
609 return this->dynsym_section_;
610 }
611
612 // Return the dynamic tags.
613 Output_data_dynamic*
614 dynamic_data() const
615 { return this->dynamic_data_; }
616
730cdc88
ILT
617 // Write out the output sections.
618 void
619 write_output_sections(Output_file* of) const;
620
61ba1cf9
ILT
621 // Write out data not associated with an input file or the symbol
622 // table.
623 void
9025d29d 624 write_data(const Symbol_table*, Output_file*) const;
61ba1cf9 625
730cdc88
ILT
626 // Write out output sections which can not be written until all the
627 // input sections are complete.
628 void
27bc2bce 629 write_sections_after_input_sections(Output_file* of);
730cdc88 630
ead1e424
ILT
631 // Return an output section named NAME, or NULL if there is none.
632 Output_section*
633 find_output_section(const char* name) const;
634
635 // Return an output segment of type TYPE, with segment flags SET set
636 // and segment flags CLEAR clear. Return NULL if there is none.
637 Output_segment*
638 find_output_segment(elfcpp::PT type, elfcpp::Elf_Word set,
639 elfcpp::Elf_Word clear) const;
640
3802b2dd
ILT
641 // Return the number of segments we expect to produce.
642 size_t
643 expected_segment_count() const;
644
535890bb
ILT
645 // Set a flag to indicate that an object file uses the static TLS model.
646 void
647 set_has_static_tls()
648 { this->has_static_tls_ = true; }
649
650 // Return true if any object file uses the static TLS model.
651 bool
652 has_static_tls() const
653 { return this->has_static_tls_; }
654
e5756efb
ILT
655 // Return the options which may be set by a linker script.
656 Script_options*
657 script_options()
658 { return this->script_options_; }
659
660 const Script_options*
661 script_options() const
662 { return this->script_options_; }
d391083d 663
3ce2c28e
ILT
664 // Return the object managing inputs in incremental build. NULL in
665 // non-incremental builds.
666 Incremental_inputs*
09ec0418 667 incremental_inputs() const
3ce2c28e
ILT
668 { return this->incremental_inputs_; }
669
ea715a34
ILT
670 // For the target-specific code to add dynamic tags which are common
671 // to most targets.
672 void
673 add_target_dynamic_tags(bool use_rel, const Output_data* plt_got,
674 const Output_data* plt_rel,
3a44184e 675 const Output_data_reloc_generic* dyn_rel,
612a8d3d 676 bool add_debug, bool dynrel_includes_plt);
ea715a34 677
8ed814a9
ILT
678 // Compute and write out the build ID if needed.
679 void
680 write_build_id(Output_file*) const;
681
516cb3d0
ILT
682 // Rewrite output file in binary format.
683 void
684 write_binary(Output_file* in) const;
685
7d9e3d98
ILT
686 // Print output sections to the map file.
687 void
688 print_to_mapfile(Mapfile*) const;
689
ad8f37d1
ILT
690 // Dump statistical information to stderr.
691 void
692 print_stats() const;
693
a445fddf 694 // A list of segments.
54dc6425
ILT
695
696 typedef std::vector<Output_segment*> Segment_list;
697
a445fddf 698 // A list of sections.
54dc6425 699
a3ad94ed 700 typedef std::vector<Output_section*> Section_list;
54dc6425
ILT
701
702 // The list of information to write out which is not attached to
703 // either a section or a segment.
a3ad94ed 704 typedef std::vector<Output_data*> Data_list;
54dc6425 705
a445fddf
ILT
706 // Store the allocated sections into the section list. This is used
707 // by the linker script code.
708 void
709 get_allocated_sections(Section_list*) const;
710
919ed24c
ILT
711 // Make a section for a linker script to hold data.
712 Output_section*
1e5d2fb1
DK
713 make_output_section_for_script(const char* name,
714 Script_sections::Section_type section_type);
919ed24c 715
a445fddf
ILT
716 // Make a segment. This is used by the linker script code.
717 Output_segment*
718 make_output_segment(elfcpp::Elf_Word type, elfcpp::Elf_Word flags);
719
720 // Return the number of segments.
721 size_t
722 segment_count() const
723 { return this->segment_list_.size(); }
724
725 // Map from section flags to segment flags.
726 static elfcpp::Elf_Word
727 section_flags_to_segment(elfcpp::Elf_Xword flags);
728
154e0e9a
ILT
729 // Attach sections to segments.
730 void
731 attach_sections_to_segments();
732
20e6d0d6
DK
733 // For relaxation clean up, we need to know output section data created
734 // from a linker script.
735 void
736 new_output_section_data_from_script(Output_section_data* posd)
737 {
738 if (this->record_output_section_data_from_script_)
739 this->script_output_section_data_list_.push_back(posd);
740 }
741
c0a62865
DK
742 // Return section list.
743 const Section_list&
744 section_list() const
745 { return this->section_list_; }
746
a2fb1b05
ILT
747 private:
748 Layout(const Layout&);
749 Layout& operator=(const Layout&);
750
dff16297
ILT
751 // Mapping from input section names to output section names.
752 struct Section_name_mapping
a2fb1b05
ILT
753 {
754 const char* from;
755 int fromlen;
756 const char* to;
ead1e424 757 int tolen;
a2fb1b05 758 };
dff16297
ILT
759 static const Section_name_mapping section_name_mapping[];
760 static const int section_name_mapping_count;
a2fb1b05 761
755ab8af
ILT
762 // During a relocatable link, a list of group sections and
763 // signatures.
764 struct Group_signature
765 {
766 // The group section.
767 Output_section* section;
768 // The signature.
769 const char* signature;
770
771 Group_signature()
772 : section(NULL), signature(NULL)
773 { }
774
775 Group_signature(Output_section* sectiona, const char* signaturea)
776 : section(sectiona), signature(signaturea)
777 { }
778 };
779 typedef std::vector<Group_signature> Group_signatures;
780
ef4ab7a8 781 // Create a note section, filling in the header.
8ed814a9 782 Output_section*
ca09d69a 783 create_note(const char* name, int note_type, const char* section_name,
ef4ab7a8 784 size_t descsz, bool allocate, size_t* trailing_padding);
8ed814a9 785
ef4ab7a8 786 // Create a note section for gold version.
4f211c8b 787 void
35cdfc9a
ILT
788 create_gold_note();
789
790 // Record whether the stack must be executable.
791 void
9c547ec3 792 create_executable_stack_info();
4f211c8b 793
8ed814a9
ILT
794 // Create a build ID note if needed.
795 void
796 create_build_id();
797
1518dc8f
ILT
798 // Link .stab and .stabstr sections.
799 void
800 link_stabs_sections();
801
3ce2c28e
ILT
802 // Create .gnu_incremental_inputs and .gnu_incremental_strtab sections needed
803 // for the next run of incremental linking to check what has changed.
804 void
09ec0418 805 create_incremental_info_sections(Symbol_table*);
3ce2c28e 806
75f65a3e
ILT
807 // Find the first read-only PT_LOAD segment, creating one if
808 // necessary.
809 Output_segment*
810 find_first_load_seg();
811
7bf1f802
ILT
812 // Count the local symbols in the regular symbol table and the dynamic
813 // symbol table, and build the respective string pools.
814 void
17a1d0a9 815 count_local_symbols(const Task*, const Input_objects*);
7bf1f802 816
54dc6425
ILT
817 // Create the output sections for the symbol table.
818 void
d491d34e
ILT
819 create_symtab_sections(const Input_objects*, Symbol_table*,
820 unsigned int, off_t*);
54dc6425 821
75f65a3e
ILT
822 // Create the .shstrtab section.
823 Output_section*
824 create_shstrtab();
825
826 // Create the section header table.
27bc2bce 827 void
d491d34e 828 create_shdrs(const Output_section* shstrtab_section, off_t*);
54dc6425 829
dbe717ef
ILT
830 // Create the dynamic symbol table.
831 void
9b07f471
ILT
832 create_dynamic_symtab(const Input_objects*, Symbol_table*,
833 Output_section** pdynstr,
14b31740
ILT
834 unsigned int* plocal_dynamic_count,
835 std::vector<Symbol*>* pdynamic_symbols,
836 Versions* versions);
dbe717ef 837
7bf1f802
ILT
838 // Assign offsets to each local portion of the dynamic symbol table.
839 void
840 assign_local_dynsym_offsets(const Input_objects*);
841
a3ad94ed 842 // Finish the .dynamic section and PT_DYNAMIC segment.
dbe717ef 843 void
16649710 844 finish_dynamic_section(const Input_objects*, const Symbol_table*);
dbe717ef 845
f0ba79e2
ILT
846 // Set the size of the _DYNAMIC symbol.
847 void
848 set_dynamic_symbol_size(const Symbol_table*);
849
dbe717ef
ILT
850 // Create the .interp section and PT_INTERP segment.
851 void
852 create_interp(const Target* target);
853
14b31740
ILT
854 // Create the version sections.
855 void
9025d29d 856 create_version_sections(const Versions*,
46fe1623 857 const Symbol_table*,
14b31740
ILT
858 unsigned int local_symcount,
859 const std::vector<Symbol*>& dynamic_symbols,
860 const Output_section* dynstr);
861
862 template<int size, bool big_endian>
863 void
864 sized_create_version_sections(const Versions* versions,
46fe1623 865 const Symbol_table*,
14b31740
ILT
866 unsigned int local_symcount,
867 const std::vector<Symbol*>& dynamic_symbols,
7d1a9ebb 868 const Output_section* dynstr);
14b31740 869
a2fb1b05
ILT
870 // Return whether to include this section in the link.
871 template<int size, bool big_endian>
872 bool
730cdc88 873 include_section(Sized_relobj<size, big_endian>* object, const char* name,
a2fb1b05
ILT
874 const elfcpp::Shdr<size, big_endian>&);
875
ead1e424
ILT
876 // Return the output section name to use given an input section
877 // name. Set *PLEN to the length of the name. *PLEN must be
878 // initialized to the length of NAME.
879 static const char*
880 output_section_name(const char* name, size_t* plen);
881
d491d34e
ILT
882 // Return the number of allocated output sections.
883 size_t
884 allocated_output_section_count() const;
885
ead1e424
ILT
886 // Return the output section for NAME, TYPE and FLAGS.
887 Output_section*
f0641a0b 888 get_output_section(const char* name, Stringpool::Key name_key,
f5c870d2 889 elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
22f0da72 890 Output_section_order order, bool is_relro);
a2fb1b05 891
a445fddf
ILT
892 // Choose the output section for NAME in RELOBJ.
893 Output_section*
894 choose_output_section(const Relobj* relobj, const char* name,
895 elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
22f0da72
ILT
896 bool is_input_section, Output_section_order order,
897 bool is_relro);
a445fddf 898
a2fb1b05
ILT
899 // Create a new Output_section.
900 Output_section*
901 make_output_section(const char* name, elfcpp::Elf_Word type,
22f0da72
ILT
902 elfcpp::Elf_Xword flags, Output_section_order order,
903 bool is_relro);
a2fb1b05 904
4e2b1697
ILT
905 // Attach a section to a segment.
906 void
154e0e9a 907 attach_section_to_segment(Output_section*);
4e2b1697 908
22f0da72
ILT
909 // Get section order.
910 Output_section_order
911 default_section_order(Output_section*, bool is_relro_local);
912
154e0e9a 913 // Attach an allocated section to a segment.
1650c4ff 914 void
154e0e9a 915 attach_allocated_section_to_segment(Output_section*);
1650c4ff 916
dbe717ef
ILT
917 // Set the final file offsets of all the segments.
918 off_t
919 set_segment_offsets(const Target*, Output_segment*, unsigned int* pshndx);
920
6a74a719
ILT
921 // Set the file offsets of the sections when doing a relocatable
922 // link.
923 off_t
924 set_relocatable_section_offsets(Output_data*, unsigned int* pshndx);
925
86887060 926 // Set the final file offsets of all the sections not associated
9a0910c3
ILT
927 // with a segment. We set section offsets in three passes: the
928 // first handles all allocated sections, the second sections that
17a1d0a9
ILT
929 // require postprocessing, and the last the late-bound STRTAB
930 // sections (probably only shstrtab, which is the one we care about
931 // because it holds section names).
9a0910c3
ILT
932 enum Section_offset_pass
933 {
934 BEFORE_INPUT_SECTIONS_PASS,
17a1d0a9
ILT
935 POSTPROCESSING_SECTIONS_PASS,
936 STRTAB_AFTER_POSTPROCESSING_SECTIONS_PASS
9a0910c3 937 };
dbe717ef 938 off_t
9a0910c3
ILT
939 set_section_offsets(off_t, Section_offset_pass pass);
940
86887060
ILT
941 // Set the final section indexes of all the sections not associated
942 // with a segment. Returns the next unused index.
943 unsigned int
944 set_section_indexes(unsigned int pshndx);
dbe717ef 945
a445fddf
ILT
946 // Set the section addresses when using a script.
947 Output_segment*
948 set_section_addresses_from_script(Symbol_table*);
949
20e6d0d6
DK
950 // Find appropriate places or orphan sections in a script.
951 void
952 place_orphan_sections_in_script();
953
a2fb1b05
ILT
954 // Return whether SEG1 comes before SEG2 in the output file.
955 static bool
b3168e9d 956 segment_precedes(const Output_segment* seg1, const Output_segment* seg2);
a2fb1b05 957
20e6d0d6
DK
958 // Use to save and restore segments during relaxation.
959 typedef Unordered_map<const Output_segment*, const Output_segment*>
960 Segment_states;
961
962 // Save states of current output segments.
963 void
964 save_segments(Segment_states*);
965
966 // Restore output segment states.
967 void
968 restore_segments(const Segment_states*);
969
970 // Clean up after relaxation so that it is possible to lay out the
971 // sections and segments again.
972 void
973 clean_up_after_relaxation();
974
975 // Doing preparation work for relaxation. This is factored out to make
976 // Layout::finalized a bit smaller and easier to read.
977 void
978 prepare_for_relaxation();
979
980 // Main body of the relaxation loop, which lays out the section.
981 off_t
982 relaxation_loop_body(int, Target*, Symbol_table*, Output_segment**,
983 Output_segment*, Output_segment_headers*,
984 Output_file_header*, unsigned int*);
985
8a4c0b0d 986 // A mapping used for kept comdats/.gnu.linkonce group signatures.
e94cf127 987 typedef Unordered_map<std::string, Kept_section> Signatures;
a2fb1b05
ILT
988
989 // Mapping from input section name/type/flags to output section. We
990 // use canonicalized strings here.
991
f0641a0b 992 typedef std::pair<Stringpool::Key,
a2fb1b05
ILT
993 std::pair<elfcpp::Elf_Word, elfcpp::Elf_Xword> > Key;
994
995 struct Hash_key
996 {
997 size_t
998 operator()(const Key& k) const;
999 };
1000
1001 typedef Unordered_map<Key, Output_section*, Hash_key> Section_name_map;
1002
1003 // A comparison class for segments.
1004
1005 struct Compare_segments
1006 {
1007 bool
1008 operator()(const Output_segment* seg1, const Output_segment* seg2)
1009 { return Layout::segment_precedes(seg1, seg2); }
1010 };
1011
20e6d0d6
DK
1012 typedef std::vector<Output_section_data*> Output_section_data_list;
1013
1014 // Debug checker class.
1015 class Relaxation_debug_check
1016 {
1017 public:
1018 Relaxation_debug_check()
1019 : section_infos_()
1020 { }
1021
1022 // Check that sections and special data are in reset states.
1023 void
1024 check_output_data_for_reset_values(const Layout::Section_list&,
1025 const Layout::Data_list&);
1026
1027 // Record information of a section list.
1028 void
1029 read_sections(const Layout::Section_list&);
1030
1031 // Verify a section list with recorded information.
1032 void
1033 verify_sections(const Layout::Section_list&);
1034
1035 private:
1036 // Information we care about a section.
1037 struct Section_info
1038 {
1039 // Output section described by this.
1040 Output_section* output_section;
1041 // Load address.
1042 uint64_t address;
1043 // Data size.
1044 off_t data_size;
1045 // File offset.
1046 off_t offset;
1047 };
1048
1049 // Section information.
1050 std::vector<Section_info> section_infos_;
1051 };
1052
e55bde5e
ILT
1053 // The number of input files, for sizing tables.
1054 int number_of_input_files_;
e5756efb
ILT
1055 // Information set by scripts or by command line options.
1056 Script_options* script_options_;
a2fb1b05
ILT
1057 // The output section names.
1058 Stringpool namepool_;
75f65a3e
ILT
1059 // The output symbol names.
1060 Stringpool sympool_;
a3ad94ed
ILT
1061 // The dynamic strings, if needed.
1062 Stringpool dynpool_;
a2fb1b05
ILT
1063 // The list of group sections and linkonce sections which we have seen.
1064 Signatures signatures_;
1065 // The mapping from input section name/type/flags to output sections.
1066 Section_name_map section_name_map_;
1067 // The list of output segments.
1068 Segment_list segment_list_;
a3ad94ed
ILT
1069 // The list of output sections.
1070 Section_list section_list_;
a2fb1b05
ILT
1071 // The list of output sections which are not attached to any output
1072 // segment.
a3ad94ed
ILT
1073 Section_list unattached_section_list_;
1074 // The list of unattached Output_data objects which require special
1075 // handling because they are not Output_sections.
61ba1cf9 1076 Data_list special_output_list_;
27bc2bce
ILT
1077 // The section headers.
1078 Output_section_headers* section_headers_;
92e059d8
ILT
1079 // A pointer to the PT_TLS segment if there is one.
1080 Output_segment* tls_segment_;
9f1d377b
ILT
1081 // A pointer to the PT_GNU_RELRO segment if there is one.
1082 Output_segment* relro_segment_;
1a2dff53
ILT
1083 // A backend may increase the size of the PT_GNU_RELRO segment if
1084 // there is one. This is the amount to increase it by.
1085 unsigned int increase_relro_;
a3ad94ed
ILT
1086 // The SHT_SYMTAB output section.
1087 Output_section* symtab_section_;
d491d34e
ILT
1088 // The SHT_SYMTAB_SHNDX for the regular symbol table if there is one.
1089 Output_symtab_xindex* symtab_xindex_;
a3ad94ed
ILT
1090 // The SHT_DYNSYM output section if there is one.
1091 Output_section* dynsym_section_;
d491d34e
ILT
1092 // The SHT_SYMTAB_SHNDX for the dynamic symbol table if there is one.
1093 Output_symtab_xindex* dynsym_xindex_;
a3ad94ed
ILT
1094 // The SHT_DYNAMIC output section if there is one.
1095 Output_section* dynamic_section_;
f0ba79e2
ILT
1096 // The _DYNAMIC symbol if there is one.
1097 Symbol* dynamic_symbol_;
16649710
ILT
1098 // The dynamic data which goes into dynamic_section_.
1099 Output_data_dynamic* dynamic_data_;
730cdc88 1100 // The exception frame output section if there is one.
3151305a 1101 Output_section* eh_frame_section_;
730cdc88
ILT
1102 // The exception frame data for eh_frame_section_.
1103 Eh_frame* eh_frame_data_;
2c38906f
ILT
1104 // Whether we have added eh_frame_data_ to the .eh_frame section.
1105 bool added_eh_frame_data_;
730cdc88
ILT
1106 // The exception frame header output section if there is one.
1107 Output_section* eh_frame_hdr_section_;
8ed814a9
ILT
1108 // The space for the build ID checksum if there is one.
1109 Output_section_data* build_id_note_;
62b01cb5
ILT
1110 // The output section containing dwarf abbreviations
1111 Output_reduced_debug_abbrev_section* debug_abbrev_;
1112 // The output section containing the dwarf debug info tree
1113 Output_reduced_debug_info_section* debug_info_;
755ab8af
ILT
1114 // A list of group sections and their signatures.
1115 Group_signatures group_signatures_;
e44fcf3b
ILT
1116 // The size of the output file.
1117 off_t output_file_size_;
d7bb5745
ILT
1118 // Whether we have added an input section to an output section.
1119 bool have_added_input_section_;
e55bde5e
ILT
1120 // Whether we have attached the sections to the segments.
1121 bool sections_are_attached_;
35cdfc9a
ILT
1122 // Whether we have seen an object file marked to require an
1123 // executable stack.
1124 bool input_requires_executable_stack_;
1125 // Whether we have seen at least one object file with an executable
1126 // stack marker.
1127 bool input_with_gnu_stack_note_;
1128 // Whether we have seen at least one object file without an
1129 // executable stack marker.
1130 bool input_without_gnu_stack_note_;
535890bb
ILT
1131 // Whether we have seen an object file that uses the static TLS model.
1132 bool has_static_tls_;
17a1d0a9
ILT
1133 // Whether any sections require postprocessing.
1134 bool any_postprocessing_sections_;
e55bde5e
ILT
1135 // Whether we have resized the signatures_ hash table.
1136 bool resized_signatures_;
1518dc8f
ILT
1137 // Whether we have created a .stab*str output section.
1138 bool have_stabstr_section_;
3ce2c28e
ILT
1139 // In incremental build, holds information check the inputs and build the
1140 // .gnu_incremental_inputs section.
1141 Incremental_inputs* incremental_inputs_;
20e6d0d6
DK
1142 // Whether we record output section data created in script
1143 bool record_output_section_data_from_script_;
9b547ce6 1144 // List of output data that needs to be removed at relaxation clean up.
20e6d0d6
DK
1145 Output_section_data_list script_output_section_data_list_;
1146 // Structure to save segment states before entering the relaxation loop.
1147 Segment_states* segment_states_;
1148 // A relaxation debug checker. We only create one when in debugging mode.
1149 Relaxation_debug_check* relaxation_debug_check_;
6e9ba2ca
ST
1150 // Hash a pattern to its position in the section ordering file.
1151 Unordered_map<std::string, unsigned int> input_section_position_;
1152 // Vector of glob only patterns in the section_ordering file.
1153 std::vector<std::string> input_section_glob_;
61ba1cf9
ILT
1154};
1155
730cdc88
ILT
1156// This task handles writing out data in output sections which is not
1157// part of an input section, or which requires special handling. When
1158// this is done, it unblocks both output_sections_blocker and
1159// final_blocker.
1160
1161class Write_sections_task : public Task
1162{
1163 public:
1164 Write_sections_task(const Layout* layout, Output_file* of,
1165 Task_token* output_sections_blocker,
1166 Task_token* final_blocker)
1167 : layout_(layout), of_(of),
1168 output_sections_blocker_(output_sections_blocker),
1169 final_blocker_(final_blocker)
1170 { }
1171
1172 // The standard Task methods.
1173
17a1d0a9
ILT
1174 Task_token*
1175 is_runnable();
730cdc88 1176
17a1d0a9
ILT
1177 void
1178 locks(Task_locker*);
730cdc88
ILT
1179
1180 void
1181 run(Workqueue*);
1182
c7912668
ILT
1183 std::string
1184 get_name() const
1185 { return "Write_sections_task"; }
1186
730cdc88
ILT
1187 private:
1188 class Write_sections_locker;
1189
1190 const Layout* layout_;
1191 Output_file* of_;
1192 Task_token* output_sections_blocker_;
1193 Task_token* final_blocker_;
1194};
1195
61ba1cf9
ILT
1196// This task handles writing out data which is not part of a section
1197// or segment.
1198
1199class Write_data_task : public Task
1200{
1201 public:
a3ad94ed 1202 Write_data_task(const Layout* layout, const Symbol_table* symtab,
9025d29d
ILT
1203 Output_file* of, Task_token* final_blocker)
1204 : layout_(layout), symtab_(symtab), of_(of), final_blocker_(final_blocker)
61ba1cf9
ILT
1205 { }
1206
1207 // The standard Task methods.
1208
17a1d0a9
ILT
1209 Task_token*
1210 is_runnable();
61ba1cf9 1211
17a1d0a9
ILT
1212 void
1213 locks(Task_locker*);
61ba1cf9
ILT
1214
1215 void
1216 run(Workqueue*);
1217
c7912668
ILT
1218 std::string
1219 get_name() const
1220 { return "Write_data_task"; }
1221
61ba1cf9
ILT
1222 private:
1223 const Layout* layout_;
a3ad94ed 1224 const Symbol_table* symtab_;
61ba1cf9
ILT
1225 Output_file* of_;
1226 Task_token* final_blocker_;
1227};
1228
1229// This task handles writing out the global symbols.
1230
1231class Write_symbols_task : public Task
1232{
1233 public:
d491d34e 1234 Write_symbols_task(const Layout* layout, const Symbol_table* symtab,
9a2d6984 1235 const Input_objects* input_objects,
16649710
ILT
1236 const Stringpool* sympool, const Stringpool* dynpool,
1237 Output_file* of, Task_token* final_blocker)
d491d34e
ILT
1238 : layout_(layout), symtab_(symtab), input_objects_(input_objects),
1239 sympool_(sympool), dynpool_(dynpool), of_(of),
1240 final_blocker_(final_blocker)
61ba1cf9
ILT
1241 { }
1242
1243 // The standard Task methods.
1244
17a1d0a9
ILT
1245 Task_token*
1246 is_runnable();
61ba1cf9 1247
17a1d0a9
ILT
1248 void
1249 locks(Task_locker*);
61ba1cf9
ILT
1250
1251 void
1252 run(Workqueue*);
1253
c7912668
ILT
1254 std::string
1255 get_name() const
1256 { return "Write_symbols_task"; }
1257
61ba1cf9 1258 private:
d491d34e 1259 const Layout* layout_;
61ba1cf9 1260 const Symbol_table* symtab_;
9a2d6984 1261 const Input_objects* input_objects_;
61ba1cf9 1262 const Stringpool* sympool_;
16649710 1263 const Stringpool* dynpool_;
61ba1cf9
ILT
1264 Output_file* of_;
1265 Task_token* final_blocker_;
1266};
1267
730cdc88
ILT
1268// This task handles writing out data in output sections which can't
1269// be written out until all the input sections have been handled.
1270// This is for sections whose contents is based on the contents of
1271// other output sections.
1272
1273class Write_after_input_sections_task : public Task
1274{
1275 public:
27bc2bce 1276 Write_after_input_sections_task(Layout* layout, Output_file* of,
730cdc88
ILT
1277 Task_token* input_sections_blocker,
1278 Task_token* final_blocker)
1279 : layout_(layout), of_(of),
1280 input_sections_blocker_(input_sections_blocker),
1281 final_blocker_(final_blocker)
1282 { }
1283
1284 // The standard Task methods.
1285
17a1d0a9
ILT
1286 Task_token*
1287 is_runnable();
730cdc88 1288
17a1d0a9
ILT
1289 void
1290 locks(Task_locker*);
730cdc88
ILT
1291
1292 void
1293 run(Workqueue*);
1294
c7912668
ILT
1295 std::string
1296 get_name() const
1297 { return "Write_after_input_sections_task"; }
1298
730cdc88 1299 private:
27bc2bce 1300 Layout* layout_;
730cdc88
ILT
1301 Output_file* of_;
1302 Task_token* input_sections_blocker_;
1303 Task_token* final_blocker_;
1304};
1305
92e059d8 1306// This task function handles closing the file.
61ba1cf9 1307
92e059d8 1308class Close_task_runner : public Task_function_runner
61ba1cf9
ILT
1309{
1310 public:
516cb3d0
ILT
1311 Close_task_runner(const General_options* options, const Layout* layout,
1312 Output_file* of)
1313 : options_(options), layout_(layout), of_(of)
61ba1cf9
ILT
1314 { }
1315
92e059d8 1316 // Run the operation.
61ba1cf9 1317 void
17a1d0a9 1318 run(Workqueue*, const Task*);
61ba1cf9
ILT
1319
1320 private:
516cb3d0
ILT
1321 const General_options* options_;
1322 const Layout* layout_;
61ba1cf9 1323 Output_file* of_;
a2fb1b05
ILT
1324};
1325
ead1e424
ILT
1326// A small helper function to align an address.
1327
1328inline uint64_t
1329align_address(uint64_t address, uint64_t addralign)
1330{
1331 if (addralign != 0)
1332 address = (address + addralign - 1) &~ (addralign - 1);
1333 return address;
1334}
1335
a2fb1b05
ILT
1336} // End namespace gold.
1337
1338#endif // !defined(GOLD_LAYOUT_H)
This page took 0.26542 seconds and 4 git commands to generate.