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