1 // layout.cc -- lay out output file sections for gold
18 // Layout_task_runner methods.
20 // Lay out the sections. This is called after all the input objects
24 Layout_task_runner::run(Workqueue* workqueue)
26 off_t file_size = this->layout_->finalize(this->input_objects_,
29 // Now we know the final size of the output file and we know where
30 // each piece of information goes.
31 Output_file* of = new Output_file(this->options_);
34 // Queue up the final set of tasks.
35 gold::queue_final_tasks(this->options_, this->input_objects_,
36 this->symtab_, this->layout_, workqueue, of);
41 Layout::Layout(const General_options& options)
42 : options_(options), namepool_(), sympool_(), signatures_(),
43 section_name_map_(), segment_list_(), section_list_(),
44 special_output_list_(), tls_segment_(NULL)
46 // Make space for more than enough segments for a typical file.
47 // This is just for efficiency--it's OK if we wind up needing more.
48 segment_list_.reserve(12);
51 // Hash a key we use to look up an output section mapping.
54 Layout::Hash_key::operator()(const Layout::Key& k) const
56 return reinterpret_cast<size_t>(k.first) + k.second.first + k.second.second;
59 // Whether to include this section in the link.
61 template<int size, bool big_endian>
63 Layout::include_section(Object*, const char*,
64 const elfcpp::Shdr<size, big_endian>& shdr)
66 // Some section types are never linked. Some are only linked when
67 // doing a relocateable link.
68 switch (shdr.get_sh_type())
70 case elfcpp::SHT_NULL:
71 case elfcpp::SHT_SYMTAB:
72 case elfcpp::SHT_DYNSYM:
73 case elfcpp::SHT_STRTAB:
74 case elfcpp::SHT_HASH:
75 case elfcpp::SHT_DYNAMIC:
76 case elfcpp::SHT_SYMTAB_SHNDX:
79 case elfcpp::SHT_RELA:
81 case elfcpp::SHT_GROUP:
82 return this->options_.is_relocatable();
85 // FIXME: Handle stripping debug sections here.
90 // Return an output section named NAME, or NULL if there is none.
93 Layout::find_output_section(const char* name) const
95 for (Section_name_map::const_iterator p = this->section_name_map_.begin();
96 p != this->section_name_map_.end();
98 if (strcmp(p->first.first, name) == 0)
103 // Return an output segment of type TYPE, with segment flags SET set
104 // and segment flags CLEAR clear. Return NULL if there is none.
107 Layout::find_output_segment(elfcpp::PT type, elfcpp::Elf_Word set,
108 elfcpp::Elf_Word clear) const
110 for (Segment_list::const_iterator p = this->segment_list_.begin();
111 p != this->segment_list_.end();
113 if (static_cast<elfcpp::PT>((*p)->type()) == type
114 && ((*p)->flags() & set) == set
115 && ((*p)->flags() & clear) == 0)
120 // Return the output section to use for section NAME with type TYPE
121 // and section flags FLAGS.
124 Layout::get_output_section(const char* name, elfcpp::Elf_Word type,
125 elfcpp::Elf_Xword flags)
127 // We should ignore some flags.
128 flags &= ~ (elfcpp::SHF_INFO_LINK
129 | elfcpp::SHF_LINK_ORDER
130 | elfcpp::SHF_GROUP);
132 const Key key(name, std::make_pair(type, flags));
133 const std::pair<Key, Output_section*> v(key, NULL);
134 std::pair<Section_name_map::iterator, bool> ins(
135 this->section_name_map_.insert(v));
138 return ins.first->second;
141 // This is the first time we've seen this name/type/flags
143 Output_section* os = this->make_output_section(name, type, flags);
144 ins.first->second = os;
149 // Return the output section to use for input section SHNDX, with name
150 // NAME, with header HEADER, from object OBJECT. Set *OFF to the
151 // offset of this input section without the output section.
153 template<int size, bool big_endian>
155 Layout::layout(Relobj* object, unsigned int shndx, const char* name,
156 const elfcpp::Shdr<size, big_endian>& shdr, off_t* off)
158 if (!this->include_section(object, name, shdr))
161 // If we are not doing a relocateable link, choose the name to use
162 // for the output section.
163 size_t len = strlen(name);
164 if (!this->options_.is_relocatable())
165 name = Layout::output_section_name(name, &len);
167 // FIXME: Handle SHF_OS_NONCONFORMING here.
169 // Canonicalize the section name.
170 name = this->namepool_.add(name, len);
172 // Find the output section. The output section is selected based on
173 // the section name, type, and flags.
174 Output_section* os = this->get_output_section(name, shdr.get_sh_type(),
175 shdr.get_sh_flags());
177 // FIXME: Handle SHF_LINK_ORDER somewhere.
179 *off = os->add_input_section(object, shndx, name, shdr);
184 // Add POSD to an output section using NAME, TYPE, and FLAGS.
187 Layout::add_output_section_data(const char* name, elfcpp::Elf_Word type,
188 elfcpp::Elf_Xword flags,
189 Output_section_data* posd)
191 // Canonicalize the name.
192 name = this->namepool_.add(name);
194 Output_section* os = this->get_output_section(name, type, flags);
195 os->add_output_section_data(posd);
198 // Map section flags to segment flags.
201 Layout::section_flags_to_segment(elfcpp::Elf_Xword flags)
203 elfcpp::Elf_Word ret = elfcpp::PF_R;
204 if ((flags & elfcpp::SHF_WRITE) != 0)
206 if ((flags & elfcpp::SHF_EXECINSTR) != 0)
211 // Make a new Output_section, and attach it to segments as
215 Layout::make_output_section(const char* name, elfcpp::Elf_Word type,
216 elfcpp::Elf_Xword flags)
218 Output_section* os = new Output_section(name, type, flags, true);
220 if ((flags & elfcpp::SHF_ALLOC) == 0)
221 this->section_list_.push_back(os);
224 // This output section goes into a PT_LOAD segment.
226 elfcpp::Elf_Word seg_flags = Layout::section_flags_to_segment(flags);
228 // The only thing we really care about for PT_LOAD segments is
229 // whether or not they are writable, so that is how we search
230 // for them. People who need segments sorted on some other
231 // basis will have to wait until we implement a mechanism for
232 // them to describe the segments they want.
234 Segment_list::const_iterator p;
235 for (p = this->segment_list_.begin();
236 p != this->segment_list_.end();
239 if ((*p)->type() == elfcpp::PT_LOAD
240 && ((*p)->flags() & elfcpp::PF_W) == (seg_flags & elfcpp::PF_W))
242 (*p)->add_output_section(os, seg_flags);
247 if (p == this->segment_list_.end())
249 Output_segment* oseg = new Output_segment(elfcpp::PT_LOAD,
251 this->segment_list_.push_back(oseg);
252 oseg->add_output_section(os, seg_flags);
255 // If we see a loadable SHT_NOTE section, we create a PT_NOTE
257 if (type == elfcpp::SHT_NOTE)
259 // See if we already have an equivalent PT_NOTE segment.
260 for (p = this->segment_list_.begin();
261 p != segment_list_.end();
264 if ((*p)->type() == elfcpp::PT_NOTE
265 && (((*p)->flags() & elfcpp::PF_W)
266 == (seg_flags & elfcpp::PF_W)))
268 (*p)->add_output_section(os, seg_flags);
273 if (p == this->segment_list_.end())
275 Output_segment* oseg = new Output_segment(elfcpp::PT_NOTE,
277 this->segment_list_.push_back(oseg);
278 oseg->add_output_section(os, seg_flags);
282 // If we see a loadable SHF_TLS section, we create a PT_TLS
283 // segment. There can only be one such segment.
284 if ((flags & elfcpp::SHF_TLS) != 0)
286 if (this->tls_segment_ == NULL)
288 this->tls_segment_ = new Output_segment(elfcpp::PT_TLS,
290 this->segment_list_.push_back(this->tls_segment_);
292 this->tls_segment_->add_output_section(os, seg_flags);
299 // Find the first read-only PT_LOAD segment, creating one if
303 Layout::find_first_load_seg()
305 for (Segment_list::const_iterator p = this->segment_list_.begin();
306 p != this->segment_list_.end();
309 if ((*p)->type() == elfcpp::PT_LOAD
310 && ((*p)->flags() & elfcpp::PF_R) != 0
311 && ((*p)->flags() & elfcpp::PF_W) == 0)
315 Output_segment* load_seg = new Output_segment(elfcpp::PT_LOAD, elfcpp::PF_R);
316 this->segment_list_.push_back(load_seg);
320 // Finalize the layout. When this is called, we have created all the
321 // output sections and all the output segments which are based on
322 // input sections. We have several things to do, and we have to do
323 // them in the right order, so that we get the right results correctly
326 // 1) Finalize the list of output segments and create the segment
329 // 2) Finalize the dynamic symbol table and associated sections.
331 // 3) Determine the final file offset of all the output segments.
333 // 4) Determine the final file offset of all the SHF_ALLOC output
336 // 5) Create the symbol table sections and the section name table
339 // 6) Finalize the symbol table: set symbol values to their final
340 // value and make a final determination of which symbols are going
341 // into the output symbol table.
343 // 7) Create the section table header.
345 // 8) Determine the final file offset of all the output sections which
346 // are not SHF_ALLOC, including the section table header.
348 // 9) Finalize the ELF file header.
350 // This function returns the size of the output file.
353 Layout::finalize(const Input_objects* input_objects, Symbol_table* symtab)
355 if (input_objects->any_dynamic())
357 // If there are any dynamic objects in the link, then we need
358 // some additional segments: PT_PHDRS, PT_INTERP, and
359 // PT_DYNAMIC. We also need to finalize the dynamic symbol
360 // table and create the dynamic hash table.
364 // FIXME: Handle PT_GNU_STACK.
366 Output_segment* load_seg = this->find_first_load_seg();
368 // Lay out the segment headers.
369 int size = input_objects->target()->get_size();
370 bool big_endian = input_objects->target()->is_big_endian();
371 Output_segment_headers* segment_headers;
372 segment_headers = new Output_segment_headers(size, big_endian,
373 this->segment_list_);
374 load_seg->add_initial_output_data(segment_headers);
375 this->special_output_list_.push_back(segment_headers);
376 // FIXME: Attach them to PT_PHDRS if necessary.
378 // Lay out the file header.
379 Output_file_header* file_header;
380 file_header = new Output_file_header(size,
383 input_objects->target(),
386 load_seg->add_initial_output_data(file_header);
387 this->special_output_list_.push_back(file_header);
389 // We set the output section indexes in set_segment_offsets and
390 // set_section_offsets.
391 unsigned int shndx = 1;
393 // Set the file offsets of all the segments, and all the sections
395 off_t off = this->set_segment_offsets(input_objects->target(), load_seg,
398 // Create the symbol table sections.
399 // FIXME: We don't need to do this if we are stripping symbols.
400 Output_section* osymtab;
401 Output_section* ostrtab;
402 this->create_symtab_sections(size, input_objects, symtab, &off,
405 // Create the .shstrtab section.
406 Output_section* shstrtab_section = this->create_shstrtab();
408 // Set the file offsets of all the sections not associated with
410 off = this->set_section_offsets(off, &shndx);
412 // Now the section index of OSTRTAB is set.
413 osymtab->set_link(ostrtab->out_shndx());
415 // Create the section table header.
416 Output_section_headers* oshdrs = this->create_shdrs(size, big_endian, &off);
418 file_header->set_section_info(oshdrs, shstrtab_section);
420 // Now we know exactly where everything goes in the output file.
425 // Return whether SEG1 should be before SEG2 in the output file. This
426 // is based entirely on the segment type and flags. When this is
427 // called the segment addresses has normally not yet been set.
430 Layout::segment_precedes(const Output_segment* seg1,
431 const Output_segment* seg2)
433 elfcpp::Elf_Word type1 = seg1->type();
434 elfcpp::Elf_Word type2 = seg2->type();
436 // The single PT_PHDR segment is required to precede any loadable
437 // segment. We simply make it always first.
438 if (type1 == elfcpp::PT_PHDR)
440 assert(type2 != elfcpp::PT_PHDR);
443 if (type2 == elfcpp::PT_PHDR)
446 // The single PT_INTERP segment is required to precede any loadable
447 // segment. We simply make it always second.
448 if (type1 == elfcpp::PT_INTERP)
450 assert(type2 != elfcpp::PT_INTERP);
453 if (type2 == elfcpp::PT_INTERP)
456 // We then put PT_LOAD segments before any other segments.
457 if (type1 == elfcpp::PT_LOAD && type2 != elfcpp::PT_LOAD)
459 if (type2 == elfcpp::PT_LOAD && type1 != elfcpp::PT_LOAD)
462 // We put the PT_TLS segment last, because that is where the dynamic
463 // linker expects to find it (this is just for efficiency; other
464 // positions would also work correctly).
465 if (type1 == elfcpp::PT_TLS && type2 != elfcpp::PT_TLS)
467 if (type2 == elfcpp::PT_TLS && type1 != elfcpp::PT_TLS)
470 const elfcpp::Elf_Word flags1 = seg1->flags();
471 const elfcpp::Elf_Word flags2 = seg2->flags();
473 // The order of non-PT_LOAD segments is unimportant. We simply sort
474 // by the numeric segment type and flags values. There should not
475 // be more than one segment with the same type and flags.
476 if (type1 != elfcpp::PT_LOAD)
479 return type1 < type2;
480 assert(flags1 != flags2);
481 return flags1 < flags2;
484 // We sort PT_LOAD segments based on the flags. Readonly segments
485 // come before writable segments. Then executable segments come
486 // before non-executable segments. Then the unlikely case of a
487 // non-readable segment comes before the normal case of a readable
488 // segment. If there are multiple segments with the same type and
489 // flags, we require that the address be set, and we sort by
490 // virtual address and then physical address.
491 if ((flags1 & elfcpp::PF_W) != (flags2 & elfcpp::PF_W))
492 return (flags1 & elfcpp::PF_W) == 0;
493 if ((flags1 & elfcpp::PF_X) != (flags2 & elfcpp::PF_X))
494 return (flags1 & elfcpp::PF_X) != 0;
495 if ((flags1 & elfcpp::PF_R) != (flags2 & elfcpp::PF_R))
496 return (flags1 & elfcpp::PF_R) == 0;
498 uint64_t vaddr1 = seg1->vaddr();
499 uint64_t vaddr2 = seg2->vaddr();
500 if (vaddr1 != vaddr2)
501 return vaddr1 < vaddr2;
503 uint64_t paddr1 = seg1->paddr();
504 uint64_t paddr2 = seg2->paddr();
505 assert(paddr1 != paddr2);
506 return paddr1 < paddr2;
509 // Set the file offsets of all the segments, and all the sections they
510 // contain. They have all been created. LOAD_SEG must be be laid out
511 // first. Return the offset of the data to follow.
514 Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
515 unsigned int *pshndx)
517 // Sort them into the final order.
518 std::sort(this->segment_list_.begin(), this->segment_list_.end(),
519 Layout::Compare_segments());
521 // Find the PT_LOAD segments, and set their addresses and offsets
522 // and their section's addresses and offsets.
523 uint64_t addr = target->text_segment_address();
525 bool was_readonly = false;
526 for (Segment_list::iterator p = this->segment_list_.begin();
527 p != this->segment_list_.end();
530 if ((*p)->type() == elfcpp::PT_LOAD)
532 if (load_seg != NULL && load_seg != *p)
536 // If the last segment was readonly, and this one is not,
537 // then skip the address forward one page, maintaining the
538 // same position within the page. This lets us store both
539 // segments overlapping on a single page in the file, but
540 // the loader will put them on different pages in memory.
542 uint64_t orig_addr = addr;
543 uint64_t orig_off = off;
545 uint64_t aligned_addr = addr;
546 uint64_t abi_pagesize = target->abi_pagesize();
547 if (was_readonly && ((*p)->flags() & elfcpp::PF_W) != 0)
549 uint64_t align = (*p)->addralign();
551 addr = align_address(addr, align);
553 if ((addr & (abi_pagesize - 1)) != 0)
554 addr = addr + abi_pagesize;
557 unsigned int shndx_hold = *pshndx;
558 off = orig_off + ((addr - orig_addr) & (abi_pagesize - 1));
559 uint64_t new_addr = (*p)->set_section_addresses(addr, &off, pshndx);
561 // Now that we know the size of this segment, we may be able
562 // to save a page in memory, at the cost of wasting some
563 // file space, by instead aligning to the start of a new
564 // page. Here we use the real machine page size rather than
565 // the ABI mandated page size.
567 if (aligned_addr != addr)
569 uint64_t common_pagesize = target->common_pagesize();
570 uint64_t first_off = (common_pagesize
572 & (common_pagesize - 1)));
573 uint64_t last_off = new_addr & (common_pagesize - 1);
576 && ((aligned_addr & ~ (common_pagesize - 1))
577 != (new_addr & ~ (common_pagesize - 1)))
578 && first_off + last_off <= common_pagesize)
580 *pshndx = shndx_hold;
581 addr = align_address(aligned_addr, common_pagesize);
582 off = orig_off + ((addr - orig_addr) & (abi_pagesize - 1));
583 new_addr = (*p)->set_section_addresses(addr, &off, pshndx);
589 if (((*p)->flags() & elfcpp::PF_W) == 0)
594 // Handle the non-PT_LOAD segments, setting their offsets from their
595 // section's offsets.
596 for (Segment_list::iterator p = this->segment_list_.begin();
597 p != this->segment_list_.end();
600 if ((*p)->type() != elfcpp::PT_LOAD)
607 // Set the file offset of all the sections not associated with a
611 Layout::set_section_offsets(off_t off, unsigned int* pshndx)
613 for (Layout::Section_list::iterator p = this->section_list_.begin();
614 p != this->section_list_.end();
617 (*p)->set_out_shndx(*pshndx);
619 if ((*p)->offset() != -1)
621 off = align_address(off, (*p)->addralign());
622 (*p)->set_address(0, off);
623 off += (*p)->data_size();
628 // Create the symbol table sections.
631 Layout::create_symtab_sections(int size, const Input_objects* input_objects,
632 Symbol_table* symtab,
634 Output_section** posymtab,
635 Output_section** postrtab)
641 symsize = elfcpp::Elf_sizes<32>::sym_size;
646 symsize = elfcpp::Elf_sizes<64>::sym_size;
653 off = align_address(off, align);
654 off_t startoff = off;
656 // Save space for the dummy symbol at the start of the section. We
657 // never bother to write this out--it will just be left as zero.
660 for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
661 p != input_objects->relobj_end();
664 Task_lock_obj<Object> tlo(**p);
665 off = (*p)->finalize_local_symbols(off, &this->sympool_);
668 unsigned int local_symcount = (off - startoff) / symsize;
669 assert(local_symcount * symsize == off - startoff);
671 off = symtab->finalize(off, &this->sympool_);
673 this->sympool_.set_string_offsets();
675 const char* symtab_name = this->namepool_.add(".symtab");
676 Output_section* osymtab = new Output_section_symtab(symtab_name,
678 this->section_list_.push_back(osymtab);
680 const char* strtab_name = this->namepool_.add(".strtab");
681 Output_section *ostrtab = new Output_section_strtab(strtab_name,
683 this->section_list_.push_back(ostrtab);
684 this->special_output_list_.push_back(ostrtab);
686 osymtab->set_address(0, startoff);
687 osymtab->set_info(local_symcount);
688 osymtab->set_entsize(symsize);
689 osymtab->set_addralign(align);
696 // Create the .shstrtab section, which holds the names of the
697 // sections. At the time this is called, we have created all the
698 // output sections except .shstrtab itself.
701 Layout::create_shstrtab()
703 // FIXME: We don't need to create a .shstrtab section if we are
704 // stripping everything.
706 const char* name = this->namepool_.add(".shstrtab");
708 this->namepool_.set_string_offsets();
710 Output_section* os = new Output_section_strtab(name, &this->namepool_);
712 this->section_list_.push_back(os);
713 this->special_output_list_.push_back(os);
718 // Create the section headers. SIZE is 32 or 64. OFF is the file
721 Output_section_headers*
722 Layout::create_shdrs(int size, bool big_endian, off_t* poff)
724 Output_section_headers* oshdrs;
725 oshdrs = new Output_section_headers(size, big_endian, this->segment_list_,
728 off_t off = align_address(*poff, oshdrs->addralign());
729 oshdrs->set_address(0, off);
730 off += oshdrs->data_size();
732 this->special_output_list_.push_back(oshdrs);
736 // The mapping of .gnu.linkonce section names to real section names.
738 #define MAPPING_INIT(f, t) { f, sizeof(f) - 1, t, sizeof(t) - 1 }
739 const Layout::Linkonce_mapping Layout::linkonce_mapping[] =
741 MAPPING_INIT("d.rel.ro", ".data.rel.ro"), // Must be before "d".
742 MAPPING_INIT("t", ".text"),
743 MAPPING_INIT("r", ".rodata"),
744 MAPPING_INIT("d", ".data"),
745 MAPPING_INIT("b", ".bss"),
746 MAPPING_INIT("s", ".sdata"),
747 MAPPING_INIT("sb", ".sbss"),
748 MAPPING_INIT("s2", ".sdata2"),
749 MAPPING_INIT("sb2", ".sbss2"),
750 MAPPING_INIT("wi", ".debug_info"),
751 MAPPING_INIT("td", ".tdata"),
752 MAPPING_INIT("tb", ".tbss"),
753 MAPPING_INIT("lr", ".lrodata"),
754 MAPPING_INIT("l", ".ldata"),
755 MAPPING_INIT("lb", ".lbss"),
759 const int Layout::linkonce_mapping_count =
760 sizeof(Layout::linkonce_mapping) / sizeof(Layout::linkonce_mapping[0]);
762 // Return the name of the output section to use for a .gnu.linkonce
763 // section. This is based on the default ELF linker script of the old
764 // GNU linker. For example, we map a name like ".gnu.linkonce.t.foo"
765 // to ".text". Set *PLEN to the length of the name. *PLEN is
766 // initialized to the length of NAME.
769 Layout::linkonce_output_name(const char* name, size_t *plen)
771 const char* s = name + sizeof(".gnu.linkonce") - 1;
775 const Linkonce_mapping* plm = linkonce_mapping;
776 for (int i = 0; i < linkonce_mapping_count; ++i, ++plm)
778 if (strncmp(s, plm->from, plm->fromlen) == 0 && s[plm->fromlen] == '.')
787 // Choose the output section name to use given an input section name.
788 // Set *PLEN to the length of the name. *PLEN is initialized to the
792 Layout::output_section_name(const char* name, size_t* plen)
794 if (Layout::is_linkonce(name))
796 // .gnu.linkonce sections are laid out as though they were named
797 // for the sections are placed into.
798 return Layout::linkonce_output_name(name, plen);
801 // If the section name has no '.', or only an initial '.', we use
802 // the name unchanged (i.e., ".text" is unchanged).
804 // Otherwise, if the section name does not include ".rel", we drop
805 // the last '.' and everything that follows (i.e., ".text.XXX"
808 // Otherwise, if the section name has zero or one '.' after the
809 // ".rel", we use the name unchanged (i.e., ".rel.text" is
812 // Otherwise, we drop the last '.' and everything that follows
813 // (i.e., ".rel.text.XXX" becomes ".rel.text").
815 const char* s = name;
818 const char* sdot = strchr(s, '.');
822 const char* srel = strstr(s, ".rel");
829 sdot = strchr(srel + 1, '.');
832 sdot = strchr(sdot + 1, '.');
840 // Record the signature of a comdat section, and return whether to
841 // include it in the link. If GROUP is true, this is a regular
842 // section group. If GROUP is false, this is a group signature
843 // derived from the name of a linkonce section. We want linkonce
844 // signatures and group signatures to block each other, but we don't
845 // want a linkonce signature to block another linkonce signature.
848 Layout::add_comdat(const char* signature, bool group)
850 std::string sig(signature);
851 std::pair<Signatures::iterator, bool> ins(
852 this->signatures_.insert(std::make_pair(sig, group)));
856 // This is the first time we've seen this signature.
860 if (ins.first->second)
862 // We've already seen a real section group with this signature.
867 // This is a real section group, and we've already seen a
868 // linkonce section with tihs signature. Record that we've seen
869 // a section group, and don't include this section group.
870 ins.first->second = true;
875 // We've already seen a linkonce section and this is a linkonce
876 // section. These don't block each other--this may be the same
877 // symbol name with different section types.
882 // Write out data not associated with a section or the symbol table.
885 Layout::write_data(Output_file* of) const
887 for (Data_list::const_iterator p = this->special_output_list_.begin();
888 p != this->special_output_list_.end();
893 // Write_data_task methods.
895 // We can always run this task.
897 Task::Is_runnable_type
898 Write_data_task::is_runnable(Workqueue*)
903 // We need to unlock FINAL_BLOCKER when finished.
906 Write_data_task::locks(Workqueue* workqueue)
908 return new Task_locker_block(*this->final_blocker_, workqueue);
911 // Run the task--write out the data.
914 Write_data_task::run(Workqueue*)
916 this->layout_->write_data(this->of_);
919 // Write_symbols_task methods.
921 // We can always run this task.
923 Task::Is_runnable_type
924 Write_symbols_task::is_runnable(Workqueue*)
929 // We need to unlock FINAL_BLOCKER when finished.
932 Write_symbols_task::locks(Workqueue* workqueue)
934 return new Task_locker_block(*this->final_blocker_, workqueue);
937 // Run the task--write out the symbols.
940 Write_symbols_task::run(Workqueue*)
942 this->symtab_->write_globals(this->target_, this->sympool_, this->of_);
945 // Close_task_runner methods.
947 // Run the task--close the file.
950 Close_task_runner::run(Workqueue*)
955 // Instantiate the templates we need. We could use the configure
956 // script to restrict this to only the ones for implemented targets.
960 Layout::layout<32, false>(Relobj* object, unsigned int shndx, const char* name,
961 const elfcpp::Shdr<32, false>& shdr, off_t*);
965 Layout::layout<32, true>(Relobj* object, unsigned int shndx, const char* name,
966 const elfcpp::Shdr<32, true>& shdr, off_t*);
970 Layout::layout<64, false>(Relobj* object, unsigned int shndx, const char* name,
971 const elfcpp::Shdr<64, false>& shdr, off_t*);
975 Layout::layout<64, true>(Relobj* object, unsigned int shndx, const char* name,
976 const elfcpp::Shdr<64, true>& shdr, off_t*);
979 } // End namespace gold.