1 // dynobj.cc -- dynamic object support for gold
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
29 #include "parameters.h"
38 // Sets up the default soname_ to use, in the (rare) cases we never
39 // see a DT_SONAME entry.
41 Dynobj::Dynobj(const std::string
& name
, Input_file
* input_file
, off_t offset
)
42 : Object(name
, input_file
, true, offset
)
44 // This will be overridden by a DT_SONAME entry, hopefully. But if
45 // we never see a DT_SONAME entry, our rule is to use the dynamic
46 // object's filename. The only exception is when the dynamic object
47 // is part of an archive (so the filename is the archive's
48 // filename). In that case, we use just the dynobj's name-in-archive.
49 this->soname_
= this->input_file()->found_name();
50 if (this->offset() != 0)
52 std::string::size_type open_paren
= this->name().find('(');
53 std::string::size_type close_paren
= this->name().find(')');
54 if (open_paren
!= std::string::npos
&& close_paren
!= std::string::npos
)
56 // It's an archive, and name() is of the form 'foo.a(bar.so)'.
57 this->soname_
= this->name().substr(open_paren
+ 1,
58 close_paren
- (open_paren
+ 1));
63 // Return the string to use in a DT_NEEDED entry.
66 Dynobj::soname() const
68 return this->soname_
.c_str();
71 // Class Sized_dynobj.
73 template<int size
, bool big_endian
>
74 Sized_dynobj
<size
, big_endian
>::Sized_dynobj(
75 const std::string
& name
,
76 Input_file
* input_file
,
78 const elfcpp::Ehdr
<size
, big_endian
>& ehdr
)
79 : Dynobj(name
, input_file
, offset
),
86 template<int size
, bool big_endian
>
88 Sized_dynobj
<size
, big_endian
>::setup(
89 const elfcpp::Ehdr
<size
, big_endian
>& ehdr
)
91 this->set_target(ehdr
.get_e_machine(), size
, big_endian
,
92 ehdr
.get_e_ident()[elfcpp::EI_OSABI
],
93 ehdr
.get_e_ident()[elfcpp::EI_ABIVERSION
]);
95 const unsigned int shnum
= this->elf_file_
.shnum();
96 this->set_shnum(shnum
);
99 // Find the SHT_DYNSYM section and the various version sections, and
100 // the dynamic section, given the section headers.
102 template<int size
, bool big_endian
>
104 Sized_dynobj
<size
, big_endian
>::find_dynsym_sections(
105 const unsigned char* pshdrs
,
106 unsigned int* pdynsym_shndx
,
107 unsigned int* pversym_shndx
,
108 unsigned int* pverdef_shndx
,
109 unsigned int* pverneed_shndx
,
110 unsigned int* pdynamic_shndx
)
112 *pdynsym_shndx
= -1U;
113 *pversym_shndx
= -1U;
114 *pverdef_shndx
= -1U;
115 *pverneed_shndx
= -1U;
116 *pdynamic_shndx
= -1U;
118 const unsigned int shnum
= this->shnum();
119 const unsigned char* p
= pshdrs
;
120 for (unsigned int i
= 0; i
< shnum
; ++i
, p
+= This::shdr_size
)
122 typename
This::Shdr
shdr(p
);
125 switch (shdr
.get_sh_type())
127 case elfcpp::SHT_DYNSYM
:
130 case elfcpp::SHT_GNU_versym
:
133 case elfcpp::SHT_GNU_verdef
:
136 case elfcpp::SHT_GNU_verneed
:
139 case elfcpp::SHT_DYNAMIC
:
151 this->error(_("unexpected duplicate type %u section: %u, %u"),
152 shdr
.get_sh_type(), *pi
, i
);
158 // Read the contents of section SHNDX. PSHDRS points to the section
159 // headers. TYPE is the expected section type. LINK is the expected
160 // section link. Store the data in *VIEW and *VIEW_SIZE. The
161 // section's sh_info field is stored in *VIEW_INFO.
163 template<int size
, bool big_endian
>
165 Sized_dynobj
<size
, big_endian
>::read_dynsym_section(
166 const unsigned char* pshdrs
,
172 unsigned int* view_info
)
182 typename
This::Shdr
shdr(pshdrs
+ shndx
* This::shdr_size
);
184 gold_assert(shdr
.get_sh_type() == type
);
186 if (shdr
.get_sh_link() != link
)
187 this->error(_("unexpected link in section %u header: %u != %u"),
188 shndx
, shdr
.get_sh_link(), link
);
190 *view
= this->get_lasting_view(shdr
.get_sh_offset(), shdr
.get_sh_size(),
192 *view_size
= shdr
.get_sh_size();
193 *view_info
= shdr
.get_sh_info();
196 // Set the soname field if this shared object has a DT_SONAME tag.
197 // PSHDRS points to the section headers. DYNAMIC_SHNDX is the section
198 // index of the SHT_DYNAMIC section. STRTAB_SHNDX, STRTAB, and
199 // STRTAB_SIZE are the section index and contents of a string table
200 // which may be the one associated with the SHT_DYNAMIC section.
202 template<int size
, bool big_endian
>
204 Sized_dynobj
<size
, big_endian
>::set_soname(const unsigned char* pshdrs
,
205 unsigned int dynamic_shndx
,
206 unsigned int strtab_shndx
,
207 const unsigned char* strtabu
,
210 typename
This::Shdr
dynamicshdr(pshdrs
+ dynamic_shndx
* This::shdr_size
);
211 gold_assert(dynamicshdr
.get_sh_type() == elfcpp::SHT_DYNAMIC
);
213 const off_t dynamic_size
= dynamicshdr
.get_sh_size();
214 const unsigned char* pdynamic
= this->get_view(dynamicshdr
.get_sh_offset(),
215 dynamic_size
, false);
217 const unsigned int link
= dynamicshdr
.get_sh_link();
218 if (link
!= strtab_shndx
)
220 if (link
>= this->shnum())
222 this->error(_("DYNAMIC section %u link out of range: %u"),
223 dynamic_shndx
, link
);
227 typename
This::Shdr
strtabshdr(pshdrs
+ link
* This::shdr_size
);
228 if (strtabshdr
.get_sh_type() != elfcpp::SHT_STRTAB
)
230 this->error(_("DYNAMIC section %u link %u is not a strtab"),
231 dynamic_shndx
, link
);
235 strtab_size
= strtabshdr
.get_sh_size();
236 strtabu
= this->get_view(strtabshdr
.get_sh_offset(), strtab_size
, false);
239 for (const unsigned char* p
= pdynamic
;
240 p
< pdynamic
+ dynamic_size
;
243 typename
This::Dyn
dyn(p
);
245 if (dyn
.get_d_tag() == elfcpp::DT_SONAME
)
247 off_t val
= dyn
.get_d_val();
248 if (val
>= strtab_size
)
250 this->error(_("DT_SONAME value out of range: %lld >= %lld"),
251 static_cast<long long>(val
),
252 static_cast<long long>(strtab_size
));
256 const char* strtab
= reinterpret_cast<const char*>(strtabu
);
257 this->set_soname_string(strtab
+ val
);
261 if (dyn
.get_d_tag() == elfcpp::DT_NULL
)
265 this->error(_("missing DT_NULL in dynamic segment"));
268 // Read the symbols and sections from a dynamic object. We read the
269 // dynamic symbols, not the normal symbols.
271 template<int size
, bool big_endian
>
273 Sized_dynobj
<size
, big_endian
>::do_read_symbols(Read_symbols_data
* sd
)
275 this->read_section_data(&this->elf_file_
, sd
);
277 const unsigned char* const pshdrs
= sd
->section_headers
->data();
279 unsigned int dynsym_shndx
;
280 unsigned int versym_shndx
;
281 unsigned int verdef_shndx
;
282 unsigned int verneed_shndx
;
283 unsigned int dynamic_shndx
;
284 this->find_dynsym_sections(pshdrs
, &dynsym_shndx
, &versym_shndx
,
285 &verdef_shndx
, &verneed_shndx
, &dynamic_shndx
);
287 unsigned int strtab_shndx
= -1U;
290 sd
->symbols_size
= 0;
291 sd
->external_symbols_offset
= 0;
292 sd
->symbol_names
= NULL
;
293 sd
->symbol_names_size
= 0;
295 if (dynsym_shndx
!= -1U)
297 // Get the dynamic symbols.
298 typename
This::Shdr
dynsymshdr(pshdrs
+ dynsym_shndx
* This::shdr_size
);
299 gold_assert(dynsymshdr
.get_sh_type() == elfcpp::SHT_DYNSYM
);
301 sd
->symbols
= this->get_lasting_view(dynsymshdr
.get_sh_offset(),
302 dynsymshdr
.get_sh_size(), false);
303 sd
->symbols_size
= dynsymshdr
.get_sh_size();
305 // Get the symbol names.
306 strtab_shndx
= dynsymshdr
.get_sh_link();
307 if (strtab_shndx
>= this->shnum())
309 this->error(_("invalid dynamic symbol table name index: %u"),
313 typename
This::Shdr
strtabshdr(pshdrs
+ strtab_shndx
* This::shdr_size
);
314 if (strtabshdr
.get_sh_type() != elfcpp::SHT_STRTAB
)
316 this->error(_("dynamic symbol table name section "
317 "has wrong type: %u"),
318 static_cast<unsigned int>(strtabshdr
.get_sh_type()));
322 sd
->symbol_names
= this->get_lasting_view(strtabshdr
.get_sh_offset(),
323 strtabshdr
.get_sh_size(),
325 sd
->symbol_names_size
= strtabshdr
.get_sh_size();
327 // Get the version information.
330 this->read_dynsym_section(pshdrs
, versym_shndx
, elfcpp::SHT_GNU_versym
,
331 dynsym_shndx
, &sd
->versym
, &sd
->versym_size
,
334 // We require that the version definition and need section link
335 // to the same string table as the dynamic symbol table. This
336 // is not a technical requirement, but it always happens in
337 // practice. We could change this if necessary.
339 this->read_dynsym_section(pshdrs
, verdef_shndx
, elfcpp::SHT_GNU_verdef
,
340 strtab_shndx
, &sd
->verdef
, &sd
->verdef_size
,
343 this->read_dynsym_section(pshdrs
, verneed_shndx
, elfcpp::SHT_GNU_verneed
,
344 strtab_shndx
, &sd
->verneed
, &sd
->verneed_size
,
348 // Read the SHT_DYNAMIC section to find whether this shared object
349 // has a DT_SONAME tag. This doesn't really have anything to do
350 // with reading the symbols, but this is a convenient place to do
352 if (dynamic_shndx
!= -1U)
353 this->set_soname(pshdrs
, dynamic_shndx
, strtab_shndx
,
354 (sd
->symbol_names
== NULL
356 : sd
->symbol_names
->data()),
357 sd
->symbol_names_size
);
360 // Lay out the input sections for a dynamic object. We don't want to
361 // include sections from a dynamic object, so all that we actually do
362 // here is check for .gnu.warning sections.
364 template<int size
, bool big_endian
>
366 Sized_dynobj
<size
, big_endian
>::do_layout(Symbol_table
* symtab
,
368 Read_symbols_data
* sd
)
370 const unsigned int shnum
= this->shnum();
374 // Get the section headers.
375 const unsigned char* pshdrs
= sd
->section_headers
->data();
377 // Get the section names.
378 const unsigned char* pnamesu
= sd
->section_names
->data();
379 const char* pnames
= reinterpret_cast<const char*>(pnamesu
);
381 // Skip the first, dummy, section.
382 pshdrs
+= This::shdr_size
;
383 for (unsigned int i
= 1; i
< shnum
; ++i
, pshdrs
+= This::shdr_size
)
385 typename
This::Shdr
shdr(pshdrs
);
387 if (shdr
.get_sh_name() >= sd
->section_names_size
)
389 this->error(_("bad section name offset for section %u: %lu"),
390 i
, static_cast<unsigned long>(shdr
.get_sh_name()));
394 const char* name
= pnames
+ shdr
.get_sh_name();
396 this->handle_gnu_warning_section(name
, i
, symtab
);
399 delete sd
->section_headers
;
400 sd
->section_headers
= NULL
;
401 delete sd
->section_names
;
402 sd
->section_names
= NULL
;
405 // Add an entry to the vector mapping version numbers to version
408 template<int size
, bool big_endian
>
410 Sized_dynobj
<size
, big_endian
>::set_version_map(
411 Version_map
* version_map
,
413 const char* name
) const
415 if (ndx
>= version_map
->size())
416 version_map
->resize(ndx
+ 1);
417 if ((*version_map
)[ndx
] != NULL
)
418 this->error(_("duplicate definition for version %u"), ndx
);
419 (*version_map
)[ndx
] = name
;
422 // Add mappings for the version definitions to VERSION_MAP.
424 template<int size
, bool big_endian
>
426 Sized_dynobj
<size
, big_endian
>::make_verdef_map(
427 Read_symbols_data
* sd
,
428 Version_map
* version_map
) const
430 if (sd
->verdef
== NULL
)
433 const char* names
= reinterpret_cast<const char*>(sd
->symbol_names
->data());
434 off_t names_size
= sd
->symbol_names_size
;
436 const unsigned char* pverdef
= sd
->verdef
->data();
437 off_t verdef_size
= sd
->verdef_size
;
438 const unsigned int count
= sd
->verdef_info
;
440 const unsigned char* p
= pverdef
;
441 for (unsigned int i
= 0; i
< count
; ++i
)
443 elfcpp::Verdef
<size
, big_endian
> verdef(p
);
445 if (verdef
.get_vd_version() != elfcpp::VER_DEF_CURRENT
)
447 this->error(_("unexpected verdef version %u"),
448 verdef
.get_vd_version());
452 const unsigned int vd_ndx
= verdef
.get_vd_ndx();
454 // The GNU linker clears the VERSYM_HIDDEN bit. I'm not
457 // The first Verdaux holds the name of this version. Subsequent
458 // ones are versions that this one depends upon, which we don't
460 const unsigned int vd_cnt
= verdef
.get_vd_cnt();
463 this->error(_("verdef vd_cnt field too small: %u"), vd_cnt
);
467 const unsigned int vd_aux
= verdef
.get_vd_aux();
468 if ((p
- pverdef
) + vd_aux
>= verdef_size
)
470 this->error(_("verdef vd_aux field out of range: %u"), vd_aux
);
474 const unsigned char* pvda
= p
+ vd_aux
;
475 elfcpp::Verdaux
<size
, big_endian
> verdaux(pvda
);
477 const unsigned int vda_name
= verdaux
.get_vda_name();
478 if (vda_name
>= names_size
)
480 this->error(_("verdaux vda_name field out of range: %u"), vda_name
);
484 this->set_version_map(version_map
, vd_ndx
, names
+ vda_name
);
486 const unsigned int vd_next
= verdef
.get_vd_next();
487 if ((p
- pverdef
) + vd_next
>= verdef_size
)
489 this->error(_("verdef vd_next field out of range: %u"), vd_next
);
497 // Add mappings for the required versions to VERSION_MAP.
499 template<int size
, bool big_endian
>
501 Sized_dynobj
<size
, big_endian
>::make_verneed_map(
502 Read_symbols_data
* sd
,
503 Version_map
* version_map
) const
505 if (sd
->verneed
== NULL
)
508 const char* names
= reinterpret_cast<const char*>(sd
->symbol_names
->data());
509 off_t names_size
= sd
->symbol_names_size
;
511 const unsigned char* pverneed
= sd
->verneed
->data();
512 const off_t verneed_size
= sd
->verneed_size
;
513 const unsigned int count
= sd
->verneed_info
;
515 const unsigned char* p
= pverneed
;
516 for (unsigned int i
= 0; i
< count
; ++i
)
518 elfcpp::Verneed
<size
, big_endian
> verneed(p
);
520 if (verneed
.get_vn_version() != elfcpp::VER_NEED_CURRENT
)
522 this->error(_("unexpected verneed version %u"),
523 verneed
.get_vn_version());
527 const unsigned int vn_aux
= verneed
.get_vn_aux();
529 if ((p
- pverneed
) + vn_aux
>= verneed_size
)
531 this->error(_("verneed vn_aux field out of range: %u"), vn_aux
);
535 const unsigned int vn_cnt
= verneed
.get_vn_cnt();
536 const unsigned char* pvna
= p
+ vn_aux
;
537 for (unsigned int j
= 0; j
< vn_cnt
; ++j
)
539 elfcpp::Vernaux
<size
, big_endian
> vernaux(pvna
);
541 const unsigned int vna_name
= vernaux
.get_vna_name();
542 if (vna_name
>= names_size
)
544 this->error(_("vernaux vna_name field out of range: %u"),
549 this->set_version_map(version_map
, vernaux
.get_vna_other(),
552 const unsigned int vna_next
= vernaux
.get_vna_next();
553 if ((pvna
- pverneed
) + vna_next
>= verneed_size
)
555 this->error(_("verneed vna_next field out of range: %u"),
563 const unsigned int vn_next
= verneed
.get_vn_next();
564 if ((p
- pverneed
) + vn_next
>= verneed_size
)
566 this->error(_("verneed vn_next field out of range: %u"), vn_next
);
574 // Create a vector mapping version numbers to version strings.
576 template<int size
, bool big_endian
>
578 Sized_dynobj
<size
, big_endian
>::make_version_map(
579 Read_symbols_data
* sd
,
580 Version_map
* version_map
) const
582 if (sd
->verdef
== NULL
&& sd
->verneed
== NULL
)
585 // A guess at the maximum version number we will see. If this is
586 // wrong we will be less efficient but still correct.
587 version_map
->reserve(sd
->verdef_info
+ sd
->verneed_info
* 10);
589 this->make_verdef_map(sd
, version_map
);
590 this->make_verneed_map(sd
, version_map
);
593 // Add the dynamic symbols to the symbol table.
595 template<int size
, bool big_endian
>
597 Sized_dynobj
<size
, big_endian
>::do_add_symbols(Symbol_table
* symtab
,
598 Read_symbols_data
* sd
)
600 if (sd
->symbols
== NULL
)
602 gold_assert(sd
->symbol_names
== NULL
);
603 gold_assert(sd
->versym
== NULL
&& sd
->verdef
== NULL
604 && sd
->verneed
== NULL
);
608 const int sym_size
= This::sym_size
;
609 const size_t symcount
= sd
->symbols_size
/ sym_size
;
610 gold_assert(sd
->external_symbols_offset
== 0);
611 if (static_cast<off_t
>(symcount
* sym_size
) != sd
->symbols_size
)
613 this->error(_("size of dynamic symbols is not multiple of symbol size"));
617 Version_map version_map
;
618 this->make_version_map(sd
, &version_map
);
620 const char* sym_names
=
621 reinterpret_cast<const char*>(sd
->symbol_names
->data());
622 symtab
->add_from_dynobj(this, sd
->symbols
->data(), symcount
,
623 sym_names
, sd
->symbol_names_size
,
626 : sd
->versym
->data()),
632 delete sd
->symbol_names
;
633 sd
->symbol_names
= NULL
;
634 if (sd
->versym
!= NULL
)
639 if (sd
->verdef
!= NULL
)
644 if (sd
->verneed
!= NULL
)
651 // Given a vector of hash codes, compute the number of hash buckets to
655 Dynobj::compute_bucket_count(const std::vector
<uint32_t>& hashcodes
,
656 bool for_gnu_hash_table
)
658 // FIXME: Implement optional hash table optimization.
660 // Array used to determine the number of hash table buckets to use
661 // based on the number of symbols there are. If there are fewer
662 // than 3 symbols we use 1 bucket, fewer than 17 symbols we use 3
663 // buckets, fewer than 37 we use 17 buckets, and so forth. We never
664 // use more than 32771 buckets. This is straight from the old GNU
666 static const unsigned int buckets
[] =
668 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209,
671 const int buckets_count
= sizeof buckets
/ sizeof buckets
[0];
673 unsigned int symcount
= hashcodes
.size();
674 unsigned int ret
= 1;
675 for (int i
= 0; i
< buckets_count
; ++i
)
677 if (symcount
< buckets
[i
])
682 if (for_gnu_hash_table
&& ret
< 2)
688 // The standard ELF hash function. This hash function must not
689 // change, as the dynamic linker uses it also.
692 Dynobj::elf_hash(const char* name
)
694 const unsigned char* nameu
= reinterpret_cast<const unsigned char*>(name
);
697 while ((c
= *nameu
++) != '\0')
700 uint32_t g
= h
& 0xf0000000;
704 // The ELF ABI says h &= ~g, but using xor is equivalent in
705 // this case (since g was set from h) and may save one
713 // Create a standard ELF hash table, setting *PPHASH and *PHASHLEN.
714 // DYNSYMS is a vector with all the global dynamic symbols.
715 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
719 Dynobj::create_elf_hash_table(const std::vector
<Symbol
*>& dynsyms
,
720 unsigned int local_dynsym_count
,
721 unsigned char** pphash
,
722 unsigned int* phashlen
)
724 unsigned int dynsym_count
= dynsyms
.size();
726 // Get the hash values for all the symbols.
727 std::vector
<uint32_t> dynsym_hashvals(dynsym_count
);
728 for (unsigned int i
= 0; i
< dynsym_count
; ++i
)
729 dynsym_hashvals
[i
] = Dynobj::elf_hash(dynsyms
[i
]->name());
731 const unsigned int bucketcount
=
732 Dynobj::compute_bucket_count(dynsym_hashvals
, false);
734 std::vector
<uint32_t> bucket(bucketcount
);
735 std::vector
<uint32_t> chain(local_dynsym_count
+ dynsym_count
);
737 for (unsigned int i
= 0; i
< dynsym_count
; ++i
)
739 unsigned int dynsym_index
= dynsyms
[i
]->dynsym_index();
740 unsigned int bucketpos
= dynsym_hashvals
[i
] % bucketcount
;
741 chain
[dynsym_index
] = bucket
[bucketpos
];
742 bucket
[bucketpos
] = dynsym_index
;
745 unsigned int hashlen
= ((2
750 unsigned char* phash
= new unsigned char[hashlen
];
752 if (parameters
->is_big_endian())
754 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
755 Dynobj::sized_create_elf_hash_table
<true>(bucket
, chain
, phash
,
763 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
764 Dynobj::sized_create_elf_hash_table
<false>(bucket
, chain
, phash
,
775 // Fill in an ELF hash table.
777 template<bool big_endian
>
779 Dynobj::sized_create_elf_hash_table(const std::vector
<uint32_t>& bucket
,
780 const std::vector
<uint32_t>& chain
,
781 unsigned char* phash
,
782 unsigned int hashlen
)
784 unsigned char* p
= phash
;
786 const unsigned int bucketcount
= bucket
.size();
787 const unsigned int chaincount
= chain
.size();
789 elfcpp::Swap
<32, big_endian
>::writeval(p
, bucketcount
);
791 elfcpp::Swap
<32, big_endian
>::writeval(p
, chaincount
);
794 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
796 elfcpp::Swap
<32, big_endian
>::writeval(p
, bucket
[i
]);
800 for (unsigned int i
= 0; i
< chaincount
; ++i
)
802 elfcpp::Swap
<32, big_endian
>::writeval(p
, chain
[i
]);
806 gold_assert(static_cast<unsigned int>(p
- phash
) == hashlen
);
809 // The hash function used for the GNU hash table. This hash function
810 // must not change, as the dynamic linker uses it also.
813 Dynobj::gnu_hash(const char* name
)
815 const unsigned char* nameu
= reinterpret_cast<const unsigned char*>(name
);
818 while ((c
= *nameu
++) != '\0')
819 h
= (h
<< 5) + h
+ c
;
823 // Create a GNU hash table, setting *PPHASH and *PHASHLEN. GNU hash
824 // tables are an extension to ELF which are recognized by the GNU
825 // dynamic linker. They are referenced using dynamic tag DT_GNU_HASH.
826 // TARGET is the target. DYNSYMS is a vector with all the global
827 // symbols which will be going into the dynamic symbol table.
828 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
832 Dynobj::create_gnu_hash_table(const std::vector
<Symbol
*>& dynsyms
,
833 unsigned int local_dynsym_count
,
834 unsigned char** pphash
,
835 unsigned int* phashlen
)
837 const unsigned int count
= dynsyms
.size();
839 // Sort the dynamic symbols into two vectors. Symbols which we do
840 // not want to put into the hash table we store into
841 // UNHASHED_DYNSYMS. Symbols which we do want to store we put into
842 // HASHED_DYNSYMS. DYNSYM_HASHVALS is parallel to HASHED_DYNSYMS,
843 // and records the hash codes.
845 std::vector
<Symbol
*> unhashed_dynsyms
;
846 unhashed_dynsyms
.reserve(count
);
848 std::vector
<Symbol
*> hashed_dynsyms
;
849 hashed_dynsyms
.reserve(count
);
851 std::vector
<uint32_t> dynsym_hashvals
;
852 dynsym_hashvals
.reserve(count
);
854 for (unsigned int i
= 0; i
< count
; ++i
)
856 Symbol
* sym
= dynsyms
[i
];
858 // FIXME: Should put on unhashed_dynsyms if the symbol is
860 if (sym
->is_undefined())
861 unhashed_dynsyms
.push_back(sym
);
864 hashed_dynsyms
.push_back(sym
);
865 dynsym_hashvals
.push_back(Dynobj::gnu_hash(sym
->name()));
869 // Put the unhashed symbols at the start of the global portion of
870 // the dynamic symbol table.
871 const unsigned int unhashed_count
= unhashed_dynsyms
.size();
872 unsigned int unhashed_dynsym_index
= local_dynsym_count
;
873 for (unsigned int i
= 0; i
< unhashed_count
; ++i
)
875 unhashed_dynsyms
[i
]->set_dynsym_index(unhashed_dynsym_index
);
876 ++unhashed_dynsym_index
;
879 // For the actual data generation we call out to a templatized
881 int size
= parameters
->get_size();
882 bool big_endian
= parameters
->is_big_endian();
887 #ifdef HAVE_TARGET_32_BIG
888 Dynobj::sized_create_gnu_hash_table
<32, true>(hashed_dynsyms
,
890 unhashed_dynsym_index
,
899 #ifdef HAVE_TARGET_32_LITTLE
900 Dynobj::sized_create_gnu_hash_table
<32, false>(hashed_dynsyms
,
902 unhashed_dynsym_index
,
914 #ifdef HAVE_TARGET_64_BIG
915 Dynobj::sized_create_gnu_hash_table
<64, true>(hashed_dynsyms
,
917 unhashed_dynsym_index
,
926 #ifdef HAVE_TARGET_64_LITTLE
927 Dynobj::sized_create_gnu_hash_table
<64, false>(hashed_dynsyms
,
929 unhashed_dynsym_index
,
941 // Create the actual data for a GNU hash table. This is just a copy
942 // of the code from the old GNU linker.
944 template<int size
, bool big_endian
>
946 Dynobj::sized_create_gnu_hash_table(
947 const std::vector
<Symbol
*>& hashed_dynsyms
,
948 const std::vector
<uint32_t>& dynsym_hashvals
,
949 unsigned int unhashed_dynsym_count
,
950 unsigned char** pphash
,
951 unsigned int* phashlen
)
953 if (hashed_dynsyms
.empty())
955 // Special case for the empty hash table.
956 unsigned int hashlen
= 5 * 4 + size
/ 8;
957 unsigned char* phash
= new unsigned char[hashlen
];
959 elfcpp::Swap
<32, big_endian
>::writeval(phash
, 1);
960 // Symbol index above unhashed symbols.
961 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 4, unhashed_dynsym_count
);
962 // One word for bitmask.
963 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 8, 1);
964 // Only bloom filter.
965 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 12, 0);
967 elfcpp::Swap
<size
, big_endian
>::writeval(phash
+ 16, 0);
968 // No hashes in only bucket.
969 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 16 + size
/ 8, 0);
977 const unsigned int bucketcount
=
978 Dynobj::compute_bucket_count(dynsym_hashvals
, true);
980 const unsigned int nsyms
= hashed_dynsyms
.size();
982 uint32_t maskbitslog2
= 1;
983 uint32_t x
= nsyms
>> 1;
989 if (maskbitslog2
< 3)
991 else if (((1U << (maskbitslog2
- 2)) & nsyms
) != 0)
1001 if (maskbitslog2
== 5)
1005 uint32_t mask
= (1U << shift1
) - 1U;
1006 uint32_t shift2
= maskbitslog2
;
1007 uint32_t maskbits
= 1U << maskbitslog2
;
1008 uint32_t maskwords
= 1U << (maskbitslog2
- shift1
);
1010 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Word
;
1011 std::vector
<Word
> bitmask(maskwords
);
1012 std::vector
<uint32_t> counts(bucketcount
);
1013 std::vector
<uint32_t> indx(bucketcount
);
1014 uint32_t symindx
= unhashed_dynsym_count
;
1016 // Count the number of times each hash bucket is used.
1017 for (unsigned int i
= 0; i
< nsyms
; ++i
)
1018 ++counts
[dynsym_hashvals
[i
] % bucketcount
];
1020 unsigned int cnt
= symindx
;
1021 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
1027 unsigned int hashlen
= (4 + bucketcount
+ nsyms
) * 4;
1028 hashlen
+= maskbits
/ 8;
1029 unsigned char* phash
= new unsigned char[hashlen
];
1031 elfcpp::Swap
<32, big_endian
>::writeval(phash
, bucketcount
);
1032 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 4, symindx
);
1033 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 8, maskwords
);
1034 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 12, shift2
);
1036 unsigned char* p
= phash
+ 16 + maskbits
/ 8;
1037 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
1040 elfcpp::Swap
<32, big_endian
>::writeval(p
, 0);
1042 elfcpp::Swap
<32, big_endian
>::writeval(p
, indx
[i
]);
1046 for (unsigned int i
= 0; i
< nsyms
; ++i
)
1048 Symbol
* sym
= hashed_dynsyms
[i
];
1049 uint32_t hashval
= dynsym_hashvals
[i
];
1051 unsigned int bucket
= hashval
% bucketcount
;
1052 unsigned int val
= ((hashval
>> shift1
)
1053 & ((maskbits
>> shift1
) - 1));
1054 bitmask
[val
] |= (static_cast<Word
>(1U)) << (hashval
& mask
);
1055 bitmask
[val
] |= (static_cast<Word
>(1U)) << ((hashval
>> shift2
) & mask
);
1056 val
= hashval
& ~ 1U;
1057 if (counts
[bucket
] == 1)
1059 // Last element terminates the chain.
1062 elfcpp::Swap
<32, big_endian
>::writeval(p
+ (indx
[bucket
] - symindx
) * 4,
1066 sym
->set_dynsym_index(indx
[bucket
]);
1071 for (unsigned int i
= 0; i
< maskwords
; ++i
)
1073 elfcpp::Swap
<size
, big_endian
>::writeval(p
, bitmask
[i
]);
1077 *phashlen
= hashlen
;
1083 // Write this definition to a buffer for the output section.
1085 template<int size
, bool big_endian
>
1087 Verdef::write(const Stringpool
* dynpool
, bool is_last
, unsigned char* pb
1088 ACCEPT_SIZE_ENDIAN
) const
1090 const int verdef_size
= elfcpp::Elf_sizes
<size
>::verdef_size
;
1091 const int verdaux_size
= elfcpp::Elf_sizes
<size
>::verdaux_size
;
1093 elfcpp::Verdef_write
<size
, big_endian
> vd(pb
);
1094 vd
.set_vd_version(elfcpp::VER_DEF_CURRENT
);
1095 vd
.set_vd_flags((this->is_base_
? elfcpp::VER_FLG_BASE
: 0)
1096 | (this->is_weak_
? elfcpp::VER_FLG_WEAK
: 0));
1097 vd
.set_vd_ndx(this->index());
1098 vd
.set_vd_cnt(1 + this->deps_
.size());
1099 vd
.set_vd_hash(Dynobj::elf_hash(this->name()));
1100 vd
.set_vd_aux(verdef_size
);
1101 vd
.set_vd_next(is_last
1103 : verdef_size
+ (1 + this->deps_
.size()) * verdaux_size
);
1106 elfcpp::Verdaux_write
<size
, big_endian
> vda(pb
);
1107 vda
.set_vda_name(dynpool
->get_offset(this->name()));
1108 vda
.set_vda_next(this->deps_
.empty() ? 0 : verdaux_size
);
1111 Deps::const_iterator p
;
1113 for (p
= this->deps_
.begin(), i
= 0;
1114 p
!= this->deps_
.end();
1117 elfcpp::Verdaux_write
<size
, big_endian
> vda(pb
);
1118 vda
.set_vda_name(dynpool
->get_offset(*p
));
1119 vda
.set_vda_next(i
+ 1 >= this->deps_
.size() ? 0 : verdaux_size
);
1130 for (Need_versions::iterator p
= this->need_versions_
.begin();
1131 p
!= this->need_versions_
.end();
1136 // Add a new version to this file reference.
1139 Verneed::add_name(const char* name
)
1141 Verneed_version
* vv
= new Verneed_version(name
);
1142 this->need_versions_
.push_back(vv
);
1146 // Set the version indexes starting at INDEX.
1149 Verneed::finalize(unsigned int index
)
1151 for (Need_versions::iterator p
= this->need_versions_
.begin();
1152 p
!= this->need_versions_
.end();
1155 (*p
)->set_index(index
);
1161 // Write this list of referenced versions to a buffer for the output
1164 template<int size
, bool big_endian
>
1166 Verneed::write(const Stringpool
* dynpool
, bool is_last
,
1167 unsigned char* pb ACCEPT_SIZE_ENDIAN
) const
1169 const int verneed_size
= elfcpp::Elf_sizes
<size
>::verneed_size
;
1170 const int vernaux_size
= elfcpp::Elf_sizes
<size
>::vernaux_size
;
1172 elfcpp::Verneed_write
<size
, big_endian
> vn(pb
);
1173 vn
.set_vn_version(elfcpp::VER_NEED_CURRENT
);
1174 vn
.set_vn_cnt(this->need_versions_
.size());
1175 vn
.set_vn_file(dynpool
->get_offset(this->filename()));
1176 vn
.set_vn_aux(verneed_size
);
1177 vn
.set_vn_next(is_last
1179 : verneed_size
+ this->need_versions_
.size() * vernaux_size
);
1182 Need_versions::const_iterator p
;
1184 for (p
= this->need_versions_
.begin(), i
= 0;
1185 p
!= this->need_versions_
.end();
1188 elfcpp::Vernaux_write
<size
, big_endian
> vna(pb
);
1189 vna
.set_vna_hash(Dynobj::elf_hash((*p
)->version()));
1190 // FIXME: We need to sometimes set VER_FLG_WEAK here.
1191 vna
.set_vna_flags(0);
1192 vna
.set_vna_other((*p
)->index());
1193 vna
.set_vna_name(dynpool
->get_offset((*p
)->version()));
1194 vna
.set_vna_next(i
+ 1 >= this->need_versions_
.size()
1203 // Versions methods.
1205 Versions::~Versions()
1207 for (Defs::iterator p
= this->defs_
.begin();
1208 p
!= this->defs_
.end();
1212 for (Needs::iterator p
= this->needs_
.begin();
1213 p
!= this->needs_
.end();
1218 // Return the dynamic object which a symbol refers to.
1221 Versions::get_dynobj_for_sym(const Symbol_table
* symtab
,
1222 const Symbol
* sym
) const
1224 if (sym
->is_copied_from_dynobj())
1225 return symtab
->get_copy_source(sym
);
1228 Object
* object
= sym
->object();
1229 gold_assert(object
->is_dynamic());
1230 return static_cast<Dynobj
*>(object
);
1234 // Record version information for a symbol going into the dynamic
1238 Versions::record_version(const Symbol_table
* symtab
,
1239 Stringpool
* dynpool
, const Symbol
* sym
)
1241 gold_assert(!this->is_finalized_
);
1242 gold_assert(sym
->version() != NULL
);
1244 Stringpool::Key version_key
;
1245 const char* version
= dynpool
->add(sym
->version(), false, &version_key
);
1247 if (!sym
->is_from_dynobj() && !sym
->is_copied_from_dynobj())
1249 if (parameters
->output_is_shared())
1250 this->add_def(sym
, version
, version_key
);
1254 // This is a version reference.
1255 Dynobj
* dynobj
= this->get_dynobj_for_sym(symtab
, sym
);
1256 this->add_need(dynpool
, dynobj
->soname(), version
, version_key
);
1260 // We've found a symbol SYM defined in version VERSION.
1263 Versions::add_def(const Symbol
* sym
, const char* version
,
1264 Stringpool::Key version_key
)
1266 Key
k(version_key
, 0);
1267 Version_base
* const vbnull
= NULL
;
1268 std::pair
<Version_table::iterator
, bool> ins
=
1269 this->version_table_
.insert(std::make_pair(k
, vbnull
));
1273 // We already have an entry for this version.
1274 Version_base
* vb
= ins
.first
->second
;
1276 // We have now seen a symbol in this version, so it is not
1280 // FIXME: When we support version scripts, we will need to
1281 // check whether this symbol should be forced local.
1285 // If we are creating a shared object, it is an error to
1286 // find a definition of a symbol with a version which is not
1287 // in the version script.
1288 if (parameters
->output_is_shared())
1290 gold_error(_("symbol %s has undefined version %s"),
1291 sym
->name(), version
);
1295 // If this is the first version we are defining, first define
1296 // the base version. FIXME: Should use soname here when
1297 // creating a shared object.
1298 Verdef
* vdbase
= new Verdef(parameters
->output_file_name(), true, false,
1300 this->defs_
.push_back(vdbase
);
1302 // When creating a regular executable, automatically define
1304 Verdef
* vd
= new Verdef(version
, false, false, false);
1305 this->defs_
.push_back(vd
);
1306 ins
.first
->second
= vd
;
1310 // Add a reference to version NAME in file FILENAME.
1313 Versions::add_need(Stringpool
* dynpool
, const char* filename
, const char* name
,
1314 Stringpool::Key name_key
)
1316 Stringpool::Key filename_key
;
1317 filename
= dynpool
->add(filename
, true, &filename_key
);
1319 Key
k(name_key
, filename_key
);
1320 Version_base
* const vbnull
= NULL
;
1321 std::pair
<Version_table::iterator
, bool> ins
=
1322 this->version_table_
.insert(std::make_pair(k
, vbnull
));
1326 // We already have an entry for this filename/version.
1330 // See whether we already have this filename. We don't expect many
1331 // version references, so we just do a linear search. This could be
1332 // replaced by a hash table.
1334 for (Needs::iterator p
= this->needs_
.begin();
1335 p
!= this->needs_
.end();
1338 if ((*p
)->filename() == filename
)
1347 // We have a new filename.
1348 vn
= new Verneed(filename
);
1349 this->needs_
.push_back(vn
);
1352 ins
.first
->second
= vn
->add_name(name
);
1355 // Set the version indexes. Create a new dynamic version symbol for
1356 // each new version definition.
1359 Versions::finalize(const Target
* target
, Symbol_table
* symtab
,
1360 unsigned int dynsym_index
, std::vector
<Symbol
*>* syms
)
1362 gold_assert(!this->is_finalized_
);
1364 unsigned int vi
= 1;
1366 for (Defs::iterator p
= this->defs_
.begin();
1367 p
!= this->defs_
.end();
1370 (*p
)->set_index(vi
);
1373 // Create a version symbol if necessary.
1374 if (!(*p
)->is_symbol_created())
1376 Symbol
* vsym
= symtab
->define_as_constant(target
, (*p
)->name(),
1380 elfcpp::STV_DEFAULT
, 0,
1382 vsym
->set_needs_dynsym_entry();
1383 vsym
->set_dynsym_index(dynsym_index
);
1385 syms
->push_back(vsym
);
1386 // The name is already in the dynamic pool.
1390 // Index 1 is used for global symbols.
1393 gold_assert(this->defs_
.empty());
1397 for (Needs::iterator p
= this->needs_
.begin();
1398 p
!= this->needs_
.end();
1400 vi
= (*p
)->finalize(vi
);
1402 this->is_finalized_
= true;
1404 return dynsym_index
;
1407 // Return the version index to use for a symbol. This does two hash
1408 // table lookups: one in DYNPOOL and one in this->version_table_.
1409 // Another approach alternative would be store a pointer in SYM, which
1410 // would increase the size of the symbol table. Or perhaps we could
1411 // use a hash table from dynamic symbol pointer values to Version_base
1415 Versions::version_index(const Symbol_table
* symtab
, const Stringpool
* dynpool
,
1416 const Symbol
* sym
) const
1418 Stringpool::Key version_key
;
1419 const char* version
= dynpool
->find(sym
->version(), &version_key
);
1420 gold_assert(version
!= NULL
);
1423 if (!sym
->is_from_dynobj() && !sym
->is_copied_from_dynobj())
1425 if (!parameters
->output_is_shared())
1426 return elfcpp::VER_NDX_GLOBAL
;
1427 k
= Key(version_key
, 0);
1431 Dynobj
* dynobj
= this->get_dynobj_for_sym(symtab
, sym
);
1433 Stringpool::Key filename_key
;
1434 const char* filename
= dynpool
->find(dynobj
->soname(), &filename_key
);
1435 gold_assert(filename
!= NULL
);
1437 k
= Key(version_key
, filename_key
);
1440 Version_table::const_iterator p
= this->version_table_
.find(k
);
1441 gold_assert(p
!= this->version_table_
.end());
1443 return p
->second
->index();
1446 // Return an allocated buffer holding the contents of the symbol
1449 template<int size
, bool big_endian
>
1451 Versions::symbol_section_contents(const Symbol_table
* symtab
,
1452 const Stringpool
* dynpool
,
1453 unsigned int local_symcount
,
1454 const std::vector
<Symbol
*>& syms
,
1457 ACCEPT_SIZE_ENDIAN
) const
1459 gold_assert(this->is_finalized_
);
1461 unsigned int sz
= (local_symcount
+ syms
.size()) * 2;
1462 unsigned char* pbuf
= new unsigned char[sz
];
1464 for (unsigned int i
= 0; i
< local_symcount
; ++i
)
1465 elfcpp::Swap
<16, big_endian
>::writeval(pbuf
+ i
* 2,
1466 elfcpp::VER_NDX_LOCAL
);
1468 for (std::vector
<Symbol
*>::const_iterator p
= syms
.begin();
1472 unsigned int version_index
;
1473 const char* version
= (*p
)->version();
1474 if (version
== NULL
)
1475 version_index
= elfcpp::VER_NDX_GLOBAL
;
1477 version_index
= this->version_index(symtab
, dynpool
, *p
);
1478 elfcpp::Swap
<16, big_endian
>::writeval(pbuf
+ (*p
)->dynsym_index() * 2,
1486 // Return an allocated buffer holding the contents of the version
1487 // definition section.
1489 template<int size
, bool big_endian
>
1491 Versions::def_section_contents(const Stringpool
* dynpool
,
1492 unsigned char** pp
, unsigned int* psize
,
1493 unsigned int* pentries
1494 ACCEPT_SIZE_ENDIAN
) const
1496 gold_assert(this->is_finalized_
);
1497 gold_assert(!this->defs_
.empty());
1499 const int verdef_size
= elfcpp::Elf_sizes
<size
>::verdef_size
;
1500 const int verdaux_size
= elfcpp::Elf_sizes
<size
>::verdaux_size
;
1502 unsigned int sz
= 0;
1503 for (Defs::const_iterator p
= this->defs_
.begin();
1504 p
!= this->defs_
.end();
1507 sz
+= verdef_size
+ verdaux_size
;
1508 sz
+= (*p
)->count_dependencies() * verdaux_size
;
1511 unsigned char* pbuf
= new unsigned char[sz
];
1513 unsigned char* pb
= pbuf
;
1514 Defs::const_iterator p
;
1516 for (p
= this->defs_
.begin(), i
= 0;
1517 p
!= this->defs_
.end();
1519 pb
= (*p
)->write
SELECT_SIZE_ENDIAN_NAME(size
, big_endian
)(
1520 dynpool
, i
+ 1 >= this->defs_
.size(), pb
1521 SELECT_SIZE_ENDIAN(size
, big_endian
));
1523 gold_assert(static_cast<unsigned int>(pb
- pbuf
) == sz
);
1527 *pentries
= this->defs_
.size();
1530 // Return an allocated buffer holding the contents of the version
1531 // reference section.
1533 template<int size
, bool big_endian
>
1535 Versions::need_section_contents(const Stringpool
* dynpool
,
1536 unsigned char** pp
, unsigned int *psize
,
1537 unsigned int *pentries
1538 ACCEPT_SIZE_ENDIAN
) const
1540 gold_assert(this->is_finalized_
);
1541 gold_assert(!this->needs_
.empty());
1543 const int verneed_size
= elfcpp::Elf_sizes
<size
>::verneed_size
;
1544 const int vernaux_size
= elfcpp::Elf_sizes
<size
>::vernaux_size
;
1546 unsigned int sz
= 0;
1547 for (Needs::const_iterator p
= this->needs_
.begin();
1548 p
!= this->needs_
.end();
1552 sz
+= (*p
)->count_versions() * vernaux_size
;
1555 unsigned char* pbuf
= new unsigned char[sz
];
1557 unsigned char* pb
= pbuf
;
1558 Needs::const_iterator p
;
1560 for (p
= this->needs_
.begin(), i
= 0;
1561 p
!= this->needs_
.end();
1563 pb
= (*p
)->write
SELECT_SIZE_ENDIAN_NAME(size
, big_endian
)(
1564 dynpool
, i
+ 1 >= this->needs_
.size(), pb
1565 SELECT_SIZE_ENDIAN(size
, big_endian
));
1567 gold_assert(static_cast<unsigned int>(pb
- pbuf
) == sz
);
1571 *pentries
= this->needs_
.size();
1574 // Instantiate the templates we need. We could use the configure
1575 // script to restrict this to only the ones for implemented targets.
1577 #ifdef HAVE_TARGET_32_LITTLE
1579 class Sized_dynobj
<32, false>;
1582 #ifdef HAVE_TARGET_32_BIG
1584 class Sized_dynobj
<32, true>;
1587 #ifdef HAVE_TARGET_64_LITTLE
1589 class Sized_dynobj
<64, false>;
1592 #ifdef HAVE_TARGET_64_BIG
1594 class Sized_dynobj
<64, true>;
1597 #ifdef HAVE_TARGET_32_LITTLE
1600 Versions::symbol_section_contents
<32, false>(
1601 const Symbol_table
*,
1604 const std::vector
<Symbol
*>&,
1607 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1610 #ifdef HAVE_TARGET_32_BIG
1613 Versions::symbol_section_contents
<32, true>(
1614 const Symbol_table
*,
1617 const std::vector
<Symbol
*>&,
1620 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1623 #ifdef HAVE_TARGET_64_LITTLE
1626 Versions::symbol_section_contents
<64, false>(
1627 const Symbol_table
*,
1630 const std::vector
<Symbol
*>&,
1633 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1636 #ifdef HAVE_TARGET_64_BIG
1639 Versions::symbol_section_contents
<64, true>(
1640 const Symbol_table
*,
1643 const std::vector
<Symbol
*>&,
1646 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1649 #ifdef HAVE_TARGET_32_LITTLE
1652 Versions::def_section_contents
<32, false>(
1657 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1660 #ifdef HAVE_TARGET_32_BIG
1663 Versions::def_section_contents
<32, true>(
1668 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1671 #ifdef HAVE_TARGET_64_LITTLE
1674 Versions::def_section_contents
<64, false>(
1679 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1682 #ifdef HAVE_TARGET_64_BIG
1685 Versions::def_section_contents
<64, true>(
1690 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1693 #ifdef HAVE_TARGET_32_LITTLE
1696 Versions::need_section_contents
<32, false>(
1701 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1704 #ifdef HAVE_TARGET_32_BIG
1707 Versions::need_section_contents
<32, true>(
1712 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1715 #ifdef HAVE_TARGET_64_LITTLE
1718 Versions::need_section_contents
<64, false>(
1723 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1726 #ifdef HAVE_TARGET_64_BIG
1729 Versions::need_section_contents
<64, true>(
1734 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1737 } // End namespace gold.