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 // Return the string to use in a DT_NEEDED entry.
41 Dynobj::soname() const
43 if (!this->soname_
.empty())
44 return this->soname_
.c_str();
45 return this->name().c_str();
48 // Class Sized_dynobj.
50 template<int size
, bool big_endian
>
51 Sized_dynobj
<size
, big_endian
>::Sized_dynobj(
52 const std::string
& name
,
53 Input_file
* input_file
,
55 const elfcpp::Ehdr
<size
, big_endian
>& ehdr
)
56 : Dynobj(name
, input_file
, offset
),
63 template<int size
, bool big_endian
>
65 Sized_dynobj
<size
, big_endian
>::setup(
66 const elfcpp::Ehdr
<size
, big_endian
>& ehdr
)
68 this->set_target(ehdr
.get_e_machine(), size
, big_endian
,
69 ehdr
.get_e_ident()[elfcpp::EI_OSABI
],
70 ehdr
.get_e_ident()[elfcpp::EI_ABIVERSION
]);
72 const unsigned int shnum
= this->elf_file_
.shnum();
73 this->set_shnum(shnum
);
76 // Find the SHT_DYNSYM section and the various version sections, and
77 // the dynamic section, given the section headers.
79 template<int size
, bool big_endian
>
81 Sized_dynobj
<size
, big_endian
>::find_dynsym_sections(
82 const unsigned char* pshdrs
,
83 unsigned int* pdynsym_shndx
,
84 unsigned int* pversym_shndx
,
85 unsigned int* pverdef_shndx
,
86 unsigned int* pverneed_shndx
,
87 unsigned int* pdynamic_shndx
)
92 *pverneed_shndx
= -1U;
93 *pdynamic_shndx
= -1U;
95 const unsigned int shnum
= this->shnum();
96 const unsigned char* p
= pshdrs
;
97 for (unsigned int i
= 0; i
< shnum
; ++i
, p
+= This::shdr_size
)
99 typename
This::Shdr
shdr(p
);
102 switch (shdr
.get_sh_type())
104 case elfcpp::SHT_DYNSYM
:
107 case elfcpp::SHT_GNU_versym
:
110 case elfcpp::SHT_GNU_verdef
:
113 case elfcpp::SHT_GNU_verneed
:
116 case elfcpp::SHT_DYNAMIC
:
130 _("%s: %s: unexpected duplicate type %u section: %u, %u\n"),
131 program_name
, this->name().c_str(), shdr
.get_sh_type(),
140 // Read the contents of section SHNDX. PSHDRS points to the section
141 // headers. TYPE is the expected section type. LINK is the expected
142 // section link. Store the data in *VIEW and *VIEW_SIZE. The
143 // section's sh_info field is stored in *VIEW_INFO.
145 template<int size
, bool big_endian
>
147 Sized_dynobj
<size
, big_endian
>::read_dynsym_section(
148 const unsigned char* pshdrs
,
154 unsigned int* view_info
)
164 typename
This::Shdr
shdr(pshdrs
+ shndx
* This::shdr_size
);
166 gold_assert(shdr
.get_sh_type() == type
);
168 if (shdr
.get_sh_link() != link
)
171 _("%s: %s: unexpected link in section %u header: %u != %u\n"),
172 program_name
, this->name().c_str(), shndx
,
173 shdr
.get_sh_link(), link
);
177 *view
= this->get_lasting_view(shdr
.get_sh_offset(), shdr
.get_sh_size(),
179 *view_size
= shdr
.get_sh_size();
180 *view_info
= shdr
.get_sh_info();
183 // Set the soname field if this shared object has a DT_SONAME tag.
184 // PSHDRS points to the section headers. DYNAMIC_SHNDX is the section
185 // index of the SHT_DYNAMIC section. STRTAB_SHNDX, STRTAB, and
186 // STRTAB_SIZE are the section index and contents of a string table
187 // which may be the one associated with the SHT_DYNAMIC section.
189 template<int size
, bool big_endian
>
191 Sized_dynobj
<size
, big_endian
>::set_soname(const unsigned char* pshdrs
,
192 unsigned int dynamic_shndx
,
193 unsigned int strtab_shndx
,
194 const unsigned char* strtabu
,
197 typename
This::Shdr
dynamicshdr(pshdrs
+ dynamic_shndx
* This::shdr_size
);
198 gold_assert(dynamicshdr
.get_sh_type() == elfcpp::SHT_DYNAMIC
);
200 const off_t dynamic_size
= dynamicshdr
.get_sh_size();
201 const unsigned char* pdynamic
= this->get_view(dynamicshdr
.get_sh_offset(),
202 dynamic_size
, false);
204 const unsigned int link
= dynamicshdr
.get_sh_link();
205 if (link
!= strtab_shndx
)
207 if (link
>= this->shnum())
210 _("%s: %s: DYNAMIC section %u link out of range: %u\n"),
211 program_name
, this->name().c_str(),
212 dynamic_shndx
, link
);
216 typename
This::Shdr
strtabshdr(pshdrs
+ link
* This::shdr_size
);
217 if (strtabshdr
.get_sh_type() != elfcpp::SHT_STRTAB
)
220 _("%s: %s: DYNAMIC section %u link %u is not a strtab\n"),
221 program_name
, this->name().c_str(),
222 dynamic_shndx
, link
);
226 strtab_size
= strtabshdr
.get_sh_size();
227 strtabu
= this->get_view(strtabshdr
.get_sh_offset(), strtab_size
, false);
230 for (const unsigned char* p
= pdynamic
;
231 p
< pdynamic
+ dynamic_size
;
234 typename
This::Dyn
dyn(p
);
236 if (dyn
.get_d_tag() == elfcpp::DT_SONAME
)
238 off_t val
= dyn
.get_d_val();
239 if (val
>= strtab_size
)
242 _("%s: %s: DT_SONAME value out of range: "
244 program_name
, this->name().c_str(),
245 static_cast<long long>(val
),
246 static_cast<long long>(strtab_size
));
250 const char* strtab
= reinterpret_cast<const char*>(strtabu
);
251 this->set_soname_string(strtab
+ val
);
255 if (dyn
.get_d_tag() == elfcpp::DT_NULL
)
259 fprintf(stderr
, _("%s: %s: missing DT_NULL in dynamic segment\n"),
260 program_name
, this->name().c_str());
264 // Read the symbols and sections from a dynamic object. We read the
265 // dynamic symbols, not the normal symbols.
267 template<int size
, bool big_endian
>
269 Sized_dynobj
<size
, big_endian
>::do_read_symbols(Read_symbols_data
* sd
)
271 this->read_section_data(&this->elf_file_
, sd
);
273 const unsigned char* const pshdrs
= sd
->section_headers
->data();
275 unsigned int dynsym_shndx
;
276 unsigned int versym_shndx
;
277 unsigned int verdef_shndx
;
278 unsigned int verneed_shndx
;
279 unsigned int dynamic_shndx
;
280 this->find_dynsym_sections(pshdrs
, &dynsym_shndx
, &versym_shndx
,
281 &verdef_shndx
, &verneed_shndx
, &dynamic_shndx
);
283 unsigned int strtab_shndx
= -1U;
285 if (dynsym_shndx
== -1U)
288 sd
->symbols_size
= 0;
289 sd
->symbol_names
= NULL
;
290 sd
->symbol_names_size
= 0;
294 // Get the dynamic symbols.
295 typename
This::Shdr
dynsymshdr(pshdrs
+ dynsym_shndx
* This::shdr_size
);
296 gold_assert(dynsymshdr
.get_sh_type() == elfcpp::SHT_DYNSYM
);
298 sd
->symbols
= this->get_lasting_view(dynsymshdr
.get_sh_offset(),
299 dynsymshdr
.get_sh_size(), false);
300 sd
->symbols_size
= dynsymshdr
.get_sh_size();
302 // Get the symbol names.
303 strtab_shndx
= dynsymshdr
.get_sh_link();
304 if (strtab_shndx
>= this->shnum())
307 _("%s: %s: invalid dynamic symbol table name index: %u\n"),
308 program_name
, this->name().c_str(), strtab_shndx
);
311 typename
This::Shdr
strtabshdr(pshdrs
+ strtab_shndx
* This::shdr_size
);
312 if (strtabshdr
.get_sh_type() != elfcpp::SHT_STRTAB
)
315 _("%s: %s: dynamic symbol table name section "
316 "has wrong type: %u\n"),
317 program_name
, this->name().c_str(),
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
)
390 _("%s: %s: bad section name offset for section %u: %lu\n"),
391 program_name
, this->name().c_str(), i
,
392 static_cast<unsigned long>(shdr
.get_sh_name()));
396 const char* name
= pnames
+ shdr
.get_sh_name();
398 this->handle_gnu_warning_section(name
, i
, symtab
);
401 delete sd
->section_headers
;
402 sd
->section_headers
= NULL
;
403 delete sd
->section_names
;
404 sd
->section_names
= NULL
;
407 // Add an entry to the vector mapping version numbers to version
410 template<int size
, bool big_endian
>
412 Sized_dynobj
<size
, big_endian
>::set_version_map(
413 Version_map
* version_map
,
415 const char* name
) const
417 if (ndx
>= version_map
->size())
418 version_map
->resize(ndx
+ 1);
419 if ((*version_map
)[ndx
] != NULL
)
421 fprintf(stderr
, _("%s: %s: duplicate definition for version %u\n"),
422 program_name
, this->name().c_str(), ndx
);
425 (*version_map
)[ndx
] = name
;
428 // Add mappings for the version definitions to VERSION_MAP.
430 template<int size
, bool big_endian
>
432 Sized_dynobj
<size
, big_endian
>::make_verdef_map(
433 Read_symbols_data
* sd
,
434 Version_map
* version_map
) const
436 if (sd
->verdef
== NULL
)
439 const char* names
= reinterpret_cast<const char*>(sd
->symbol_names
->data());
440 off_t names_size
= sd
->symbol_names_size
;
442 const unsigned char* pverdef
= sd
->verdef
->data();
443 off_t verdef_size
= sd
->verdef_size
;
444 const unsigned int count
= sd
->verdef_info
;
446 const unsigned char* p
= pverdef
;
447 for (unsigned int i
= 0; i
< count
; ++i
)
449 elfcpp::Verdef
<size
, big_endian
> verdef(p
);
451 if (verdef
.get_vd_version() != elfcpp::VER_DEF_CURRENT
)
453 fprintf(stderr
, _("%s: %s: unexpected verdef version %u\n"),
454 program_name
, this->name().c_str(), verdef
.get_vd_version());
458 const unsigned int vd_ndx
= verdef
.get_vd_ndx();
460 // The GNU linker clears the VERSYM_HIDDEN bit. I'm not
463 // The first Verdaux holds the name of this version. Subsequent
464 // ones are versions that this one depends upon, which we don't
466 const unsigned int vd_cnt
= verdef
.get_vd_cnt();
469 fprintf(stderr
, _("%s: %s: verdef vd_cnt field too small: %u\n"),
470 program_name
, this->name().c_str(), vd_cnt
);
474 const unsigned int vd_aux
= verdef
.get_vd_aux();
475 if ((p
- pverdef
) + vd_aux
>= verdef_size
)
478 _("%s: %s: verdef vd_aux field out of range: %u\n"),
479 program_name
, this->name().c_str(), vd_aux
);
483 const unsigned char* pvda
= p
+ vd_aux
;
484 elfcpp::Verdaux
<size
, big_endian
> verdaux(pvda
);
486 const unsigned int vda_name
= verdaux
.get_vda_name();
487 if (vda_name
>= names_size
)
490 _("%s: %s: verdaux vda_name field out of range: %u\n"),
491 program_name
, this->name().c_str(), vda_name
);
495 this->set_version_map(version_map
, vd_ndx
, names
+ vda_name
);
497 const unsigned int vd_next
= verdef
.get_vd_next();
498 if ((p
- pverdef
) + vd_next
>= verdef_size
)
501 _("%s: %s: verdef vd_next field out of range: %u\n"),
502 program_name
, this->name().c_str(), vd_next
);
510 // Add mappings for the required versions to VERSION_MAP.
512 template<int size
, bool big_endian
>
514 Sized_dynobj
<size
, big_endian
>::make_verneed_map(
515 Read_symbols_data
* sd
,
516 Version_map
* version_map
) const
518 if (sd
->verneed
== NULL
)
521 const char* names
= reinterpret_cast<const char*>(sd
->symbol_names
->data());
522 off_t names_size
= sd
->symbol_names_size
;
524 const unsigned char* pverneed
= sd
->verneed
->data();
525 const off_t verneed_size
= sd
->verneed_size
;
526 const unsigned int count
= sd
->verneed_info
;
528 const unsigned char* p
= pverneed
;
529 for (unsigned int i
= 0; i
< count
; ++i
)
531 elfcpp::Verneed
<size
, big_endian
> verneed(p
);
533 if (verneed
.get_vn_version() != elfcpp::VER_NEED_CURRENT
)
535 fprintf(stderr
, _("%s: %s: unexpected verneed version %u\n"),
536 program_name
, this->name().c_str(),
537 verneed
.get_vn_version());
541 const unsigned int vn_aux
= verneed
.get_vn_aux();
543 if ((p
- pverneed
) + vn_aux
>= verneed_size
)
546 _("%s: %s: verneed vn_aux field out of range: %u\n"),
547 program_name
, this->name().c_str(), vn_aux
);
551 const unsigned int vn_cnt
= verneed
.get_vn_cnt();
552 const unsigned char* pvna
= p
+ vn_aux
;
553 for (unsigned int j
= 0; j
< vn_cnt
; ++j
)
555 elfcpp::Vernaux
<size
, big_endian
> vernaux(pvna
);
557 const unsigned int vna_name
= vernaux
.get_vna_name();
558 if (vna_name
>= names_size
)
561 _("%s: %s: vernaux vna_name field "
562 "out of range: %u\n"),
563 program_name
, this->name().c_str(), vna_name
);
567 this->set_version_map(version_map
, vernaux
.get_vna_other(),
570 const unsigned int vna_next
= vernaux
.get_vna_next();
571 if ((pvna
- pverneed
) + vna_next
>= verneed_size
)
574 _("%s: %s: verneed vna_next field "
575 "out of range: %u\n"),
576 program_name
, this->name().c_str(), vna_next
);
583 const unsigned int vn_next
= verneed
.get_vn_next();
584 if ((p
- pverneed
) + vn_next
>= verneed_size
)
587 _("%s: %s: verneed vn_next field out of range: %u\n"),
588 program_name
, this->name().c_str(), vn_next
);
596 // Create a vector mapping version numbers to version strings.
598 template<int size
, bool big_endian
>
600 Sized_dynobj
<size
, big_endian
>::make_version_map(
601 Read_symbols_data
* sd
,
602 Version_map
* version_map
) const
604 if (sd
->verdef
== NULL
&& sd
->verneed
== NULL
)
607 // A guess at the maximum version number we will see. If this is
608 // wrong we will be less efficient but still correct.
609 version_map
->reserve(sd
->verdef_info
+ sd
->verneed_info
* 10);
611 this->make_verdef_map(sd
, version_map
);
612 this->make_verneed_map(sd
, version_map
);
615 // Add the dynamic symbols to the symbol table.
617 template<int size
, bool big_endian
>
619 Sized_dynobj
<size
, big_endian
>::do_add_symbols(Symbol_table
* symtab
,
620 Read_symbols_data
* sd
)
622 if (sd
->symbols
== NULL
)
624 gold_assert(sd
->symbol_names
== NULL
);
625 gold_assert(sd
->versym
== NULL
&& sd
->verdef
== NULL
626 && sd
->verneed
== NULL
);
630 const int sym_size
= This::sym_size
;
631 const size_t symcount
= sd
->symbols_size
/ sym_size
;
632 if (static_cast<off_t
>(symcount
* sym_size
) != sd
->symbols_size
)
635 _("%s: %s: size of dynamic symbols is not "
636 "multiple of symbol size\n"),
637 program_name
, this->name().c_str());
641 Version_map version_map
;
642 this->make_version_map(sd
, &version_map
);
644 const char* sym_names
=
645 reinterpret_cast<const char*>(sd
->symbol_names
->data());
646 symtab
->add_from_dynobj(this, sd
->symbols
->data(), symcount
,
647 sym_names
, sd
->symbol_names_size
,
650 : sd
->versym
->data()),
656 delete sd
->symbol_names
;
657 sd
->symbol_names
= NULL
;
658 if (sd
->versym
!= NULL
)
663 if (sd
->verdef
!= NULL
)
668 if (sd
->verneed
!= NULL
)
675 // Given a vector of hash codes, compute the number of hash buckets to
679 Dynobj::compute_bucket_count(const std::vector
<uint32_t>& hashcodes
,
680 bool for_gnu_hash_table
)
682 // FIXME: Implement optional hash table optimization.
684 // Array used to determine the number of hash table buckets to use
685 // based on the number of symbols there are. If there are fewer
686 // than 3 symbols we use 1 bucket, fewer than 17 symbols we use 3
687 // buckets, fewer than 37 we use 17 buckets, and so forth. We never
688 // use more than 32771 buckets. This is straight from the old GNU
690 static const unsigned int buckets
[] =
692 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209,
695 const int buckets_count
= sizeof buckets
/ sizeof buckets
[0];
697 unsigned int symcount
= hashcodes
.size();
698 unsigned int ret
= 1;
699 for (int i
= 0; i
< buckets_count
; ++i
)
701 if (symcount
< buckets
[i
])
706 if (for_gnu_hash_table
&& ret
< 2)
712 // The standard ELF hash function. This hash function must not
713 // change, as the dynamic linker uses it also.
716 Dynobj::elf_hash(const char* name
)
718 const unsigned char* nameu
= reinterpret_cast<const unsigned char*>(name
);
721 while ((c
= *nameu
++) != '\0')
724 uint32_t g
= h
& 0xf0000000;
728 // The ELF ABI says h &= ~g, but using xor is equivalent in
729 // this case (since g was set from h) and may save one
737 // Create a standard ELF hash table, setting *PPHASH and *PHASHLEN.
738 // DYNSYMS is a vector with all the global dynamic symbols.
739 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
743 Dynobj::create_elf_hash_table(const std::vector
<Symbol
*>& dynsyms
,
744 unsigned int local_dynsym_count
,
745 unsigned char** pphash
,
746 unsigned int* phashlen
)
748 unsigned int dynsym_count
= dynsyms
.size();
750 // Get the hash values for all the symbols.
751 std::vector
<uint32_t> dynsym_hashvals(dynsym_count
);
752 for (unsigned int i
= 0; i
< dynsym_count
; ++i
)
753 dynsym_hashvals
[i
] = Dynobj::elf_hash(dynsyms
[i
]->name());
755 const unsigned int bucketcount
=
756 Dynobj::compute_bucket_count(dynsym_hashvals
, false);
758 std::vector
<uint32_t> bucket(bucketcount
);
759 std::vector
<uint32_t> chain(local_dynsym_count
+ dynsym_count
);
761 for (unsigned int i
= 0; i
< dynsym_count
; ++i
)
763 unsigned int dynsym_index
= dynsyms
[i
]->dynsym_index();
764 unsigned int bucketpos
= dynsym_hashvals
[i
] % bucketcount
;
765 chain
[dynsym_index
] = bucket
[bucketpos
];
766 bucket
[bucketpos
] = dynsym_index
;
769 unsigned int hashlen
= ((2
774 unsigned char* phash
= new unsigned char[hashlen
];
776 if (parameters
->is_big_endian())
778 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
779 Dynobj::sized_create_elf_hash_table
<true>(bucket
, chain
, phash
,
787 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
788 Dynobj::sized_create_elf_hash_table
<false>(bucket
, chain
, phash
,
799 // Fill in an ELF hash table.
801 template<bool big_endian
>
803 Dynobj::sized_create_elf_hash_table(const std::vector
<uint32_t>& bucket
,
804 const std::vector
<uint32_t>& chain
,
805 unsigned char* phash
,
806 unsigned int hashlen
)
808 unsigned char* p
= phash
;
810 const unsigned int bucketcount
= bucket
.size();
811 const unsigned int chaincount
= chain
.size();
813 elfcpp::Swap
<32, big_endian
>::writeval(p
, bucketcount
);
815 elfcpp::Swap
<32, big_endian
>::writeval(p
, chaincount
);
818 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
820 elfcpp::Swap
<32, big_endian
>::writeval(p
, bucket
[i
]);
824 for (unsigned int i
= 0; i
< chaincount
; ++i
)
826 elfcpp::Swap
<32, big_endian
>::writeval(p
, chain
[i
]);
830 gold_assert(static_cast<unsigned int>(p
- phash
) == hashlen
);
833 // The hash function used for the GNU hash table. This hash function
834 // must not change, as the dynamic linker uses it also.
837 Dynobj::gnu_hash(const char* name
)
839 const unsigned char* nameu
= reinterpret_cast<const unsigned char*>(name
);
842 while ((c
= *nameu
++) != '\0')
843 h
= (h
<< 5) + h
+ c
;
847 // Create a GNU hash table, setting *PPHASH and *PHASHLEN. GNU hash
848 // tables are an extension to ELF which are recognized by the GNU
849 // dynamic linker. They are referenced using dynamic tag DT_GNU_HASH.
850 // TARGET is the target. DYNSYMS is a vector with all the global
851 // symbols which will be going into the dynamic symbol table.
852 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
856 Dynobj::create_gnu_hash_table(const std::vector
<Symbol
*>& dynsyms
,
857 unsigned int local_dynsym_count
,
858 unsigned char** pphash
,
859 unsigned int* phashlen
)
861 const unsigned int count
= dynsyms
.size();
863 // Sort the dynamic symbols into two vectors. Symbols which we do
864 // not want to put into the hash table we store into
865 // UNHASHED_DYNSYMS. Symbols which we do want to store we put into
866 // HASHED_DYNSYMS. DYNSYM_HASHVALS is parallel to HASHED_DYNSYMS,
867 // and records the hash codes.
869 std::vector
<Symbol
*> unhashed_dynsyms
;
870 unhashed_dynsyms
.reserve(count
);
872 std::vector
<Symbol
*> hashed_dynsyms
;
873 hashed_dynsyms
.reserve(count
);
875 std::vector
<uint32_t> dynsym_hashvals
;
876 dynsym_hashvals
.reserve(count
);
878 for (unsigned int i
= 0; i
< count
; ++i
)
880 Symbol
* sym
= dynsyms
[i
];
882 // FIXME: Should put on unhashed_dynsyms if the symbol is
884 if (sym
->is_undefined())
885 unhashed_dynsyms
.push_back(sym
);
888 hashed_dynsyms
.push_back(sym
);
889 dynsym_hashvals
.push_back(Dynobj::gnu_hash(sym
->name()));
893 // Put the unhashed symbols at the start of the global portion of
894 // the dynamic symbol table.
895 const unsigned int unhashed_count
= unhashed_dynsyms
.size();
896 unsigned int unhashed_dynsym_index
= local_dynsym_count
;
897 for (unsigned int i
= 0; i
< unhashed_count
; ++i
)
899 unhashed_dynsyms
[i
]->set_dynsym_index(unhashed_dynsym_index
);
900 ++unhashed_dynsym_index
;
903 // For the actual data generation we call out to a templatized
905 int size
= parameters
->get_size();
906 bool big_endian
= parameters
->is_big_endian();
911 #ifdef HAVE_TARGET_32_BIG
912 Dynobj::sized_create_gnu_hash_table
<32, true>(hashed_dynsyms
,
914 unhashed_dynsym_index
,
923 #ifdef HAVE_TARGET_32_LITTLE
924 Dynobj::sized_create_gnu_hash_table
<32, false>(hashed_dynsyms
,
926 unhashed_dynsym_index
,
938 #ifdef HAVE_TARGET_64_BIG
939 Dynobj::sized_create_gnu_hash_table
<64, true>(hashed_dynsyms
,
941 unhashed_dynsym_index
,
950 #ifdef HAVE_TARGET_64_LITTLE
951 Dynobj::sized_create_gnu_hash_table
<64, false>(hashed_dynsyms
,
953 unhashed_dynsym_index
,
965 // Create the actual data for a GNU hash table. This is just a copy
966 // of the code from the old GNU linker.
968 template<int size
, bool big_endian
>
970 Dynobj::sized_create_gnu_hash_table(
971 const std::vector
<Symbol
*>& hashed_dynsyms
,
972 const std::vector
<uint32_t>& dynsym_hashvals
,
973 unsigned int unhashed_dynsym_count
,
974 unsigned char** pphash
,
975 unsigned int* phashlen
)
977 if (hashed_dynsyms
.empty())
979 // Special case for the empty hash table.
980 unsigned int hashlen
= 5 * 4 + size
/ 8;
981 unsigned char* phash
= new unsigned char[hashlen
];
983 elfcpp::Swap
<32, big_endian
>::writeval(phash
, 1);
984 // Symbol index above unhashed symbols.
985 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 4, unhashed_dynsym_count
);
986 // One word for bitmask.
987 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 8, 1);
988 // Only bloom filter.
989 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 12, 0);
991 elfcpp::Swap
<size
, big_endian
>::writeval(phash
+ 16, 0);
992 // No hashes in only bucket.
993 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 16 + size
/ 8, 0);
1001 const unsigned int bucketcount
=
1002 Dynobj::compute_bucket_count(dynsym_hashvals
, true);
1004 const unsigned int nsyms
= hashed_dynsyms
.size();
1006 uint32_t maskbitslog2
= 1;
1007 uint32_t x
= nsyms
>> 1;
1013 if (maskbitslog2
< 3)
1015 else if (((1U << (maskbitslog2
- 2)) & nsyms
) != 0)
1025 if (maskbitslog2
== 5)
1029 uint32_t mask
= (1U << shift1
) - 1U;
1030 uint32_t shift2
= maskbitslog2
;
1031 uint32_t maskbits
= 1U << maskbitslog2
;
1032 uint32_t maskwords
= 1U << (maskbitslog2
- shift1
);
1034 typedef typename
elfcpp::Elf_types
<size
>::Elf_WXword Word
;
1035 std::vector
<Word
> bitmask(maskwords
);
1036 std::vector
<uint32_t> counts(bucketcount
);
1037 std::vector
<uint32_t> indx(bucketcount
);
1038 uint32_t symindx
= unhashed_dynsym_count
;
1040 // Count the number of times each hash bucket is used.
1041 for (unsigned int i
= 0; i
< nsyms
; ++i
)
1042 ++counts
[dynsym_hashvals
[i
] % bucketcount
];
1044 unsigned int cnt
= symindx
;
1045 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
1051 unsigned int hashlen
= (4 + bucketcount
+ nsyms
) * 4;
1052 hashlen
+= maskbits
/ 8;
1053 unsigned char* phash
= new unsigned char[hashlen
];
1055 elfcpp::Swap
<32, big_endian
>::writeval(phash
, bucketcount
);
1056 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 4, symindx
);
1057 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 8, maskwords
);
1058 elfcpp::Swap
<32, big_endian
>::writeval(phash
+ 12, shift2
);
1060 unsigned char* p
= phash
+ 16 + maskbits
/ 8;
1061 for (unsigned int i
= 0; i
< bucketcount
; ++i
)
1064 elfcpp::Swap
<32, big_endian
>::writeval(p
, 0);
1066 elfcpp::Swap
<32, big_endian
>::writeval(p
, indx
[i
]);
1070 for (unsigned int i
= 0; i
< nsyms
; ++i
)
1072 Symbol
* sym
= hashed_dynsyms
[i
];
1073 uint32_t hashval
= dynsym_hashvals
[i
];
1075 unsigned int bucket
= hashval
% bucketcount
;
1076 unsigned int val
= ((hashval
>> shift1
)
1077 & ((maskbits
>> shift1
) - 1));
1078 bitmask
[val
] |= (static_cast<Word
>(1U)) << (hashval
& mask
);
1079 bitmask
[val
] |= (static_cast<Word
>(1U)) << ((hashval
>> shift2
) & mask
);
1080 val
= hashval
& ~ 1U;
1081 if (counts
[bucket
] == 1)
1083 // Last element terminates the chain.
1086 elfcpp::Swap
<32, big_endian
>::writeval(p
+ (indx
[bucket
] - symindx
) * 4,
1090 sym
->set_dynsym_index(indx
[bucket
]);
1095 for (unsigned int i
= 0; i
< maskwords
; ++i
)
1097 elfcpp::Swap
<size
, big_endian
>::writeval(p
, bitmask
[i
]);
1101 *phashlen
= hashlen
;
1107 // Write this definition to a buffer for the output section.
1109 template<int size
, bool big_endian
>
1111 Verdef::write(const Stringpool
* dynpool
, bool is_last
, unsigned char* pb
1112 ACCEPT_SIZE_ENDIAN
) const
1114 const int verdef_size
= elfcpp::Elf_sizes
<size
>::verdef_size
;
1115 const int verdaux_size
= elfcpp::Elf_sizes
<size
>::verdaux_size
;
1117 elfcpp::Verdef_write
<size
, big_endian
> vd(pb
);
1118 vd
.set_vd_version(elfcpp::VER_DEF_CURRENT
);
1119 vd
.set_vd_flags((this->is_base_
? elfcpp::VER_FLG_BASE
: 0)
1120 | (this->is_weak_
? elfcpp::VER_FLG_WEAK
: 0));
1121 vd
.set_vd_ndx(this->index());
1122 vd
.set_vd_cnt(1 + this->deps_
.size());
1123 vd
.set_vd_hash(Dynobj::elf_hash(this->name()));
1124 vd
.set_vd_aux(verdef_size
);
1125 vd
.set_vd_next(is_last
1127 : verdef_size
+ (1 + this->deps_
.size()) * verdaux_size
);
1130 elfcpp::Verdaux_write
<size
, big_endian
> vda(pb
);
1131 vda
.set_vda_name(dynpool
->get_offset(this->name()));
1132 vda
.set_vda_next(this->deps_
.empty() ? 0 : verdaux_size
);
1135 Deps::const_iterator p
;
1137 for (p
= this->deps_
.begin(), i
= 0;
1138 p
!= this->deps_
.end();
1141 elfcpp::Verdaux_write
<size
, big_endian
> vda(pb
);
1142 vda
.set_vda_name(dynpool
->get_offset(*p
));
1143 vda
.set_vda_next(i
+ 1 >= this->deps_
.size() ? 0 : verdaux_size
);
1154 for (Need_versions::iterator p
= this->need_versions_
.begin();
1155 p
!= this->need_versions_
.end();
1160 // Add a new version to this file reference.
1163 Verneed::add_name(const char* name
)
1165 Verneed_version
* vv
= new Verneed_version(name
);
1166 this->need_versions_
.push_back(vv
);
1170 // Set the version indexes starting at INDEX.
1173 Verneed::finalize(unsigned int index
)
1175 for (Need_versions::iterator p
= this->need_versions_
.begin();
1176 p
!= this->need_versions_
.end();
1179 (*p
)->set_index(index
);
1185 // Write this list of referenced versions to a buffer for the output
1188 template<int size
, bool big_endian
>
1190 Verneed::write(const Stringpool
* dynpool
, bool is_last
,
1191 unsigned char* pb ACCEPT_SIZE_ENDIAN
) const
1193 const int verneed_size
= elfcpp::Elf_sizes
<size
>::verneed_size
;
1194 const int vernaux_size
= elfcpp::Elf_sizes
<size
>::vernaux_size
;
1196 elfcpp::Verneed_write
<size
, big_endian
> vn(pb
);
1197 vn
.set_vn_version(elfcpp::VER_NEED_CURRENT
);
1198 vn
.set_vn_cnt(this->need_versions_
.size());
1199 vn
.set_vn_file(dynpool
->get_offset(this->filename()));
1200 vn
.set_vn_aux(verneed_size
);
1201 vn
.set_vn_next(is_last
1203 : verneed_size
+ this->need_versions_
.size() * vernaux_size
);
1206 Need_versions::const_iterator p
;
1208 for (p
= this->need_versions_
.begin(), i
= 0;
1209 p
!= this->need_versions_
.end();
1212 elfcpp::Vernaux_write
<size
, big_endian
> vna(pb
);
1213 vna
.set_vna_hash(Dynobj::elf_hash((*p
)->version()));
1214 // FIXME: We need to sometimes set VER_FLG_WEAK here.
1215 vna
.set_vna_flags(0);
1216 vna
.set_vna_other((*p
)->index());
1217 vna
.set_vna_name(dynpool
->get_offset((*p
)->version()));
1218 vna
.set_vna_next(i
+ 1 >= this->need_versions_
.size()
1227 // Versions methods.
1229 Versions::~Versions()
1231 for (Defs::iterator p
= this->defs_
.begin();
1232 p
!= this->defs_
.end();
1236 for (Needs::iterator p
= this->needs_
.begin();
1237 p
!= this->needs_
.end();
1242 // Record version information for a symbol going into the dynamic
1246 Versions::record_version(const General_options
* options
,
1247 Stringpool
* dynpool
, const Symbol
* sym
)
1249 gold_assert(!this->is_finalized_
);
1250 gold_assert(sym
->version() != NULL
);
1252 Stringpool::Key version_key
;
1253 const char* version
= dynpool
->add(sym
->version(), &version_key
);
1255 if (!sym
->is_from_dynobj())
1257 if (parameters
->output_is_shared())
1258 this->add_def(options
, sym
, version
, version_key
);
1262 // This is a version reference.
1264 Object
* object
= sym
->object();
1265 gold_assert(object
->is_dynamic());
1266 Dynobj
* dynobj
= static_cast<Dynobj
*>(object
);
1268 this->add_need(dynpool
, dynobj
->soname(), version
, version_key
);
1272 // We've found a symbol SYM defined in version VERSION.
1275 Versions::add_def(const General_options
* options
, const Symbol
* sym
,
1276 const char* version
, Stringpool::Key version_key
)
1278 Key
k(version_key
, 0);
1279 Version_base
* const vbnull
= NULL
;
1280 std::pair
<Version_table::iterator
, bool> ins
=
1281 this->version_table_
.insert(std::make_pair(k
, vbnull
));
1285 // We already have an entry for this version.
1286 Version_base
* vb
= ins
.first
->second
;
1288 // We have now seen a symbol in this version, so it is not
1292 // FIXME: When we support version scripts, we will need to
1293 // check whether this symbol should be forced local.
1297 // If we are creating a shared object, it is an error to
1298 // find a definition of a symbol with a version which is not
1299 // in the version script.
1300 if (parameters
->output_is_shared())
1302 fprintf(stderr
, _("%s: symbol %s has undefined version %s\n"),
1303 program_name
, sym
->name(), version
);
1307 // If this is the first version we are defining, first define
1308 // the base version. FIXME: Should use soname here when
1309 // creating a shared object.
1310 Verdef
* vdbase
= new Verdef(options
->output_file_name(), true, false,
1312 this->defs_
.push_back(vdbase
);
1314 // When creating a regular executable, automatically define
1316 Verdef
* vd
= new Verdef(version
, false, false, false);
1317 this->defs_
.push_back(vd
);
1318 ins
.first
->second
= vd
;
1322 // Add a reference to version NAME in file FILENAME.
1325 Versions::add_need(Stringpool
* dynpool
, const char* filename
, const char* name
,
1326 Stringpool::Key name_key
)
1328 Stringpool::Key filename_key
;
1329 filename
= dynpool
->add(filename
, &filename_key
);
1331 Key
k(name_key
, filename_key
);
1332 Version_base
* const vbnull
= NULL
;
1333 std::pair
<Version_table::iterator
, bool> ins
=
1334 this->version_table_
.insert(std::make_pair(k
, vbnull
));
1338 // We already have an entry for this filename/version.
1342 // See whether we already have this filename. We don't expect many
1343 // version references, so we just do a linear search. This could be
1344 // replaced by a hash table.
1346 for (Needs::iterator p
= this->needs_
.begin();
1347 p
!= this->needs_
.end();
1350 if ((*p
)->filename() == filename
)
1359 // We have a new filename.
1360 vn
= new Verneed(filename
);
1361 this->needs_
.push_back(vn
);
1364 ins
.first
->second
= vn
->add_name(name
);
1367 // Set the version indexes. Create a new dynamic version symbol for
1368 // each new version definition.
1371 Versions::finalize(const Target
* target
, Symbol_table
* symtab
,
1372 unsigned int dynsym_index
, std::vector
<Symbol
*>* syms
)
1374 gold_assert(!this->is_finalized_
);
1376 unsigned int vi
= 1;
1378 for (Defs::iterator p
= this->defs_
.begin();
1379 p
!= this->defs_
.end();
1382 (*p
)->set_index(vi
);
1385 // Create a version symbol if necessary.
1386 if (!(*p
)->is_symbol_created())
1388 Symbol
* vsym
= symtab
->define_as_constant(target
, (*p
)->name(),
1392 elfcpp::STV_DEFAULT
, 0,
1394 vsym
->set_needs_dynsym_entry();
1395 vsym
->set_dynsym_index(dynsym_index
);
1397 syms
->push_back(vsym
);
1398 // The name is already in the dynamic pool.
1402 // Index 1 is used for global symbols.
1405 gold_assert(this->defs_
.empty());
1409 for (Needs::iterator p
= this->needs_
.begin();
1410 p
!= this->needs_
.end();
1412 vi
= (*p
)->finalize(vi
);
1414 this->is_finalized_
= true;
1416 return dynsym_index
;
1419 // Return the version index to use for a symbol. This does two hash
1420 // table lookups: one in DYNPOOL and one in this->version_table_.
1421 // Another approach alternative would be store a pointer in SYM, which
1422 // would increase the size of the symbol table. Or perhaps we could
1423 // use a hash table from dynamic symbol pointer values to Version_base
1427 Versions::version_index(const Stringpool
* dynpool
, const Symbol
* sym
) const
1429 Stringpool::Key version_key
;
1430 const char* version
= dynpool
->find(sym
->version(), &version_key
);
1431 gold_assert(version
!= NULL
);
1434 if (!sym
->is_from_dynobj())
1436 if (!parameters
->output_is_shared())
1437 return elfcpp::VER_NDX_GLOBAL
;
1438 k
= Key(version_key
, 0);
1442 Object
* object
= sym
->object();
1443 gold_assert(object
->is_dynamic());
1444 Dynobj
* dynobj
= static_cast<Dynobj
*>(object
);
1446 Stringpool::Key filename_key
;
1447 const char* filename
= dynpool
->find(dynobj
->soname(), &filename_key
);
1448 gold_assert(filename
!= NULL
);
1450 k
= Key(version_key
, filename_key
);
1453 Version_table::const_iterator p
= this->version_table_
.find(k
);
1454 gold_assert(p
!= this->version_table_
.end());
1456 return p
->second
->index();
1459 // Return an allocated buffer holding the contents of the symbol
1462 template<int size
, bool big_endian
>
1464 Versions::symbol_section_contents(const Stringpool
* dynpool
,
1465 unsigned int local_symcount
,
1466 const std::vector
<Symbol
*>& syms
,
1469 ACCEPT_SIZE_ENDIAN
) const
1471 gold_assert(this->is_finalized_
);
1473 unsigned int sz
= (local_symcount
+ syms
.size()) * 2;
1474 unsigned char* pbuf
= new unsigned char[sz
];
1476 for (unsigned int i
= 0; i
< local_symcount
; ++i
)
1477 elfcpp::Swap
<16, big_endian
>::writeval(pbuf
+ i
* 2,
1478 elfcpp::VER_NDX_LOCAL
);
1480 for (std::vector
<Symbol
*>::const_iterator p
= syms
.begin();
1484 unsigned int version_index
;
1485 const char* version
= (*p
)->version();
1486 if (version
== NULL
)
1487 version_index
= elfcpp::VER_NDX_GLOBAL
;
1489 version_index
= this->version_index(dynpool
, *p
);
1490 elfcpp::Swap
<16, big_endian
>::writeval(pbuf
+ (*p
)->dynsym_index() * 2,
1498 // Return an allocated buffer holding the contents of the version
1499 // definition section.
1501 template<int size
, bool big_endian
>
1503 Versions::def_section_contents(const Stringpool
* dynpool
,
1504 unsigned char** pp
, unsigned int* psize
,
1505 unsigned int* pentries
1506 ACCEPT_SIZE_ENDIAN
) const
1508 gold_assert(this->is_finalized_
);
1509 gold_assert(!this->defs_
.empty());
1511 const int verdef_size
= elfcpp::Elf_sizes
<size
>::verdef_size
;
1512 const int verdaux_size
= elfcpp::Elf_sizes
<size
>::verdaux_size
;
1514 unsigned int sz
= 0;
1515 for (Defs::const_iterator p
= this->defs_
.begin();
1516 p
!= this->defs_
.end();
1519 sz
+= verdef_size
+ verdaux_size
;
1520 sz
+= (*p
)->count_dependencies() * verdaux_size
;
1523 unsigned char* pbuf
= new unsigned char[sz
];
1525 unsigned char* pb
= pbuf
;
1526 Defs::const_iterator p
;
1528 for (p
= this->defs_
.begin(), i
= 0;
1529 p
!= this->defs_
.end();
1531 pb
= (*p
)->write
SELECT_SIZE_ENDIAN_NAME(size
, big_endian
)(
1532 dynpool
, i
+ 1 >= this->defs_
.size(), pb
1533 SELECT_SIZE_ENDIAN(size
, big_endian
));
1535 gold_assert(static_cast<unsigned int>(pb
- pbuf
) == sz
);
1539 *pentries
= this->defs_
.size();
1542 // Return an allocated buffer holding the contents of the version
1543 // reference section.
1545 template<int size
, bool big_endian
>
1547 Versions::need_section_contents(const Stringpool
* dynpool
,
1548 unsigned char** pp
, unsigned int *psize
,
1549 unsigned int *pentries
1550 ACCEPT_SIZE_ENDIAN
) const
1552 gold_assert(this->is_finalized_
);
1553 gold_assert(!this->needs_
.empty());
1555 const int verneed_size
= elfcpp::Elf_sizes
<size
>::verneed_size
;
1556 const int vernaux_size
= elfcpp::Elf_sizes
<size
>::vernaux_size
;
1558 unsigned int sz
= 0;
1559 for (Needs::const_iterator p
= this->needs_
.begin();
1560 p
!= this->needs_
.end();
1564 sz
+= (*p
)->count_versions() * vernaux_size
;
1567 unsigned char* pbuf
= new unsigned char[sz
];
1569 unsigned char* pb
= pbuf
;
1570 Needs::const_iterator p
;
1572 for (p
= this->needs_
.begin(), i
= 0;
1573 p
!= this->needs_
.end();
1575 pb
= (*p
)->write
SELECT_SIZE_ENDIAN_NAME(size
, big_endian
)(
1576 dynpool
, i
+ 1 >= this->needs_
.size(), pb
1577 SELECT_SIZE_ENDIAN(size
, big_endian
));
1579 gold_assert(static_cast<unsigned int>(pb
- pbuf
) == sz
);
1583 *pentries
= this->needs_
.size();
1586 // Instantiate the templates we need. We could use the configure
1587 // script to restrict this to only the ones for implemented targets.
1589 #ifdef HAVE_TARGET_32_LITTLE
1591 class Sized_dynobj
<32, false>;
1594 #ifdef HAVE_TARGET_32_BIG
1596 class Sized_dynobj
<32, true>;
1599 #ifdef HAVE_TARGET_64_LITTLE
1601 class Sized_dynobj
<64, false>;
1604 #ifdef HAVE_TARGET_64_BIG
1606 class Sized_dynobj
<64, true>;
1609 #ifdef HAVE_TARGET_32_LITTLE
1612 Versions::symbol_section_contents
<32, false>(
1615 const std::vector
<Symbol
*>&,
1618 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1621 #ifdef HAVE_TARGET_32_BIG
1624 Versions::symbol_section_contents
<32, true>(
1627 const std::vector
<Symbol
*>&,
1630 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1633 #ifdef HAVE_TARGET_64_LITTLE
1636 Versions::symbol_section_contents
<64, false>(
1639 const std::vector
<Symbol
*>&,
1642 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1645 #ifdef HAVE_TARGET_64_BIG
1648 Versions::symbol_section_contents
<64, true>(
1651 const std::vector
<Symbol
*>&,
1654 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1657 #ifdef HAVE_TARGET_32_LITTLE
1660 Versions::def_section_contents
<32, false>(
1665 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1668 #ifdef HAVE_TARGET_32_BIG
1671 Versions::def_section_contents
<32, true>(
1676 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1679 #ifdef HAVE_TARGET_64_LITTLE
1682 Versions::def_section_contents
<64, false>(
1687 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1690 #ifdef HAVE_TARGET_64_BIG
1693 Versions::def_section_contents
<64, true>(
1698 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1701 #ifdef HAVE_TARGET_32_LITTLE
1704 Versions::need_section_contents
<32, false>(
1709 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, false)) const;
1712 #ifdef HAVE_TARGET_32_BIG
1715 Versions::need_section_contents
<32, true>(
1720 ACCEPT_SIZE_ENDIAN_EXPLICIT(32, true)) const;
1723 #ifdef HAVE_TARGET_64_LITTLE
1726 Versions::need_section_contents
<64, false>(
1731 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, false)) const;
1734 #ifdef HAVE_TARGET_64_BIG
1737 Versions::need_section_contents
<64, true>(
1742 ACCEPT_SIZE_ENDIAN_EXPLICIT(64, true)) const;
1745 } // End namespace gold.