bfd/
[deliverable/binutils-gdb.git] / gold / output.cc
CommitLineData
a2fb1b05
ILT
1// output.cc -- manage the output file for gold
2
6cb15b7f
ILT
3// Copyright 2006, 2007 Free Software Foundation, Inc.
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#include "gold.h"
24
25#include <cstdlib>
61ba1cf9
ILT
26#include <cerrno>
27#include <fcntl.h>
28#include <unistd.h>
29#include <sys/mman.h>
4e9d8586 30#include <sys/stat.h>
75f65a3e 31#include <algorithm>
5ffcaa86 32#include "libiberty.h" // for unlink_if_ordinary()
a2fb1b05 33
7e1edb90 34#include "parameters.h"
a2fb1b05 35#include "object.h"
ead1e424
ILT
36#include "symtab.h"
37#include "reloc.h"
b8e6aad9 38#include "merge.h"
a2fb1b05
ILT
39#include "output.h"
40
41namespace gold
42{
43
a3ad94ed
ILT
44// Output_data variables.
45
46bool Output_data::sizes_are_fixed;
47
a2fb1b05
ILT
48// Output_data methods.
49
50Output_data::~Output_data()
51{
52}
53
75f65a3e
ILT
54// Set the address and offset.
55
56void
57Output_data::set_address(uint64_t addr, off_t off)
58{
59 this->address_ = addr;
60 this->offset_ = off;
61
62 // Let the child class know.
63 this->do_set_address(addr, off);
64}
65
730cdc88
ILT
66// Return the default alignment for the target size.
67
68uint64_t
69Output_data::default_alignment()
70{
71 return Output_data::default_alignment_for_size(parameters->get_size());
72}
73
75f65a3e
ILT
74// Return the default alignment for a size--32 or 64.
75
76uint64_t
730cdc88 77Output_data::default_alignment_for_size(int size)
75f65a3e
ILT
78{
79 if (size == 32)
80 return 4;
81 else if (size == 64)
82 return 8;
83 else
a3ad94ed 84 gold_unreachable();
75f65a3e
ILT
85}
86
75f65a3e
ILT
87// Output_section_header methods. This currently assumes that the
88// segment and section lists are complete at construction time.
89
90Output_section_headers::Output_section_headers(
16649710
ILT
91 const Layout* layout,
92 const Layout::Segment_list* segment_list,
93 const Layout::Section_list* unattached_section_list,
61ba1cf9 94 const Stringpool* secnamepool)
9025d29d 95 : layout_(layout),
75f65a3e 96 segment_list_(segment_list),
a3ad94ed 97 unattached_section_list_(unattached_section_list),
61ba1cf9 98 secnamepool_(secnamepool)
75f65a3e 99{
61ba1cf9
ILT
100 // Count all the sections. Start with 1 for the null section.
101 off_t count = 1;
16649710
ILT
102 for (Layout::Segment_list::const_iterator p = segment_list->begin();
103 p != segment_list->end();
75f65a3e 104 ++p)
ead1e424
ILT
105 if ((*p)->type() == elfcpp::PT_LOAD)
106 count += (*p)->output_section_count();
16649710 107 count += unattached_section_list->size();
75f65a3e 108
9025d29d 109 const int size = parameters->get_size();
75f65a3e
ILT
110 int shdr_size;
111 if (size == 32)
112 shdr_size = elfcpp::Elf_sizes<32>::shdr_size;
113 else if (size == 64)
114 shdr_size = elfcpp::Elf_sizes<64>::shdr_size;
115 else
a3ad94ed 116 gold_unreachable();
75f65a3e
ILT
117
118 this->set_data_size(count * shdr_size);
119}
120
61ba1cf9
ILT
121// Write out the section headers.
122
75f65a3e 123void
61ba1cf9 124Output_section_headers::do_write(Output_file* of)
a2fb1b05 125{
9025d29d 126 if (parameters->get_size() == 32)
61ba1cf9 127 {
9025d29d
ILT
128 if (parameters->is_big_endian())
129 {
130#ifdef HAVE_TARGET_32_BIG
131 this->do_sized_write<32, true>(of);
132#else
133 gold_unreachable();
134#endif
135 }
61ba1cf9 136 else
9025d29d
ILT
137 {
138#ifdef HAVE_TARGET_32_LITTLE
139 this->do_sized_write<32, false>(of);
140#else
141 gold_unreachable();
142#endif
143 }
61ba1cf9 144 }
9025d29d 145 else if (parameters->get_size() == 64)
61ba1cf9 146 {
9025d29d
ILT
147 if (parameters->is_big_endian())
148 {
149#ifdef HAVE_TARGET_64_BIG
150 this->do_sized_write<64, true>(of);
151#else
152 gold_unreachable();
153#endif
154 }
61ba1cf9 155 else
9025d29d
ILT
156 {
157#ifdef HAVE_TARGET_64_LITTLE
158 this->do_sized_write<64, false>(of);
159#else
160 gold_unreachable();
161#endif
162 }
61ba1cf9
ILT
163 }
164 else
a3ad94ed 165 gold_unreachable();
61ba1cf9
ILT
166}
167
168template<int size, bool big_endian>
169void
170Output_section_headers::do_sized_write(Output_file* of)
171{
172 off_t all_shdrs_size = this->data_size();
173 unsigned char* view = of->get_output_view(this->offset(), all_shdrs_size);
174
175 const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
176 unsigned char* v = view;
177
178 {
179 typename elfcpp::Shdr_write<size, big_endian> oshdr(v);
180 oshdr.put_sh_name(0);
181 oshdr.put_sh_type(elfcpp::SHT_NULL);
182 oshdr.put_sh_flags(0);
183 oshdr.put_sh_addr(0);
184 oshdr.put_sh_offset(0);
185 oshdr.put_sh_size(0);
186 oshdr.put_sh_link(0);
187 oshdr.put_sh_info(0);
188 oshdr.put_sh_addralign(0);
189 oshdr.put_sh_entsize(0);
190 }
191
192 v += shdr_size;
193
ead1e424 194 unsigned shndx = 1;
16649710
ILT
195 for (Layout::Segment_list::const_iterator p = this->segment_list_->begin();
196 p != this->segment_list_->end();
61ba1cf9 197 ++p)
593f47df 198 v = (*p)->write_section_headers SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
16649710 199 this->layout_, this->secnamepool_, v, &shndx
ead1e424 200 SELECT_SIZE_ENDIAN(size, big_endian));
a3ad94ed 201 for (Layout::Section_list::const_iterator p =
16649710
ILT
202 this->unattached_section_list_->begin();
203 p != this->unattached_section_list_->end();
61ba1cf9
ILT
204 ++p)
205 {
a3ad94ed 206 gold_assert(shndx == (*p)->out_shndx());
61ba1cf9 207 elfcpp::Shdr_write<size, big_endian> oshdr(v);
16649710 208 (*p)->write_header(this->layout_, this->secnamepool_, &oshdr);
61ba1cf9 209 v += shdr_size;
ead1e424 210 ++shndx;
61ba1cf9
ILT
211 }
212
213 of->write_output_view(this->offset(), all_shdrs_size, view);
a2fb1b05
ILT
214}
215
54dc6425
ILT
216// Output_segment_header methods.
217
61ba1cf9 218Output_segment_headers::Output_segment_headers(
61ba1cf9 219 const Layout::Segment_list& segment_list)
9025d29d 220 : segment_list_(segment_list)
61ba1cf9 221{
9025d29d 222 const int size = parameters->get_size();
61ba1cf9
ILT
223 int phdr_size;
224 if (size == 32)
225 phdr_size = elfcpp::Elf_sizes<32>::phdr_size;
226 else if (size == 64)
227 phdr_size = elfcpp::Elf_sizes<64>::phdr_size;
228 else
a3ad94ed 229 gold_unreachable();
61ba1cf9
ILT
230
231 this->set_data_size(segment_list.size() * phdr_size);
232}
233
54dc6425 234void
61ba1cf9 235Output_segment_headers::do_write(Output_file* of)
75f65a3e 236{
9025d29d 237 if (parameters->get_size() == 32)
61ba1cf9 238 {
9025d29d
ILT
239 if (parameters->is_big_endian())
240 {
241#ifdef HAVE_TARGET_32_BIG
242 this->do_sized_write<32, true>(of);
243#else
244 gold_unreachable();
245#endif
246 }
61ba1cf9 247 else
9025d29d
ILT
248 {
249#ifdef HAVE_TARGET_32_LITTLE
61ba1cf9 250 this->do_sized_write<32, false>(of);
9025d29d
ILT
251#else
252 gold_unreachable();
253#endif
254 }
61ba1cf9 255 }
9025d29d 256 else if (parameters->get_size() == 64)
61ba1cf9 257 {
9025d29d
ILT
258 if (parameters->is_big_endian())
259 {
260#ifdef HAVE_TARGET_64_BIG
261 this->do_sized_write<64, true>(of);
262#else
263 gold_unreachable();
264#endif
265 }
61ba1cf9 266 else
9025d29d
ILT
267 {
268#ifdef HAVE_TARGET_64_LITTLE
269 this->do_sized_write<64, false>(of);
270#else
271 gold_unreachable();
272#endif
273 }
61ba1cf9
ILT
274 }
275 else
a3ad94ed 276 gold_unreachable();
61ba1cf9
ILT
277}
278
279template<int size, bool big_endian>
280void
281Output_segment_headers::do_sized_write(Output_file* of)
282{
283 const int phdr_size = elfcpp::Elf_sizes<size>::phdr_size;
284 off_t all_phdrs_size = this->segment_list_.size() * phdr_size;
285 unsigned char* view = of->get_output_view(this->offset(),
286 all_phdrs_size);
287 unsigned char* v = view;
288 for (Layout::Segment_list::const_iterator p = this->segment_list_.begin();
289 p != this->segment_list_.end();
290 ++p)
291 {
292 elfcpp::Phdr_write<size, big_endian> ophdr(v);
293 (*p)->write_header(&ophdr);
294 v += phdr_size;
295 }
296
297 of->write_output_view(this->offset(), all_phdrs_size, view);
75f65a3e
ILT
298}
299
300// Output_file_header methods.
301
9025d29d 302Output_file_header::Output_file_header(const Target* target,
75f65a3e
ILT
303 const Symbol_table* symtab,
304 const Output_segment_headers* osh)
9025d29d 305 : target_(target),
75f65a3e 306 symtab_(symtab),
61ba1cf9 307 segment_header_(osh),
75f65a3e
ILT
308 section_header_(NULL),
309 shstrtab_(NULL)
310{
9025d29d 311 const int size = parameters->get_size();
61ba1cf9
ILT
312 int ehdr_size;
313 if (size == 32)
314 ehdr_size = elfcpp::Elf_sizes<32>::ehdr_size;
315 else if (size == 64)
316 ehdr_size = elfcpp::Elf_sizes<64>::ehdr_size;
317 else
a3ad94ed 318 gold_unreachable();
61ba1cf9
ILT
319
320 this->set_data_size(ehdr_size);
75f65a3e
ILT
321}
322
323// Set the section table information for a file header.
324
325void
326Output_file_header::set_section_info(const Output_section_headers* shdrs,
327 const Output_section* shstrtab)
328{
329 this->section_header_ = shdrs;
330 this->shstrtab_ = shstrtab;
331}
332
333// Write out the file header.
334
335void
61ba1cf9 336Output_file_header::do_write(Output_file* of)
54dc6425 337{
9025d29d 338 if (parameters->get_size() == 32)
61ba1cf9 339 {
9025d29d
ILT
340 if (parameters->is_big_endian())
341 {
342#ifdef HAVE_TARGET_32_BIG
343 this->do_sized_write<32, true>(of);
344#else
345 gold_unreachable();
346#endif
347 }
61ba1cf9 348 else
9025d29d
ILT
349 {
350#ifdef HAVE_TARGET_32_LITTLE
351 this->do_sized_write<32, false>(of);
352#else
353 gold_unreachable();
354#endif
355 }
61ba1cf9 356 }
9025d29d 357 else if (parameters->get_size() == 64)
61ba1cf9 358 {
9025d29d
ILT
359 if (parameters->is_big_endian())
360 {
361#ifdef HAVE_TARGET_64_BIG
362 this->do_sized_write<64, true>(of);
363#else
364 gold_unreachable();
365#endif
366 }
61ba1cf9 367 else
9025d29d
ILT
368 {
369#ifdef HAVE_TARGET_64_LITTLE
370 this->do_sized_write<64, false>(of);
371#else
372 gold_unreachable();
373#endif
374 }
61ba1cf9
ILT
375 }
376 else
a3ad94ed 377 gold_unreachable();
61ba1cf9
ILT
378}
379
380// Write out the file header with appropriate size and endianess.
381
382template<int size, bool big_endian>
383void
384Output_file_header::do_sized_write(Output_file* of)
385{
a3ad94ed 386 gold_assert(this->offset() == 0);
61ba1cf9
ILT
387
388 int ehdr_size = elfcpp::Elf_sizes<size>::ehdr_size;
389 unsigned char* view = of->get_output_view(0, ehdr_size);
390 elfcpp::Ehdr_write<size, big_endian> oehdr(view);
391
392 unsigned char e_ident[elfcpp::EI_NIDENT];
393 memset(e_ident, 0, elfcpp::EI_NIDENT);
394 e_ident[elfcpp::EI_MAG0] = elfcpp::ELFMAG0;
395 e_ident[elfcpp::EI_MAG1] = elfcpp::ELFMAG1;
396 e_ident[elfcpp::EI_MAG2] = elfcpp::ELFMAG2;
397 e_ident[elfcpp::EI_MAG3] = elfcpp::ELFMAG3;
398 if (size == 32)
399 e_ident[elfcpp::EI_CLASS] = elfcpp::ELFCLASS32;
400 else if (size == 64)
401 e_ident[elfcpp::EI_CLASS] = elfcpp::ELFCLASS64;
402 else
a3ad94ed 403 gold_unreachable();
61ba1cf9
ILT
404 e_ident[elfcpp::EI_DATA] = (big_endian
405 ? elfcpp::ELFDATA2MSB
406 : elfcpp::ELFDATA2LSB);
407 e_ident[elfcpp::EI_VERSION] = elfcpp::EV_CURRENT;
408 // FIXME: Some targets may need to set EI_OSABI and EI_ABIVERSION.
409 oehdr.put_e_ident(e_ident);
410
411 elfcpp::ET e_type;
7e1edb90 412 if (parameters->output_is_object())
61ba1cf9 413 e_type = elfcpp::ET_REL;
436ca963
ILT
414 else if (parameters->output_is_shared())
415 e_type = elfcpp::ET_DYN;
61ba1cf9
ILT
416 else
417 e_type = elfcpp::ET_EXEC;
418 oehdr.put_e_type(e_type);
419
420 oehdr.put_e_machine(this->target_->machine_code());
421 oehdr.put_e_version(elfcpp::EV_CURRENT);
422
ead1e424 423 // FIXME: Need to support -e, and target specific entry symbol.
61ba1cf9
ILT
424 Symbol* sym = this->symtab_->lookup("_start");
425 typename Sized_symbol<size>::Value_type v;
426 if (sym == NULL)
427 v = 0;
428 else
429 {
430 Sized_symbol<size>* ssym;
593f47df 431 ssym = this->symtab_->get_sized_symbol SELECT_SIZE_NAME(size) (
5482377d 432 sym SELECT_SIZE(size));
61ba1cf9
ILT
433 v = ssym->value();
434 }
435 oehdr.put_e_entry(v);
436
437 oehdr.put_e_phoff(this->segment_header_->offset());
438 oehdr.put_e_shoff(this->section_header_->offset());
439
440 // FIXME: The target needs to set the flags.
441 oehdr.put_e_flags(0);
442
443 oehdr.put_e_ehsize(elfcpp::Elf_sizes<size>::ehdr_size);
444 oehdr.put_e_phentsize(elfcpp::Elf_sizes<size>::phdr_size);
445 oehdr.put_e_phnum(this->segment_header_->data_size()
446 / elfcpp::Elf_sizes<size>::phdr_size);
447 oehdr.put_e_shentsize(elfcpp::Elf_sizes<size>::shdr_size);
448 oehdr.put_e_shnum(this->section_header_->data_size()
449 / elfcpp::Elf_sizes<size>::shdr_size);
ead1e424 450 oehdr.put_e_shstrndx(this->shstrtab_->out_shndx());
61ba1cf9
ILT
451
452 of->write_output_view(0, ehdr_size, view);
54dc6425
ILT
453}
454
dbe717ef
ILT
455// Output_data_const methods.
456
457void
a3ad94ed 458Output_data_const::do_write(Output_file* of)
dbe717ef 459{
a3ad94ed
ILT
460 of->write(this->offset(), this->data_.data(), this->data_.size());
461}
462
463// Output_data_const_buffer methods.
464
465void
466Output_data_const_buffer::do_write(Output_file* of)
467{
468 of->write(this->offset(), this->p_, this->data_size());
dbe717ef
ILT
469}
470
471// Output_section_data methods.
472
16649710
ILT
473// Record the output section, and set the entry size and such.
474
475void
476Output_section_data::set_output_section(Output_section* os)
477{
478 gold_assert(this->output_section_ == NULL);
479 this->output_section_ = os;
480 this->do_adjust_output_section(os);
481}
482
483// Return the section index of the output section.
484
dbe717ef
ILT
485unsigned int
486Output_section_data::do_out_shndx() const
487{
a3ad94ed 488 gold_assert(this->output_section_ != NULL);
dbe717ef
ILT
489 return this->output_section_->out_shndx();
490}
491
a3ad94ed
ILT
492// Output_data_strtab methods.
493
494// Set the address. We don't actually care about the address, but we
495// do set our final size.
496
497void
498Output_data_strtab::do_set_address(uint64_t, off_t)
499{
500 this->strtab_->set_string_offsets();
501 this->set_data_size(this->strtab_->get_strtab_size());
502}
503
504// Write out a string table.
505
506void
507Output_data_strtab::do_write(Output_file* of)
508{
509 this->strtab_->write(of, this->offset());
510}
511
c06b7b0b
ILT
512// Output_reloc methods.
513
514// Get the symbol index of a relocation.
515
516template<bool dynamic, int size, bool big_endian>
517unsigned int
518Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_symbol_index()
519 const
520{
521 unsigned int index;
522 switch (this->local_sym_index_)
523 {
524 case INVALID_CODE:
a3ad94ed 525 gold_unreachable();
c06b7b0b
ILT
526
527 case GSYM_CODE:
5a6f7e2d 528 if (this->u1_.gsym == NULL)
c06b7b0b
ILT
529 index = 0;
530 else if (dynamic)
5a6f7e2d 531 index = this->u1_.gsym->dynsym_index();
c06b7b0b 532 else
5a6f7e2d 533 index = this->u1_.gsym->symtab_index();
c06b7b0b
ILT
534 break;
535
536 case SECTION_CODE:
537 if (dynamic)
5a6f7e2d 538 index = this->u1_.os->dynsym_index();
c06b7b0b 539 else
5a6f7e2d 540 index = this->u1_.os->symtab_index();
c06b7b0b
ILT
541 break;
542
436ca963
ILT
543 case 0:
544 // Relocations without symbols use a symbol index of 0.
545 index = 0;
546 break;
547
c06b7b0b
ILT
548 default:
549 if (dynamic)
550 {
551 // FIXME: It seems that some targets may need to generate
552 // dynamic relocations against local symbols for some
553 // reasons. This will have to be addressed at some point.
a3ad94ed 554 gold_unreachable();
c06b7b0b
ILT
555 }
556 else
5a6f7e2d 557 index = this->u1_.relobj->symtab_index(this->local_sym_index_);
c06b7b0b
ILT
558 break;
559 }
a3ad94ed 560 gold_assert(index != -1U);
c06b7b0b
ILT
561 return index;
562}
563
564// Write out the offset and info fields of a Rel or Rela relocation
565// entry.
566
567template<bool dynamic, int size, bool big_endian>
568template<typename Write_rel>
569void
570Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::write_rel(
571 Write_rel* wr) const
572{
a3ad94ed 573 Address address = this->address_;
5a6f7e2d
ILT
574 if (this->shndx_ != INVALID_CODE)
575 {
576 off_t off;
577 Output_section* os = this->u2_.relobj->output_section(this->shndx_,
578 &off);
579 gold_assert(os != NULL);
730cdc88
ILT
580 if (off != -1)
581 address += os->address() + off;
582 else
583 {
584 address = os->output_address(this->u2_.relobj, this->shndx_,
585 address);
586 gold_assert(address != -1U);
587 }
5a6f7e2d
ILT
588 }
589 else if (this->u2_.od != NULL)
590 address += this->u2_.od->address();
a3ad94ed 591 wr->put_r_offset(address);
c06b7b0b
ILT
592 wr->put_r_info(elfcpp::elf_r_info<size>(this->get_symbol_index(),
593 this->type_));
594}
595
596// Write out a Rel relocation.
597
598template<bool dynamic, int size, bool big_endian>
599void
600Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::write(
601 unsigned char* pov) const
602{
603 elfcpp::Rel_write<size, big_endian> orel(pov);
604 this->write_rel(&orel);
605}
606
607// Write out a Rela relocation.
608
609template<bool dynamic, int size, bool big_endian>
610void
611Output_reloc<elfcpp::SHT_RELA, dynamic, size, big_endian>::write(
612 unsigned char* pov) const
613{
614 elfcpp::Rela_write<size, big_endian> orel(pov);
615 this->rel_.write_rel(&orel);
616 orel.put_r_addend(this->addend_);
617}
618
619// Output_data_reloc_base methods.
620
16649710
ILT
621// Adjust the output section.
622
623template<int sh_type, bool dynamic, int size, bool big_endian>
624void
625Output_data_reloc_base<sh_type, dynamic, size, big_endian>
626 ::do_adjust_output_section(Output_section* os)
627{
628 if (sh_type == elfcpp::SHT_REL)
629 os->set_entsize(elfcpp::Elf_sizes<size>::rel_size);
630 else if (sh_type == elfcpp::SHT_RELA)
631 os->set_entsize(elfcpp::Elf_sizes<size>::rela_size);
632 else
633 gold_unreachable();
634 if (dynamic)
635 os->set_should_link_to_dynsym();
636 else
637 os->set_should_link_to_symtab();
638}
639
c06b7b0b
ILT
640// Write out relocation data.
641
642template<int sh_type, bool dynamic, int size, bool big_endian>
643void
644Output_data_reloc_base<sh_type, dynamic, size, big_endian>::do_write(
645 Output_file* of)
646{
647 const off_t off = this->offset();
648 const off_t oview_size = this->data_size();
649 unsigned char* const oview = of->get_output_view(off, oview_size);
650
651 unsigned char* pov = oview;
652 for (typename Relocs::const_iterator p = this->relocs_.begin();
653 p != this->relocs_.end();
654 ++p)
655 {
656 p->write(pov);
657 pov += reloc_size;
658 }
659
a3ad94ed 660 gold_assert(pov - oview == oview_size);
c06b7b0b
ILT
661
662 of->write_output_view(off, oview_size, oview);
663
664 // We no longer need the relocation entries.
665 this->relocs_.clear();
666}
667
dbe717ef 668// Output_data_got::Got_entry methods.
ead1e424
ILT
669
670// Write out the entry.
671
672template<int size, bool big_endian>
673void
7e1edb90 674Output_data_got<size, big_endian>::Got_entry::write(unsigned char* pov) const
ead1e424
ILT
675{
676 Valtype val = 0;
677
678 switch (this->local_sym_index_)
679 {
680 case GSYM_CODE:
681 {
682 Symbol* gsym = this->u_.gsym;
683
684 // If the symbol is resolved locally, we need to write out its
685 // value. Otherwise we just write zero. The target code is
686 // responsible for creating a relocation entry to fill in the
d61c6bd4
ILT
687 // value at runtime. For non-preemptible symbols in a shared
688 // library, the target will need to record whether or not the
689 // value should be written (e.g., it may use a RELATIVE
690 // relocation type).
691 if (gsym->final_value_is_known() || gsym->needs_value_in_got())
ead1e424
ILT
692 {
693 Sized_symbol<size>* sgsym;
694 // This cast is a bit ugly. We don't want to put a
695 // virtual method in Symbol, because we want Symbol to be
696 // as small as possible.
697 sgsym = static_cast<Sized_symbol<size>*>(gsym);
698 val = sgsym->value();
699 }
700 }
701 break;
702
703 case CONSTANT_CODE:
704 val = this->u_.constant;
705 break;
706
707 default:
e727fa71
ILT
708 val = this->u_.object->local_symbol_value(this->local_sym_index_);
709 break;
ead1e424
ILT
710 }
711
a3ad94ed 712 elfcpp::Swap<size, big_endian>::writeval(pov, val);
ead1e424
ILT
713}
714
dbe717ef 715// Output_data_got methods.
ead1e424 716
dbe717ef
ILT
717// Add an entry for a global symbol to the GOT. This returns true if
718// this is a new GOT entry, false if the symbol already had a GOT
719// entry.
720
721template<int size, bool big_endian>
722bool
723Output_data_got<size, big_endian>::add_global(Symbol* gsym)
ead1e424 724{
dbe717ef
ILT
725 if (gsym->has_got_offset())
726 return false;
ead1e424 727
dbe717ef
ILT
728 this->entries_.push_back(Got_entry(gsym));
729 this->set_got_size();
730 gsym->set_got_offset(this->last_got_offset());
731 return true;
732}
ead1e424 733
e727fa71
ILT
734// Add an entry for a local symbol to the GOT. This returns true if
735// this is a new GOT entry, false if the symbol already has a GOT
736// entry.
737
738template<int size, bool big_endian>
739bool
740Output_data_got<size, big_endian>::add_local(
741 Sized_relobj<size, big_endian>* object,
742 unsigned int symndx)
743{
744 if (object->local_has_got_offset(symndx))
745 return false;
746 this->entries_.push_back(Got_entry(object, symndx));
747 this->set_got_size();
748 object->set_local_got_offset(symndx, this->last_got_offset());
749 return true;
750}
751
ead1e424
ILT
752// Write out the GOT.
753
754template<int size, bool big_endian>
755void
dbe717ef 756Output_data_got<size, big_endian>::do_write(Output_file* of)
ead1e424
ILT
757{
758 const int add = size / 8;
759
760 const off_t off = this->offset();
c06b7b0b 761 const off_t oview_size = this->data_size();
ead1e424
ILT
762 unsigned char* const oview = of->get_output_view(off, oview_size);
763
764 unsigned char* pov = oview;
765 for (typename Got_entries::const_iterator p = this->entries_.begin();
766 p != this->entries_.end();
767 ++p)
768 {
7e1edb90 769 p->write(pov);
ead1e424
ILT
770 pov += add;
771 }
772
a3ad94ed 773 gold_assert(pov - oview == oview_size);
c06b7b0b 774
ead1e424
ILT
775 of->write_output_view(off, oview_size, oview);
776
777 // We no longer need the GOT entries.
778 this->entries_.clear();
779}
780
a3ad94ed
ILT
781// Output_data_dynamic::Dynamic_entry methods.
782
783// Write out the entry.
784
785template<int size, bool big_endian>
786void
787Output_data_dynamic::Dynamic_entry::write(
788 unsigned char* pov,
1ddbd1e6
ILT
789 const Stringpool* pool
790 ACCEPT_SIZE_ENDIAN) const
a3ad94ed
ILT
791{
792 typename elfcpp::Elf_types<size>::Elf_WXword val;
793 switch (this->classification_)
794 {
795 case DYNAMIC_NUMBER:
796 val = this->u_.val;
797 break;
798
799 case DYNAMIC_SECTION_ADDRESS:
16649710 800 val = this->u_.od->address();
a3ad94ed
ILT
801 break;
802
803 case DYNAMIC_SECTION_SIZE:
16649710 804 val = this->u_.od->data_size();
a3ad94ed
ILT
805 break;
806
807 case DYNAMIC_SYMBOL:
808 {
16649710
ILT
809 const Sized_symbol<size>* s =
810 static_cast<const Sized_symbol<size>*>(this->u_.sym);
a3ad94ed
ILT
811 val = s->value();
812 }
813 break;
814
815 case DYNAMIC_STRING:
816 val = pool->get_offset(this->u_.str);
817 break;
818
819 default:
820 gold_unreachable();
821 }
822
823 elfcpp::Dyn_write<size, big_endian> dw(pov);
824 dw.put_d_tag(this->tag_);
825 dw.put_d_val(val);
826}
827
828// Output_data_dynamic methods.
829
16649710
ILT
830// Adjust the output section to set the entry size.
831
832void
833Output_data_dynamic::do_adjust_output_section(Output_section* os)
834{
9025d29d 835 if (parameters->get_size() == 32)
16649710 836 os->set_entsize(elfcpp::Elf_sizes<32>::dyn_size);
9025d29d 837 else if (parameters->get_size() == 64)
16649710
ILT
838 os->set_entsize(elfcpp::Elf_sizes<64>::dyn_size);
839 else
840 gold_unreachable();
841}
842
a3ad94ed
ILT
843// Set the final data size.
844
845void
846Output_data_dynamic::do_set_address(uint64_t, off_t)
847{
848 // Add the terminating entry.
849 this->add_constant(elfcpp::DT_NULL, 0);
850
851 int dyn_size;
9025d29d 852 if (parameters->get_size() == 32)
a3ad94ed 853 dyn_size = elfcpp::Elf_sizes<32>::dyn_size;
9025d29d 854 else if (parameters->get_size() == 64)
a3ad94ed
ILT
855 dyn_size = elfcpp::Elf_sizes<64>::dyn_size;
856 else
857 gold_unreachable();
858 this->set_data_size(this->entries_.size() * dyn_size);
859}
860
861// Write out the dynamic entries.
862
863void
864Output_data_dynamic::do_write(Output_file* of)
865{
9025d29d 866 if (parameters->get_size() == 32)
a3ad94ed 867 {
9025d29d
ILT
868 if (parameters->is_big_endian())
869 {
870#ifdef HAVE_TARGET_32_BIG
871 this->sized_write<32, true>(of);
872#else
873 gold_unreachable();
874#endif
875 }
a3ad94ed 876 else
9025d29d
ILT
877 {
878#ifdef HAVE_TARGET_32_LITTLE
879 this->sized_write<32, false>(of);
880#else
881 gold_unreachable();
882#endif
883 }
a3ad94ed 884 }
9025d29d 885 else if (parameters->get_size() == 64)
a3ad94ed 886 {
9025d29d
ILT
887 if (parameters->is_big_endian())
888 {
889#ifdef HAVE_TARGET_64_BIG
890 this->sized_write<64, true>(of);
891#else
892 gold_unreachable();
893#endif
894 }
a3ad94ed 895 else
9025d29d
ILT
896 {
897#ifdef HAVE_TARGET_64_LITTLE
898 this->sized_write<64, false>(of);
899#else
900 gold_unreachable();
901#endif
902 }
a3ad94ed
ILT
903 }
904 else
905 gold_unreachable();
906}
907
908template<int size, bool big_endian>
909void
910Output_data_dynamic::sized_write(Output_file* of)
911{
912 const int dyn_size = elfcpp::Elf_sizes<size>::dyn_size;
913
914 const off_t offset = this->offset();
915 const off_t oview_size = this->data_size();
916 unsigned char* const oview = of->get_output_view(offset, oview_size);
917
918 unsigned char* pov = oview;
919 for (typename Dynamic_entries::const_iterator p = this->entries_.begin();
920 p != this->entries_.end();
921 ++p)
922 {
1ddbd1e6
ILT
923 p->write SELECT_SIZE_ENDIAN_NAME(size, big_endian)(
924 pov, this->pool_ SELECT_SIZE_ENDIAN(size, big_endian));
a3ad94ed
ILT
925 pov += dyn_size;
926 }
927
928 gold_assert(pov - oview == oview_size);
929
930 of->write_output_view(offset, oview_size, oview);
931
932 // We no longer need the dynamic entries.
933 this->entries_.clear();
934}
935
ead1e424
ILT
936// Output_section::Input_section methods.
937
938// Return the data size. For an input section we store the size here.
939// For an Output_section_data, we have to ask it for the size.
940
941off_t
942Output_section::Input_section::data_size() const
943{
944 if (this->is_input_section())
b8e6aad9 945 return this->u1_.data_size;
ead1e424 946 else
b8e6aad9 947 return this->u2_.posd->data_size();
ead1e424
ILT
948}
949
950// Set the address and file offset.
951
952void
953Output_section::Input_section::set_address(uint64_t addr, off_t off,
954 off_t secoff)
955{
956 if (this->is_input_section())
b8e6aad9 957 this->u2_.object->set_section_offset(this->shndx_, off - secoff);
ead1e424 958 else
b8e6aad9
ILT
959 this->u2_.posd->set_address(addr, off);
960}
961
730cdc88 962// Try to turn an input offset into an output offset.
b8e6aad9
ILT
963
964bool
730cdc88
ILT
965Output_section::Input_section::output_offset(const Relobj* object,
966 unsigned int shndx,
967 off_t offset,
968 off_t *poutput) const
b8e6aad9
ILT
969{
970 if (!this->is_input_section())
730cdc88 971 return this->u2_.posd->output_offset(object, shndx, offset, poutput);
b8e6aad9
ILT
972 else
973 {
730cdc88 974 if (this->shndx_ != shndx || this->u2_.object != object)
b8e6aad9
ILT
975 return false;
976 off_t output_offset;
977 Output_section* os = object->output_section(shndx, &output_offset);
978 gold_assert(os != NULL);
730cdc88
ILT
979 gold_assert(output_offset != -1);
980 *poutput = output_offset + offset;
b8e6aad9
ILT
981 return true;
982 }
ead1e424
ILT
983}
984
985// Write out the data. We don't have to do anything for an input
986// section--they are handled via Object::relocate--but this is where
987// we write out the data for an Output_section_data.
988
989void
990Output_section::Input_section::write(Output_file* of)
991{
992 if (!this->is_input_section())
b8e6aad9 993 this->u2_.posd->write(of);
ead1e424
ILT
994}
995
a2fb1b05
ILT
996// Output_section methods.
997
998// Construct an Output_section. NAME will point into a Stringpool.
999
1000Output_section::Output_section(const char* name, elfcpp::Elf_Word type,
b8e6aad9 1001 elfcpp::Elf_Xword flags)
a2fb1b05 1002 : name_(name),
a2fb1b05
ILT
1003 addralign_(0),
1004 entsize_(0),
16649710 1005 link_section_(NULL),
a2fb1b05 1006 link_(0),
16649710 1007 info_section_(NULL),
a2fb1b05
ILT
1008 info_(0),
1009 type_(type),
61ba1cf9 1010 flags_(flags),
91ea499d 1011 out_shndx_(-1U),
c06b7b0b
ILT
1012 symtab_index_(0),
1013 dynsym_index_(0),
ead1e424
ILT
1014 input_sections_(),
1015 first_input_offset_(0),
c51e6221 1016 fills_(),
a3ad94ed 1017 needs_symtab_index_(false),
16649710
ILT
1018 needs_dynsym_index_(false),
1019 should_link_to_symtab_(false),
730cdc88
ILT
1020 should_link_to_dynsym_(false),
1021 after_input_sections_(false)
a2fb1b05
ILT
1022{
1023}
1024
54dc6425
ILT
1025Output_section::~Output_section()
1026{
1027}
1028
16649710
ILT
1029// Set the entry size.
1030
1031void
1032Output_section::set_entsize(uint64_t v)
1033{
1034 if (this->entsize_ == 0)
1035 this->entsize_ = v;
1036 else
1037 gold_assert(this->entsize_ == v);
1038}
1039
ead1e424 1040// Add the input section SHNDX, with header SHDR, named SECNAME, in
730cdc88
ILT
1041// OBJECT, to the Output_section. RELOC_SHNDX is the index of a
1042// relocation section which applies to this section, or 0 if none, or
1043// -1U if more than one. Return the offset of the input section
1044// within the output section. Return -1 if the input section will
1045// receive special handling. In the normal case we don't always keep
1046// track of input sections for an Output_section. Instead, each
1047// Object keeps track of the Output_section for each of its input
1048// sections.
a2fb1b05
ILT
1049
1050template<int size, bool big_endian>
1051off_t
730cdc88
ILT
1052Output_section::add_input_section(Sized_relobj<size, big_endian>* object,
1053 unsigned int shndx,
ead1e424 1054 const char* secname,
730cdc88
ILT
1055 const elfcpp::Shdr<size, big_endian>& shdr,
1056 unsigned int reloc_shndx)
a2fb1b05
ILT
1057{
1058 elfcpp::Elf_Xword addralign = shdr.get_sh_addralign();
1059 if ((addralign & (addralign - 1)) != 0)
1060 {
75f2446e
ILT
1061 object->error(_("invalid alignment %lu for section \"%s\""),
1062 static_cast<unsigned long>(addralign), secname);
1063 addralign = 1;
a2fb1b05 1064 }
a2fb1b05
ILT
1065
1066 if (addralign > this->addralign_)
1067 this->addralign_ = addralign;
1068
b8e6aad9 1069 // If this is a SHF_MERGE section, we pass all the input sections to
730cdc88
ILT
1070 // a Output_data_merge. We don't try to handle relocations for such
1071 // a section.
1072 if ((shdr.get_sh_flags() & elfcpp::SHF_MERGE) != 0
1073 && reloc_shndx == 0)
b8e6aad9
ILT
1074 {
1075 if (this->add_merge_input_section(object, shndx, shdr.get_sh_flags(),
1076 shdr.get_sh_entsize(),
1077 addralign))
1078 {
1079 // Tell the relocation routines that they need to call the
730cdc88 1080 // output_offset method to determine the final address.
b8e6aad9
ILT
1081 return -1;
1082 }
1083 }
1084
c51e6221
ILT
1085 off_t offset_in_section = this->data_size();
1086 off_t aligned_offset_in_section = align_address(offset_in_section,
1087 addralign);
1088
1089 if (aligned_offset_in_section > offset_in_section
1090 && (shdr.get_sh_flags() & elfcpp::SHF_EXECINSTR) != 0
1091 && object->target()->has_code_fill())
1092 {
1093 // We need to add some fill data. Using fill_list_ when
1094 // possible is an optimization, since we will often have fill
1095 // sections without input sections.
1096 off_t fill_len = aligned_offset_in_section - offset_in_section;
1097 if (this->input_sections_.empty())
1098 this->fills_.push_back(Fill(offset_in_section, fill_len));
1099 else
1100 {
1101 // FIXME: When relaxing, the size needs to adjust to
1102 // maintain a constant alignment.
1103 std::string fill_data(object->target()->code_fill(fill_len));
1104 Output_data_const* odc = new Output_data_const(fill_data, 1);
1105 this->input_sections_.push_back(Input_section(odc));
1106 }
1107 }
1108
1109 this->set_data_size(aligned_offset_in_section + shdr.get_sh_size());
a2fb1b05 1110
ead1e424
ILT
1111 // We need to keep track of this section if we are already keeping
1112 // track of sections, or if we are relaxing. FIXME: Add test for
1113 // relaxing.
c51e6221 1114 if (!this->input_sections_.empty())
ead1e424
ILT
1115 this->input_sections_.push_back(Input_section(object, shndx,
1116 shdr.get_sh_size(),
1117 addralign));
54dc6425 1118
c51e6221 1119 return aligned_offset_in_section;
61ba1cf9
ILT
1120}
1121
ead1e424
ILT
1122// Add arbitrary data to an output section.
1123
1124void
1125Output_section::add_output_section_data(Output_section_data* posd)
1126{
b8e6aad9
ILT
1127 Input_section inp(posd);
1128 this->add_output_section_data(&inp);
1129}
1130
1131// Add arbitrary data to an output section by Input_section.
c06b7b0b 1132
b8e6aad9
ILT
1133void
1134Output_section::add_output_section_data(Input_section* inp)
1135{
ead1e424
ILT
1136 if (this->input_sections_.empty())
1137 this->first_input_offset_ = this->data_size();
c06b7b0b 1138
b8e6aad9 1139 this->input_sections_.push_back(*inp);
c06b7b0b 1140
b8e6aad9 1141 uint64_t addralign = inp->addralign();
ead1e424
ILT
1142 if (addralign > this->addralign_)
1143 this->addralign_ = addralign;
c06b7b0b 1144
b8e6aad9
ILT
1145 inp->set_output_section(this);
1146}
1147
1148// Add a merge section to an output section.
1149
1150void
1151Output_section::add_output_merge_section(Output_section_data* posd,
1152 bool is_string, uint64_t entsize)
1153{
1154 Input_section inp(posd, is_string, entsize);
1155 this->add_output_section_data(&inp);
1156}
1157
1158// Add an input section to a SHF_MERGE section.
1159
1160bool
1161Output_section::add_merge_input_section(Relobj* object, unsigned int shndx,
1162 uint64_t flags, uint64_t entsize,
1163 uint64_t addralign)
1164{
87f95776
ILT
1165 bool is_string = (flags & elfcpp::SHF_STRINGS) != 0;
1166
1167 // We only merge strings if the alignment is not more than the
1168 // character size. This could be handled, but it's unusual.
1169 if (is_string && addralign > entsize)
b8e6aad9
ILT
1170 return false;
1171
b8e6aad9
ILT
1172 Input_section_list::iterator p;
1173 for (p = this->input_sections_.begin();
1174 p != this->input_sections_.end();
1175 ++p)
87f95776 1176 if (p->is_merge_section(is_string, entsize, addralign))
b8e6aad9
ILT
1177 break;
1178
1179 // We handle the actual constant merging in Output_merge_data or
1180 // Output_merge_string_data.
1181 if (p != this->input_sections_.end())
1182 p->add_input_section(object, shndx);
1183 else
1184 {
1185 Output_section_data* posd;
1186 if (!is_string)
87f95776 1187 posd = new Output_merge_data(entsize, addralign);
b8e6aad9 1188 else if (entsize == 1)
87f95776 1189 posd = new Output_merge_string<char>(addralign);
b8e6aad9 1190 else if (entsize == 2)
87f95776 1191 posd = new Output_merge_string<uint16_t>(addralign);
b8e6aad9 1192 else if (entsize == 4)
87f95776 1193 posd = new Output_merge_string<uint32_t>(addralign);
b8e6aad9
ILT
1194 else
1195 return false;
1196
1197 this->add_output_merge_section(posd, is_string, entsize);
1198 posd->add_input_section(object, shndx);
1199 }
1200
1201 return true;
1202}
1203
730cdc88
ILT
1204// Given an address OFFSET relative to the start of input section
1205// SHNDX in OBJECT, return whether this address is being included in
1206// the final link. This should only be called if SHNDX in OBJECT has
1207// a special mapping.
1208
1209bool
1210Output_section::is_input_address_mapped(const Relobj* object,
1211 unsigned int shndx,
1212 off_t offset) const
1213{
1214 gold_assert(object->is_section_specially_mapped(shndx));
1215
1216 for (Input_section_list::const_iterator p = this->input_sections_.begin();
1217 p != this->input_sections_.end();
1218 ++p)
1219 {
1220 off_t output_offset;
1221 if (p->output_offset(object, shndx, offset, &output_offset))
1222 return output_offset != -1;
1223 }
1224
1225 // By default we assume that the address is mapped. This should
1226 // only be called after we have passed all sections to Layout. At
1227 // that point we should know what we are discarding.
1228 return true;
1229}
1230
1231// Given an address OFFSET relative to the start of input section
1232// SHNDX in object OBJECT, return the output offset relative to the
1233// start of the section. This should only be called if SHNDX in
1234// OBJECT has a special mapping.
1235
1236off_t
1237Output_section::output_offset(const Relobj* object, unsigned int shndx,
1238 off_t offset) const
1239{
1240 gold_assert(object->is_section_specially_mapped(shndx));
1241 // This can only be called meaningfully when layout is complete.
1242 gold_assert(Output_data::is_layout_complete());
1243
1244 for (Input_section_list::const_iterator p = this->input_sections_.begin();
1245 p != this->input_sections_.end();
1246 ++p)
1247 {
1248 off_t output_offset;
1249 if (p->output_offset(object, shndx, offset, &output_offset))
1250 return output_offset;
1251 }
1252 gold_unreachable();
1253}
1254
b8e6aad9
ILT
1255// Return the output virtual address of OFFSET relative to the start
1256// of input section SHNDX in object OBJECT.
1257
1258uint64_t
1259Output_section::output_address(const Relobj* object, unsigned int shndx,
1260 off_t offset) const
1261{
730cdc88
ILT
1262 gold_assert(object->is_section_specially_mapped(shndx));
1263 // This can only be called meaningfully when layout is complete.
1264 gold_assert(Output_data::is_layout_complete());
1265
b8e6aad9
ILT
1266 uint64_t addr = this->address() + this->first_input_offset_;
1267 for (Input_section_list::const_iterator p = this->input_sections_.begin();
1268 p != this->input_sections_.end();
1269 ++p)
1270 {
1271 addr = align_address(addr, p->addralign());
730cdc88
ILT
1272 off_t output_offset;
1273 if (p->output_offset(object, shndx, offset, &output_offset))
1274 {
1275 if (output_offset == -1)
1276 return -1U;
1277 return addr + output_offset;
1278 }
b8e6aad9
ILT
1279 addr += p->data_size();
1280 }
1281
1282 // If we get here, it means that we don't know the mapping for this
1283 // input section. This might happen in principle if
1284 // add_input_section were called before add_output_section_data.
1285 // But it should never actually happen.
1286
1287 gold_unreachable();
ead1e424
ILT
1288}
1289
1290// Set the address of an Output_section. This is where we handle
1291// setting the addresses of any Output_section_data objects.
1292
1293void
1294Output_section::do_set_address(uint64_t address, off_t startoff)
1295{
1296 if (this->input_sections_.empty())
1297 return;
1298
1299 off_t off = startoff + this->first_input_offset_;
1300 for (Input_section_list::iterator p = this->input_sections_.begin();
1301 p != this->input_sections_.end();
1302 ++p)
1303 {
1304 off = align_address(off, p->addralign());
1305 p->set_address(address + (off - startoff), off, startoff);
1306 off += p->data_size();
1307 }
1308
1309 this->set_data_size(off - startoff);
1310}
1311
61ba1cf9
ILT
1312// Write the section header to *OSHDR.
1313
1314template<int size, bool big_endian>
1315void
16649710
ILT
1316Output_section::write_header(const Layout* layout,
1317 const Stringpool* secnamepool,
61ba1cf9
ILT
1318 elfcpp::Shdr_write<size, big_endian>* oshdr) const
1319{
1320 oshdr->put_sh_name(secnamepool->get_offset(this->name_));
1321 oshdr->put_sh_type(this->type_);
1322 oshdr->put_sh_flags(this->flags_);
1323 oshdr->put_sh_addr(this->address());
1324 oshdr->put_sh_offset(this->offset());
1325 oshdr->put_sh_size(this->data_size());
16649710
ILT
1326 if (this->link_section_ != NULL)
1327 oshdr->put_sh_link(this->link_section_->out_shndx());
1328 else if (this->should_link_to_symtab_)
1329 oshdr->put_sh_link(layout->symtab_section()->out_shndx());
1330 else if (this->should_link_to_dynsym_)
1331 oshdr->put_sh_link(layout->dynsym_section()->out_shndx());
1332 else
1333 oshdr->put_sh_link(this->link_);
1334 if (this->info_section_ != NULL)
1335 oshdr->put_sh_info(this->info_section_->out_shndx());
1336 else
1337 oshdr->put_sh_info(this->info_);
61ba1cf9
ILT
1338 oshdr->put_sh_addralign(this->addralign_);
1339 oshdr->put_sh_entsize(this->entsize_);
a2fb1b05
ILT
1340}
1341
ead1e424
ILT
1342// Write out the data. For input sections the data is written out by
1343// Object::relocate, but we have to handle Output_section_data objects
1344// here.
1345
1346void
1347Output_section::do_write(Output_file* of)
1348{
c51e6221
ILT
1349 off_t output_section_file_offset = this->offset();
1350 for (Fill_list::iterator p = this->fills_.begin();
1351 p != this->fills_.end();
1352 ++p)
1353 {
1354 std::string fill_data(of->target()->code_fill(p->length()));
1355 of->write(output_section_file_offset + p->section_offset(),
1356 fill_data.data(), fill_data.size());
1357 }
1358
ead1e424
ILT
1359 for (Input_section_list::iterator p = this->input_sections_.begin();
1360 p != this->input_sections_.end();
1361 ++p)
1362 p->write(of);
1363}
1364
a2fb1b05
ILT
1365// Output segment methods.
1366
1367Output_segment::Output_segment(elfcpp::Elf_Word type, elfcpp::Elf_Word flags)
54dc6425 1368 : output_data_(),
75f65a3e 1369 output_bss_(),
a2fb1b05
ILT
1370 vaddr_(0),
1371 paddr_(0),
1372 memsz_(0),
1373 align_(0),
1374 offset_(0),
1375 filesz_(0),
1376 type_(type),
ead1e424
ILT
1377 flags_(flags),
1378 is_align_known_(false)
a2fb1b05
ILT
1379{
1380}
1381
1382// Add an Output_section to an Output_segment.
1383
1384void
75f65a3e 1385Output_segment::add_output_section(Output_section* os,
dbe717ef
ILT
1386 elfcpp::Elf_Word seg_flags,
1387 bool front)
a2fb1b05 1388{
a3ad94ed
ILT
1389 gold_assert((os->flags() & elfcpp::SHF_ALLOC) != 0);
1390 gold_assert(!this->is_align_known_);
75f65a3e 1391
ead1e424 1392 // Update the segment flags.
75f65a3e 1393 this->flags_ |= seg_flags;
75f65a3e
ILT
1394
1395 Output_segment::Output_data_list* pdl;
1396 if (os->type() == elfcpp::SHT_NOBITS)
1397 pdl = &this->output_bss_;
1398 else
1399 pdl = &this->output_data_;
54dc6425 1400
a2fb1b05
ILT
1401 // So that PT_NOTE segments will work correctly, we need to ensure
1402 // that all SHT_NOTE sections are adjacent. This will normally
1403 // happen automatically, because all the SHT_NOTE input sections
1404 // will wind up in the same output section. However, it is possible
1405 // for multiple SHT_NOTE input sections to have different section
1406 // flags, and thus be in different output sections, but for the
1407 // different section flags to map into the same segment flags and
1408 // thus the same output segment.
54dc6425
ILT
1409
1410 // Note that while there may be many input sections in an output
1411 // section, there are normally only a few output sections in an
1412 // output segment. This loop is expected to be fast.
1413
61ba1cf9 1414 if (os->type() == elfcpp::SHT_NOTE && !pdl->empty())
a2fb1b05 1415 {
a3ad94ed 1416 Output_segment::Output_data_list::iterator p = pdl->end();
75f65a3e 1417 do
54dc6425 1418 {
75f65a3e 1419 --p;
54dc6425
ILT
1420 if ((*p)->is_section_type(elfcpp::SHT_NOTE))
1421 {
dbe717ef 1422 // We don't worry about the FRONT parameter.
54dc6425 1423 ++p;
75f65a3e 1424 pdl->insert(p, os);
54dc6425
ILT
1425 return;
1426 }
1427 }
75f65a3e 1428 while (p != pdl->begin());
54dc6425
ILT
1429 }
1430
1431 // Similarly, so that PT_TLS segments will work, we need to group
75f65a3e
ILT
1432 // SHF_TLS sections. An SHF_TLS/SHT_NOBITS section is a special
1433 // case: we group the SHF_TLS/SHT_NOBITS sections right after the
1434 // SHF_TLS/SHT_PROGBITS sections. This lets us set up PT_TLS
1435 // correctly.
61ba1cf9 1436 if ((os->flags() & elfcpp::SHF_TLS) != 0 && !this->output_data_.empty())
54dc6425 1437 {
75f65a3e
ILT
1438 pdl = &this->output_data_;
1439 bool nobits = os->type() == elfcpp::SHT_NOBITS;
ead1e424 1440 bool sawtls = false;
a3ad94ed 1441 Output_segment::Output_data_list::iterator p = pdl->end();
75f65a3e 1442 do
a2fb1b05 1443 {
75f65a3e 1444 --p;
ead1e424
ILT
1445 bool insert;
1446 if ((*p)->is_section_flag_set(elfcpp::SHF_TLS))
1447 {
1448 sawtls = true;
1449 // Put a NOBITS section after the first TLS section.
1450 // But a PROGBITS section after the first TLS/PROGBITS
1451 // section.
1452 insert = nobits || !(*p)->is_section_type(elfcpp::SHT_NOBITS);
1453 }
1454 else
1455 {
1456 // If we've gone past the TLS sections, but we've seen a
1457 // TLS section, then we need to insert this section now.
1458 insert = sawtls;
1459 }
1460
1461 if (insert)
a2fb1b05 1462 {
dbe717ef 1463 // We don't worry about the FRONT parameter.
a2fb1b05 1464 ++p;
75f65a3e 1465 pdl->insert(p, os);
a2fb1b05
ILT
1466 return;
1467 }
1468 }
75f65a3e 1469 while (p != pdl->begin());
ead1e424 1470
dbe717ef
ILT
1471 // There are no TLS sections yet; put this one at the requested
1472 // location in the section list.
a2fb1b05
ILT
1473 }
1474
dbe717ef
ILT
1475 if (front)
1476 pdl->push_front(os);
1477 else
1478 pdl->push_back(os);
75f65a3e
ILT
1479}
1480
1481// Add an Output_data (which is not an Output_section) to the start of
1482// a segment.
1483
1484void
1485Output_segment::add_initial_output_data(Output_data* od)
1486{
a3ad94ed 1487 gold_assert(!this->is_align_known_);
75f65a3e
ILT
1488 this->output_data_.push_front(od);
1489}
1490
1491// Return the maximum alignment of the Output_data in Output_segment.
ead1e424 1492// Once we compute this, we prohibit new sections from being added.
75f65a3e
ILT
1493
1494uint64_t
ead1e424 1495Output_segment::addralign()
75f65a3e 1496{
ead1e424
ILT
1497 if (!this->is_align_known_)
1498 {
1499 uint64_t addralign;
1500
1501 addralign = Output_segment::maximum_alignment(&this->output_data_);
1502 if (addralign > this->align_)
1503 this->align_ = addralign;
1504
1505 addralign = Output_segment::maximum_alignment(&this->output_bss_);
1506 if (addralign > this->align_)
1507 this->align_ = addralign;
1508
1509 this->is_align_known_ = true;
1510 }
1511
75f65a3e
ILT
1512 return this->align_;
1513}
1514
ead1e424
ILT
1515// Return the maximum alignment of a list of Output_data.
1516
1517uint64_t
1518Output_segment::maximum_alignment(const Output_data_list* pdl)
1519{
1520 uint64_t ret = 0;
1521 for (Output_data_list::const_iterator p = pdl->begin();
1522 p != pdl->end();
1523 ++p)
1524 {
1525 uint64_t addralign = (*p)->addralign();
1526 if (addralign > ret)
1527 ret = addralign;
1528 }
1529 return ret;
1530}
1531
75f65a3e 1532// Set the section addresses for an Output_segment. ADDR is the
ead1e424
ILT
1533// address and *POFF is the file offset. Set the section indexes
1534// starting with *PSHNDX. Return the address of the immediately
1535// following segment. Update *POFF and *PSHNDX.
75f65a3e
ILT
1536
1537uint64_t
ead1e424
ILT
1538Output_segment::set_section_addresses(uint64_t addr, off_t* poff,
1539 unsigned int* pshndx)
75f65a3e 1540{
a3ad94ed 1541 gold_assert(this->type_ == elfcpp::PT_LOAD);
75f65a3e
ILT
1542
1543 this->vaddr_ = addr;
1544 this->paddr_ = addr;
1545
1546 off_t orig_off = *poff;
1547 this->offset_ = orig_off;
1548
ead1e424
ILT
1549 *poff = align_address(*poff, this->addralign());
1550
1551 addr = this->set_section_list_addresses(&this->output_data_, addr, poff,
1552 pshndx);
75f65a3e
ILT
1553 this->filesz_ = *poff - orig_off;
1554
1555 off_t off = *poff;
1556
61ba1cf9 1557 uint64_t ret = this->set_section_list_addresses(&this->output_bss_, addr,
ead1e424 1558 poff, pshndx);
75f65a3e
ILT
1559 this->memsz_ = *poff - orig_off;
1560
1561 // Ignore the file offset adjustments made by the BSS Output_data
1562 // objects.
1563 *poff = off;
61ba1cf9
ILT
1564
1565 return ret;
75f65a3e
ILT
1566}
1567
b8e6aad9
ILT
1568// Set the addresses and file offsets in a list of Output_data
1569// structures.
75f65a3e
ILT
1570
1571uint64_t
1572Output_segment::set_section_list_addresses(Output_data_list* pdl,
ead1e424
ILT
1573 uint64_t addr, off_t* poff,
1574 unsigned int* pshndx)
75f65a3e 1575{
ead1e424 1576 off_t startoff = *poff;
75f65a3e 1577
ead1e424 1578 off_t off = startoff;
75f65a3e
ILT
1579 for (Output_data_list::iterator p = pdl->begin();
1580 p != pdl->end();
1581 ++p)
1582 {
ead1e424
ILT
1583 off = align_address(off, (*p)->addralign());
1584 (*p)->set_address(addr + (off - startoff), off);
1585
1586 // Unless this is a PT_TLS segment, we want to ignore the size
1587 // of a SHF_TLS/SHT_NOBITS section. Such a section does not
1588 // affect the size of a PT_LOAD segment.
1589 if (this->type_ == elfcpp::PT_TLS
1590 || !(*p)->is_section_flag_set(elfcpp::SHF_TLS)
1591 || !(*p)->is_section_type(elfcpp::SHT_NOBITS))
1592 off += (*p)->data_size();
75f65a3e 1593
ead1e424
ILT
1594 if ((*p)->is_section())
1595 {
1596 (*p)->set_out_shndx(*pshndx);
1597 ++*pshndx;
1598 }
75f65a3e
ILT
1599 }
1600
1601 *poff = off;
ead1e424 1602 return addr + (off - startoff);
75f65a3e
ILT
1603}
1604
1605// For a non-PT_LOAD segment, set the offset from the sections, if
1606// any.
1607
1608void
1609Output_segment::set_offset()
1610{
a3ad94ed 1611 gold_assert(this->type_ != elfcpp::PT_LOAD);
75f65a3e
ILT
1612
1613 if (this->output_data_.empty() && this->output_bss_.empty())
1614 {
1615 this->vaddr_ = 0;
1616 this->paddr_ = 0;
1617 this->memsz_ = 0;
1618 this->align_ = 0;
1619 this->offset_ = 0;
1620 this->filesz_ = 0;
1621 return;
1622 }
1623
1624 const Output_data* first;
1625 if (this->output_data_.empty())
1626 first = this->output_bss_.front();
1627 else
1628 first = this->output_data_.front();
1629 this->vaddr_ = first->address();
1630 this->paddr_ = this->vaddr_;
1631 this->offset_ = first->offset();
1632
1633 if (this->output_data_.empty())
1634 this->filesz_ = 0;
1635 else
1636 {
1637 const Output_data* last_data = this->output_data_.back();
1638 this->filesz_ = (last_data->address()
1639 + last_data->data_size()
1640 - this->vaddr_);
1641 }
1642
1643 const Output_data* last;
1644 if (this->output_bss_.empty())
1645 last = this->output_data_.back();
1646 else
1647 last = this->output_bss_.back();
1648 this->memsz_ = (last->address()
1649 + last->data_size()
1650 - this->vaddr_);
75f65a3e
ILT
1651}
1652
1653// Return the number of Output_sections in an Output_segment.
1654
1655unsigned int
1656Output_segment::output_section_count() const
1657{
1658 return (this->output_section_count_list(&this->output_data_)
1659 + this->output_section_count_list(&this->output_bss_));
1660}
1661
1662// Return the number of Output_sections in an Output_data_list.
1663
1664unsigned int
1665Output_segment::output_section_count_list(const Output_data_list* pdl) const
1666{
1667 unsigned int count = 0;
1668 for (Output_data_list::const_iterator p = pdl->begin();
1669 p != pdl->end();
1670 ++p)
1671 {
1672 if ((*p)->is_section())
1673 ++count;
1674 }
1675 return count;
a2fb1b05
ILT
1676}
1677
61ba1cf9
ILT
1678// Write the segment data into *OPHDR.
1679
1680template<int size, bool big_endian>
1681void
ead1e424 1682Output_segment::write_header(elfcpp::Phdr_write<size, big_endian>* ophdr)
61ba1cf9
ILT
1683{
1684 ophdr->put_p_type(this->type_);
1685 ophdr->put_p_offset(this->offset_);
1686 ophdr->put_p_vaddr(this->vaddr_);
1687 ophdr->put_p_paddr(this->paddr_);
1688 ophdr->put_p_filesz(this->filesz_);
1689 ophdr->put_p_memsz(this->memsz_);
1690 ophdr->put_p_flags(this->flags_);
ead1e424 1691 ophdr->put_p_align(this->addralign());
61ba1cf9
ILT
1692}
1693
1694// Write the section headers into V.
1695
1696template<int size, bool big_endian>
1697unsigned char*
16649710
ILT
1698Output_segment::write_section_headers(const Layout* layout,
1699 const Stringpool* secnamepool,
ead1e424
ILT
1700 unsigned char* v,
1701 unsigned int *pshndx
5482377d
ILT
1702 ACCEPT_SIZE_ENDIAN) const
1703{
ead1e424
ILT
1704 // Every section that is attached to a segment must be attached to a
1705 // PT_LOAD segment, so we only write out section headers for PT_LOAD
1706 // segments.
1707 if (this->type_ != elfcpp::PT_LOAD)
1708 return v;
1709
593f47df
ILT
1710 v = this->write_section_headers_list
1711 SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
16649710 1712 layout, secnamepool, &this->output_data_, v, pshndx
593f47df
ILT
1713 SELECT_SIZE_ENDIAN(size, big_endian));
1714 v = this->write_section_headers_list
1715 SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
16649710 1716 layout, secnamepool, &this->output_bss_, v, pshndx
593f47df 1717 SELECT_SIZE_ENDIAN(size, big_endian));
61ba1cf9
ILT
1718 return v;
1719}
1720
1721template<int size, bool big_endian>
1722unsigned char*
16649710
ILT
1723Output_segment::write_section_headers_list(const Layout* layout,
1724 const Stringpool* secnamepool,
61ba1cf9 1725 const Output_data_list* pdl,
ead1e424
ILT
1726 unsigned char* v,
1727 unsigned int* pshndx
5482377d 1728 ACCEPT_SIZE_ENDIAN) const
61ba1cf9
ILT
1729{
1730 const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
1731 for (Output_data_list::const_iterator p = pdl->begin();
1732 p != pdl->end();
1733 ++p)
1734 {
1735 if ((*p)->is_section())
1736 {
5482377d 1737 const Output_section* ps = static_cast<const Output_section*>(*p);
a3ad94ed 1738 gold_assert(*pshndx == ps->out_shndx());
61ba1cf9 1739 elfcpp::Shdr_write<size, big_endian> oshdr(v);
16649710 1740 ps->write_header(layout, secnamepool, &oshdr);
61ba1cf9 1741 v += shdr_size;
ead1e424 1742 ++*pshndx;
61ba1cf9
ILT
1743 }
1744 }
1745 return v;
1746}
1747
a2fb1b05
ILT
1748// Output_file methods.
1749
c51e6221 1750Output_file::Output_file(const General_options& options, Target* target)
61ba1cf9 1751 : options_(options),
c51e6221 1752 target_(target),
61ba1cf9
ILT
1753 name_(options.output_file_name()),
1754 o_(-1),
1755 file_size_(0),
1756 base_(NULL)
1757{
1758}
1759
1760// Open the output file.
1761
a2fb1b05 1762void
61ba1cf9 1763Output_file::open(off_t file_size)
a2fb1b05 1764{
61ba1cf9
ILT
1765 this->file_size_ = file_size;
1766
4e9d8586
ILT
1767 // Unlink the file first; otherwise the open() may fail if the file
1768 // is busy (e.g. it's an executable that's currently being executed).
1769 //
1770 // However, the linker may be part of a system where a zero-length
1771 // file is created for it to write to, with tight permissions (gcc
1772 // 2.95 did something like this). Unlinking the file would work
1773 // around those permission controls, so we only unlink if the file
1774 // has a non-zero size. We also unlink only regular files to avoid
1775 // trouble with directories/etc.
1776 //
1777 // If we fail, continue; this command is merely a best-effort attempt
1778 // to improve the odds for open().
1779
4e9d8586 1780 struct stat s;
5ffcaa86
ILT
1781 if (::stat(this->name_, &s) == 0 && s.st_size != 0)
1782 unlink_if_ordinary(this->name_);
4e9d8586 1783
7e1edb90 1784 int mode = parameters->output_is_object() ? 0666 : 0777;
61ba1cf9
ILT
1785 int o = ::open(this->name_, O_RDWR | O_CREAT | O_TRUNC, mode);
1786 if (o < 0)
75f2446e 1787 gold_fatal(_("%s: open: %s"), this->name_, strerror(errno));
61ba1cf9
ILT
1788 this->o_ = o;
1789
1790 // Write out one byte to make the file the right size.
1791 if (::lseek(o, file_size - 1, SEEK_SET) < 0)
75f2446e 1792 gold_fatal(_("%s: lseek: %s"), this->name_, strerror(errno));
61ba1cf9
ILT
1793 char b = 0;
1794 if (::write(o, &b, 1) != 1)
75f2446e 1795 gold_fatal(_("%s: write: %s"), this->name_, strerror(errno));
61ba1cf9
ILT
1796
1797 // Map the file into memory.
1798 void* base = ::mmap(NULL, file_size, PROT_READ | PROT_WRITE,
1799 MAP_SHARED, o, 0);
1800 if (base == MAP_FAILED)
75f2446e 1801 gold_fatal(_("%s: mmap: %s"), this->name_, strerror(errno));
61ba1cf9
ILT
1802 this->base_ = static_cast<unsigned char*>(base);
1803}
1804
1805// Close the output file.
1806
1807void
1808Output_file::close()
1809{
1810 if (::munmap(this->base_, this->file_size_) < 0)
a0c4fb0a 1811 gold_error(_("%s: munmap: %s"), this->name_, strerror(errno));
61ba1cf9
ILT
1812 this->base_ = NULL;
1813
1814 if (::close(this->o_) < 0)
75f2446e 1815 gold_error(_("%s: close: %s"), this->name_, strerror(errno));
61ba1cf9 1816 this->o_ = -1;
a2fb1b05
ILT
1817}
1818
1819// Instantiate the templates we need. We could use the configure
1820// script to restrict this to only the ones for implemented targets.
1821
193a53d9 1822#ifdef HAVE_TARGET_32_LITTLE
a2fb1b05
ILT
1823template
1824off_t
1825Output_section::add_input_section<32, false>(
730cdc88 1826 Sized_relobj<32, false>* object,
ead1e424 1827 unsigned int shndx,
a2fb1b05 1828 const char* secname,
730cdc88
ILT
1829 const elfcpp::Shdr<32, false>& shdr,
1830 unsigned int reloc_shndx);
193a53d9 1831#endif
a2fb1b05 1832
193a53d9 1833#ifdef HAVE_TARGET_32_BIG
a2fb1b05
ILT
1834template
1835off_t
1836Output_section::add_input_section<32, true>(
730cdc88 1837 Sized_relobj<32, true>* object,
ead1e424 1838 unsigned int shndx,
a2fb1b05 1839 const char* secname,
730cdc88
ILT
1840 const elfcpp::Shdr<32, true>& shdr,
1841 unsigned int reloc_shndx);
193a53d9 1842#endif
a2fb1b05 1843
193a53d9 1844#ifdef HAVE_TARGET_64_LITTLE
a2fb1b05
ILT
1845template
1846off_t
1847Output_section::add_input_section<64, false>(
730cdc88 1848 Sized_relobj<64, false>* object,
ead1e424 1849 unsigned int shndx,
a2fb1b05 1850 const char* secname,
730cdc88
ILT
1851 const elfcpp::Shdr<64, false>& shdr,
1852 unsigned int reloc_shndx);
193a53d9 1853#endif
a2fb1b05 1854
193a53d9 1855#ifdef HAVE_TARGET_64_BIG
a2fb1b05
ILT
1856template
1857off_t
1858Output_section::add_input_section<64, true>(
730cdc88 1859 Sized_relobj<64, true>* object,
ead1e424 1860 unsigned int shndx,
a2fb1b05 1861 const char* secname,
730cdc88
ILT
1862 const elfcpp::Shdr<64, true>& shdr,
1863 unsigned int reloc_shndx);
193a53d9 1864#endif
a2fb1b05 1865
193a53d9 1866#ifdef HAVE_TARGET_32_LITTLE
c06b7b0b
ILT
1867template
1868class Output_data_reloc<elfcpp::SHT_REL, false, 32, false>;
193a53d9 1869#endif
c06b7b0b 1870
193a53d9 1871#ifdef HAVE_TARGET_32_BIG
c06b7b0b
ILT
1872template
1873class Output_data_reloc<elfcpp::SHT_REL, false, 32, true>;
193a53d9 1874#endif
c06b7b0b 1875
193a53d9 1876#ifdef HAVE_TARGET_64_LITTLE
c06b7b0b
ILT
1877template
1878class Output_data_reloc<elfcpp::SHT_REL, false, 64, false>;
193a53d9 1879#endif
c06b7b0b 1880
193a53d9 1881#ifdef HAVE_TARGET_64_BIG
c06b7b0b
ILT
1882template
1883class Output_data_reloc<elfcpp::SHT_REL, false, 64, true>;
193a53d9 1884#endif
c06b7b0b 1885
193a53d9 1886#ifdef HAVE_TARGET_32_LITTLE
c06b7b0b
ILT
1887template
1888class Output_data_reloc<elfcpp::SHT_REL, true, 32, false>;
193a53d9 1889#endif
c06b7b0b 1890
193a53d9 1891#ifdef HAVE_TARGET_32_BIG
c06b7b0b
ILT
1892template
1893class Output_data_reloc<elfcpp::SHT_REL, true, 32, true>;
193a53d9 1894#endif
c06b7b0b 1895
193a53d9 1896#ifdef HAVE_TARGET_64_LITTLE
c06b7b0b
ILT
1897template
1898class Output_data_reloc<elfcpp::SHT_REL, true, 64, false>;
193a53d9 1899#endif
c06b7b0b 1900
193a53d9 1901#ifdef HAVE_TARGET_64_BIG
c06b7b0b
ILT
1902template
1903class Output_data_reloc<elfcpp::SHT_REL, true, 64, true>;
193a53d9 1904#endif
c06b7b0b 1905
193a53d9 1906#ifdef HAVE_TARGET_32_LITTLE
c06b7b0b
ILT
1907template
1908class Output_data_reloc<elfcpp::SHT_RELA, false, 32, false>;
193a53d9 1909#endif
c06b7b0b 1910
193a53d9 1911#ifdef HAVE_TARGET_32_BIG
c06b7b0b
ILT
1912template
1913class Output_data_reloc<elfcpp::SHT_RELA, false, 32, true>;
193a53d9 1914#endif
c06b7b0b 1915
193a53d9 1916#ifdef HAVE_TARGET_64_LITTLE
c06b7b0b
ILT
1917template
1918class Output_data_reloc<elfcpp::SHT_RELA, false, 64, false>;
193a53d9 1919#endif
c06b7b0b 1920
193a53d9 1921#ifdef HAVE_TARGET_64_BIG
c06b7b0b
ILT
1922template
1923class Output_data_reloc<elfcpp::SHT_RELA, false, 64, true>;
193a53d9 1924#endif
c06b7b0b 1925
193a53d9 1926#ifdef HAVE_TARGET_32_LITTLE
c06b7b0b
ILT
1927template
1928class Output_data_reloc<elfcpp::SHT_RELA, true, 32, false>;
193a53d9 1929#endif
c06b7b0b 1930
193a53d9 1931#ifdef HAVE_TARGET_32_BIG
c06b7b0b
ILT
1932template
1933class Output_data_reloc<elfcpp::SHT_RELA, true, 32, true>;
193a53d9 1934#endif
c06b7b0b 1935
193a53d9 1936#ifdef HAVE_TARGET_64_LITTLE
c06b7b0b
ILT
1937template
1938class Output_data_reloc<elfcpp::SHT_RELA, true, 64, false>;
193a53d9 1939#endif
c06b7b0b 1940
193a53d9 1941#ifdef HAVE_TARGET_64_BIG
c06b7b0b
ILT
1942template
1943class Output_data_reloc<elfcpp::SHT_RELA, true, 64, true>;
193a53d9 1944#endif
c06b7b0b 1945
193a53d9 1946#ifdef HAVE_TARGET_32_LITTLE
ead1e424 1947template
dbe717ef 1948class Output_data_got<32, false>;
193a53d9 1949#endif
ead1e424 1950
193a53d9 1951#ifdef HAVE_TARGET_32_BIG
ead1e424 1952template
dbe717ef 1953class Output_data_got<32, true>;
193a53d9 1954#endif
ead1e424 1955
193a53d9 1956#ifdef HAVE_TARGET_64_LITTLE
ead1e424 1957template
dbe717ef 1958class Output_data_got<64, false>;
193a53d9 1959#endif
ead1e424 1960
193a53d9 1961#ifdef HAVE_TARGET_64_BIG
ead1e424 1962template
dbe717ef 1963class Output_data_got<64, true>;
193a53d9 1964#endif
ead1e424 1965
a2fb1b05 1966} // End namespace gold.
This page took 0.156018 seconds and 4 git commands to generate.