1 // dynobj.cc -- dynamic object support for gold
3 // Copyright 2006, 2007, 2008 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"
39 // Sets up the default soname_ to use, in the (rare) cases we never
40 // see a DT_SONAME entry.
42 Dynobj::Dynobj(const std::string& name, Input_file* input_file, off_t offset)
43 : Object(name, input_file, true, offset),
45 unknown_needed_(UNKNOWN_NEEDED_UNSET)
47 // This will be overridden by a DT_SONAME entry, hopefully. But if
48 // we never see a DT_SONAME entry, our rule is to use the dynamic
49 // object's filename. The only exception is when the dynamic object
50 // is part of an archive (so the filename is the archive's
51 // filename). In that case, we use just the dynobj's name-in-archive.
52 this->soname_ = this->input_file()->found_name();
53 if (this->offset() != 0)
55 std::string::size_type open_paren = this->name().find('(');
56 std::string::size_type close_paren = this->name().find(')');
57 if (open_paren != std::string::npos && close_paren != std::string::npos)
59 // It's an archive, and name() is of the form 'foo.a(bar.so)'.
60 this->soname_ = this->name().substr(open_paren + 1,
61 close_paren - (open_paren + 1));
66 // Class Sized_dynobj.
68 template<int size, bool big_endian>
69 Sized_dynobj<size, big_endian>::Sized_dynobj(
70 const std::string& name,
71 Input_file* input_file,
73 const elfcpp::Ehdr<size, big_endian>& ehdr)
74 : Dynobj(name, input_file, offset),
75 elf_file_(this, ehdr),
84 template<int size, bool big_endian>
86 Sized_dynobj<size, big_endian>::setup(
87 const elfcpp::Ehdr<size, big_endian>& ehdr)
89 this->set_target(ehdr.get_e_machine(), size, big_endian,
90 ehdr.get_e_ident()[elfcpp::EI_OSABI],
91 ehdr.get_e_ident()[elfcpp::EI_ABIVERSION]);
93 const unsigned int shnum = this->elf_file_.shnum();
94 this->set_shnum(shnum);
97 // Find the SHT_DYNSYM section and the various version sections, and
98 // the dynamic section, given the section headers.
100 template<int size, bool big_endian>
102 Sized_dynobj<size, big_endian>::find_dynsym_sections(
103 const unsigned char* pshdrs,
104 unsigned int* pversym_shndx,
105 unsigned int* pverdef_shndx,
106 unsigned int* pverneed_shndx,
107 unsigned int* pdynamic_shndx)
109 *pversym_shndx = -1U;
110 *pverdef_shndx = -1U;
111 *pverneed_shndx = -1U;
112 *pdynamic_shndx = -1U;
114 unsigned int xindex_shndx = 0;
115 unsigned int xindex_link = 0;
116 const unsigned int shnum = this->shnum();
117 const unsigned char* p = pshdrs;
118 for (unsigned int i = 0; i < shnum; ++i, p += This::shdr_size)
120 typename This::Shdr shdr(p);
123 switch (shdr.get_sh_type())
125 case elfcpp::SHT_DYNSYM:
126 this->dynsym_shndx_ = i;
127 if (xindex_shndx > 0 && xindex_link == i)
129 Xindex* xindex = new Xindex(this->elf_file_.large_shndx_offset());
130 xindex->read_symtab_xindex<size, big_endian>(this, xindex_shndx,
132 this->set_xindex(xindex);
136 case elfcpp::SHT_GNU_versym:
139 case elfcpp::SHT_GNU_verdef:
142 case elfcpp::SHT_GNU_verneed:
145 case elfcpp::SHT_DYNAMIC:
148 case elfcpp::SHT_SYMTAB_SHNDX:
150 xindex_link = this->adjust_shndx(shdr.get_sh_link());
151 if (xindex_link == this->dynsym_shndx_)
153 Xindex* xindex = new Xindex(this->elf_file_.large_shndx_offset());
154 xindex->read_symtab_xindex<size, big_endian>(this, xindex_shndx,
156 this->set_xindex(xindex);
169 this->error(_("unexpected duplicate type %u section: %u, %u"),
170 shdr.get_sh_type(), *pi, i);
176 // Read the contents of section SHNDX. PSHDRS points to the section
177 // headers. TYPE is the expected section type. LINK is the expected
178 // section link. Store the data in *VIEW and *VIEW_SIZE. The
179 // section's sh_info field is stored in *VIEW_INFO.
181 template<int size, bool big_endian>
183 Sized_dynobj<size, big_endian>::read_dynsym_section(
184 const unsigned char* pshdrs,
189 section_size_type* view_size,
190 unsigned int* view_info)
200 typename This::Shdr shdr(pshdrs + shndx * This::shdr_size);
202 gold_assert(shdr.get_sh_type() == type);
204 if (this->adjust_shndx(shdr.get_sh_link()) != link)
205 this->error(_("unexpected link in section %u header: %u != %u"),
206 shndx, this->adjust_shndx(shdr.get_sh_link()), link);
208 *view = this->get_lasting_view(shdr.get_sh_offset(), shdr.get_sh_size(),
210 *view_size = convert_to_section_size_type(shdr.get_sh_size());
211 *view_info = shdr.get_sh_info();
214 // Read the dynamic tags. Set the soname field if this shared object
215 // has a DT_SONAME tag. Record the DT_NEEDED tags. PSHDRS points to
216 // the section headers. DYNAMIC_SHNDX is the section index of the
217 // SHT_DYNAMIC section. STRTAB_SHNDX, STRTAB, and STRTAB_SIZE are the
218 // section index and contents of a string table which may be the one
219 // associated with the SHT_DYNAMIC section.
221 template<int size, bool big_endian>
223 Sized_dynobj<size, big_endian>::read_dynamic(const unsigned char* pshdrs,
224 unsigned int dynamic_shndx,
225 unsigned int strtab_shndx,
226 const unsigned char* strtabu,
229 typename This::Shdr dynamicshdr(pshdrs + dynamic_shndx * This::shdr_size);
230 gold_assert(dynamicshdr.get_sh_type() == elfcpp::SHT_DYNAMIC);
232 const off_t dynamic_size = dynamicshdr.get_sh_size();
233 const unsigned char* pdynamic = this->get_view(dynamicshdr.get_sh_offset(),
234 dynamic_size, true, false);
236 const unsigned int link = this->adjust_shndx(dynamicshdr.get_sh_link());
237 if (link != strtab_shndx)
239 if (link >= this->shnum())
241 this->error(_("DYNAMIC section %u link out of range: %u"),
242 dynamic_shndx, link);
246 typename This::Shdr strtabshdr(pshdrs + link * This::shdr_size);
247 if (strtabshdr.get_sh_type() != elfcpp::SHT_STRTAB)
249 this->error(_("DYNAMIC section %u link %u is not a strtab"),
250 dynamic_shndx, link);
254 strtab_size = strtabshdr.get_sh_size();
255 strtabu = this->get_view(strtabshdr.get_sh_offset(), strtab_size, false,
259 const char* const strtab = reinterpret_cast<const char*>(strtabu);
261 for (const unsigned char* p = pdynamic;
262 p < pdynamic + dynamic_size;
265 typename This::Dyn dyn(p);
267 switch (dyn.get_d_tag())
269 case elfcpp::DT_NULL:
270 // We should always see DT_NULL at the end of the dynamic
274 case elfcpp::DT_SONAME:
276 off_t val = dyn.get_d_val();
277 if (val >= strtab_size)
278 this->error(_("DT_SONAME value out of range: %lld >= %lld"),
279 static_cast<long long>(val),
280 static_cast<long long>(strtab_size));
282 this->set_soname_string(strtab + val);
286 case elfcpp::DT_NEEDED:
288 off_t val = dyn.get_d_val();
289 if (val >= strtab_size)
290 this->error(_("DT_NEEDED value out of range: %lld >= %lld"),
291 static_cast<long long>(val),
292 static_cast<long long>(strtab_size));
294 this->add_needed(strtab + val);
303 this->error(_("missing DT_NULL in dynamic segment"));
306 // Read the symbols and sections from a dynamic object. We read the
307 // dynamic symbols, not the normal symbols.
309 template<int size, bool big_endian>
311 Sized_dynobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd)
313 this->read_section_data(&this->elf_file_, sd);
315 const unsigned char* const pshdrs = sd->section_headers->data();
317 unsigned int versym_shndx;
318 unsigned int verdef_shndx;
319 unsigned int verneed_shndx;
320 unsigned int dynamic_shndx;
321 this->find_dynsym_sections(pshdrs, &versym_shndx, &verdef_shndx,
322 &verneed_shndx, &dynamic_shndx);
324 unsigned int strtab_shndx = -1U;
327 sd->symbols_size = 0;
328 sd->external_symbols_offset = 0;
329 sd->symbol_names = NULL;
330 sd->symbol_names_size = 0;
332 if (this->dynsym_shndx_ != -1U)
334 // Get the dynamic symbols.
335 typename This::Shdr dynsymshdr(pshdrs
336 + this->dynsym_shndx_ * This::shdr_size);
337 gold_assert(dynsymshdr.get_sh_type() == elfcpp::SHT_DYNSYM);
339 sd->symbols = this->get_lasting_view(dynsymshdr.get_sh_offset(),
340 dynsymshdr.get_sh_size(), true,
343 convert_to_section_size_type(dynsymshdr.get_sh_size());
345 // Get the symbol names.
346 strtab_shndx = this->adjust_shndx(dynsymshdr.get_sh_link());
347 if (strtab_shndx >= this->shnum())
349 this->error(_("invalid dynamic symbol table name index: %u"),
353 typename This::Shdr strtabshdr(pshdrs + strtab_shndx * This::shdr_size);
354 if (strtabshdr.get_sh_type() != elfcpp::SHT_STRTAB)
356 this->error(_("dynamic symbol table name section "
357 "has wrong type: %u"),
358 static_cast<unsigned int>(strtabshdr.get_sh_type()));
362 sd->symbol_names = this->get_lasting_view(strtabshdr.get_sh_offset(),
363 strtabshdr.get_sh_size(),
365 sd->symbol_names_size =
366 convert_to_section_size_type(strtabshdr.get_sh_size());
368 // Get the version information.
371 this->read_dynsym_section(pshdrs, versym_shndx, elfcpp::SHT_GNU_versym,
373 &sd->versym, &sd->versym_size, &dummy);
375 // We require that the version definition and need section link
376 // to the same string table as the dynamic symbol table. This
377 // is not a technical requirement, but it always happens in
378 // practice. We could change this if necessary.
380 this->read_dynsym_section(pshdrs, verdef_shndx, elfcpp::SHT_GNU_verdef,
381 strtab_shndx, &sd->verdef, &sd->verdef_size,
384 this->read_dynsym_section(pshdrs, verneed_shndx, elfcpp::SHT_GNU_verneed,
385 strtab_shndx, &sd->verneed, &sd->verneed_size,
389 // Read the SHT_DYNAMIC section to find whether this shared object
390 // has a DT_SONAME tag and to record any DT_NEEDED tags. This
391 // doesn't really have anything to do with reading the symbols, but
392 // this is a convenient place to do it.
393 if (dynamic_shndx != -1U)
394 this->read_dynamic(pshdrs, dynamic_shndx, strtab_shndx,
395 (sd->symbol_names == NULL
397 : sd->symbol_names->data()),
398 sd->symbol_names_size);
401 // Return the Xindex structure to use for object with lots of
404 template<int size, bool big_endian>
406 Sized_dynobj<size, big_endian>::do_initialize_xindex()
408 gold_assert(this->dynsym_shndx_ != -1U);
409 Xindex* xindex = new Xindex(this->elf_file_.large_shndx_offset());
410 xindex->initialize_symtab_xindex<size, big_endian>(this, this->dynsym_shndx_);
414 // Lay out the input sections for a dynamic object. We don't want to
415 // include sections from a dynamic object, so all that we actually do
416 // here is check for .gnu.warning sections.
418 template<int size, bool big_endian>
420 Sized_dynobj<size, big_endian>::do_layout(Symbol_table* symtab,
422 Read_symbols_data* sd)
424 const unsigned int shnum = this->shnum();
428 // Get the section headers.
429 const unsigned char* pshdrs = sd->section_headers->data();
431 // Get the section names.
432 const unsigned char* pnamesu = sd->section_names->data();
433 const char* pnames = reinterpret_cast<const char*>(pnamesu);
435 // Skip the first, dummy, section.
436 pshdrs += This::shdr_size;
437 for (unsigned int i = 1; i < shnum; ++i, pshdrs += This::shdr_size)
439 typename This::Shdr shdr(pshdrs);
441 if (shdr.get_sh_name() >= sd->section_names_size)
443 this->error(_("bad section name offset for section %u: %lu"),
444 i, static_cast<unsigned long>(shdr.get_sh_name()));
448 const char* name = pnames + shdr.get_sh_name();
450 this->handle_gnu_warning_section(name, i, symtab);
453 delete sd->section_headers;
454 sd->section_headers = NULL;
455 delete sd->section_names;
456 sd->section_names = NULL;
459 // Add an entry to the vector mapping version numbers to version
462 template<int size, bool big_endian>
464 Sized_dynobj<size, big_endian>::set_version_map(
465 Version_map* version_map,
467 const char* name) const
469 if (ndx >= version_map->size())
470 version_map->resize(ndx + 1);
471 if ((*version_map)[ndx] != NULL)
472 this->error(_("duplicate definition for version %u"), ndx);
473 (*version_map)[ndx] = name;
476 // Add mappings for the version definitions to VERSION_MAP.
478 template<int size, bool big_endian>
480 Sized_dynobj<size, big_endian>::make_verdef_map(
481 Read_symbols_data* sd,
482 Version_map* version_map) const
484 if (sd->verdef == NULL)
487 const char* names = reinterpret_cast<const char*>(sd->symbol_names->data());
488 section_size_type names_size = sd->symbol_names_size;
490 const unsigned char* pverdef = sd->verdef->data();
491 section_size_type verdef_size = sd->verdef_size;
492 const unsigned int count = sd->verdef_info;
494 const unsigned char* p = pverdef;
495 for (unsigned int i = 0; i < count; ++i)
497 elfcpp::Verdef<size, big_endian> verdef(p);
499 if (verdef.get_vd_version() != elfcpp::VER_DEF_CURRENT)
501 this->error(_("unexpected verdef version %u"),
502 verdef.get_vd_version());
506 const section_size_type vd_ndx = verdef.get_vd_ndx();
508 // The GNU linker clears the VERSYM_HIDDEN bit. I'm not
511 // The first Verdaux holds the name of this version. Subsequent
512 // ones are versions that this one depends upon, which we don't
514 const section_size_type vd_cnt = verdef.get_vd_cnt();
517 this->error(_("verdef vd_cnt field too small: %u"),
518 static_cast<unsigned int>(vd_cnt));
522 const section_size_type vd_aux = verdef.get_vd_aux();
523 if ((p - pverdef) + vd_aux >= verdef_size)
525 this->error(_("verdef vd_aux field out of range: %u"),
526 static_cast<unsigned int>(vd_aux));
530 const unsigned char* pvda = p + vd_aux;
531 elfcpp::Verdaux<size, big_endian> verdaux(pvda);
533 const section_size_type vda_name = verdaux.get_vda_name();
534 if (vda_name >= names_size)
536 this->error(_("verdaux vda_name field out of range: %u"),
537 static_cast<unsigned int>(vda_name));
541 this->set_version_map(version_map, vd_ndx, names + vda_name);
543 const section_size_type vd_next = verdef.get_vd_next();
544 if ((p - pverdef) + vd_next >= verdef_size)
546 this->error(_("verdef vd_next field out of range: %u"),
547 static_cast<unsigned int>(vd_next));
555 // Add mappings for the required versions to VERSION_MAP.
557 template<int size, bool big_endian>
559 Sized_dynobj<size, big_endian>::make_verneed_map(
560 Read_symbols_data* sd,
561 Version_map* version_map) const
563 if (sd->verneed == NULL)
566 const char* names = reinterpret_cast<const char*>(sd->symbol_names->data());
567 section_size_type names_size = sd->symbol_names_size;
569 const unsigned char* pverneed = sd->verneed->data();
570 const section_size_type verneed_size = sd->verneed_size;
571 const unsigned int count = sd->verneed_info;
573 const unsigned char* p = pverneed;
574 for (unsigned int i = 0; i < count; ++i)
576 elfcpp::Verneed<size, big_endian> verneed(p);
578 if (verneed.get_vn_version() != elfcpp::VER_NEED_CURRENT)
580 this->error(_("unexpected verneed version %u"),
581 verneed.get_vn_version());
585 const section_size_type vn_aux = verneed.get_vn_aux();
587 if ((p - pverneed) + vn_aux >= verneed_size)
589 this->error(_("verneed vn_aux field out of range: %u"),
590 static_cast<unsigned int>(vn_aux));
594 const unsigned int vn_cnt = verneed.get_vn_cnt();
595 const unsigned char* pvna = p + vn_aux;
596 for (unsigned int j = 0; j < vn_cnt; ++j)
598 elfcpp::Vernaux<size, big_endian> vernaux(pvna);
600 const unsigned int vna_name = vernaux.get_vna_name();
601 if (vna_name >= names_size)
603 this->error(_("vernaux vna_name field out of range: %u"),
604 static_cast<unsigned int>(vna_name));
608 this->set_version_map(version_map, vernaux.get_vna_other(),
611 const section_size_type vna_next = vernaux.get_vna_next();
612 if ((pvna - pverneed) + vna_next >= verneed_size)
614 this->error(_("verneed vna_next field out of range: %u"),
615 static_cast<unsigned int>(vna_next));
622 const section_size_type vn_next = verneed.get_vn_next();
623 if ((p - pverneed) + vn_next >= verneed_size)
625 this->error(_("verneed vn_next field out of range: %u"),
626 static_cast<unsigned int>(vn_next));
634 // Create a vector mapping version numbers to version strings.
636 template<int size, bool big_endian>
638 Sized_dynobj<size, big_endian>::make_version_map(
639 Read_symbols_data* sd,
640 Version_map* version_map) const
642 if (sd->verdef == NULL && sd->verneed == NULL)
645 // A guess at the maximum version number we will see. If this is
646 // wrong we will be less efficient but still correct.
647 version_map->reserve(sd->verdef_info + sd->verneed_info * 10);
649 this->make_verdef_map(sd, version_map);
650 this->make_verneed_map(sd, version_map);
653 // Add the dynamic symbols to the symbol table.
655 template<int size, bool big_endian>
657 Sized_dynobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
658 Read_symbols_data* sd,
661 if (sd->symbols == NULL)
663 gold_assert(sd->symbol_names == NULL);
664 gold_assert(sd->versym == NULL && sd->verdef == NULL
665 && sd->verneed == NULL);
669 const int sym_size = This::sym_size;
670 const size_t symcount = sd->symbols_size / sym_size;
671 gold_assert(sd->external_symbols_offset == 0);
672 if (symcount * sym_size != sd->symbols_size)
674 this->error(_("size of dynamic symbols is not multiple of symbol size"));
678 Version_map version_map;
679 this->make_version_map(sd, &version_map);
681 // If printing symbol counts, we want to track symbols.
683 if (parameters->options().user_set_print_symbol_counts())
685 this->symbols_ = new Symbols();
686 this->symbols_->resize(symcount);
689 const char* sym_names =
690 reinterpret_cast<const char*>(sd->symbol_names->data());
691 symtab->add_from_dynobj(this, sd->symbols->data(), symcount,
692 sym_names, sd->symbol_names_size,
695 : sd->versym->data()),
699 &this->defined_count_);
703 delete sd->symbol_names;
704 sd->symbol_names = NULL;
705 if (sd->versym != NULL)
710 if (sd->verdef != NULL)
715 if (sd->verneed != NULL)
721 // This is normally the last time we will read any data from this
723 this->clear_view_cache_marks();
726 // Get symbol counts.
728 template<int size, bool big_endian>
730 Sized_dynobj<size, big_endian>::do_get_global_symbol_counts(
735 *defined = this->defined_count_;
737 for (typename Symbols::const_iterator p = this->symbols_->begin();
738 p != this->symbols_->end();
741 && (*p)->source() == Symbol::FROM_OBJECT
742 && (*p)->object() == this
743 && (*p)->is_defined()
744 && (*p)->dynsym_index() != -1U)
749 // Given a vector of hash codes, compute the number of hash buckets to
753 Dynobj::compute_bucket_count(const std::vector<uint32_t>& hashcodes,
754 bool for_gnu_hash_table)
756 // FIXME: Implement optional hash table optimization.
758 // Array used to determine the number of hash table buckets to use
759 // based on the number of symbols there are. If there are fewer
760 // than 3 symbols we use 1 bucket, fewer than 17 symbols we use 3
761 // buckets, fewer than 37 we use 17 buckets, and so forth. We never
762 // use more than 262147 buckets. This is straight from the old GNU
764 static const unsigned int buckets[] =
766 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209,
767 16411, 32771, 65537, 131101, 262147
769 const int buckets_count = sizeof buckets / sizeof buckets[0];
771 unsigned int symcount = hashcodes.size();
772 unsigned int ret = 1;
773 const double full_fraction
774 = 1.0 - parameters->options().hash_bucket_empty_fraction();
775 for (int i = 0; i < buckets_count; ++i)
777 if (symcount < buckets[i] * full_fraction)
782 if (for_gnu_hash_table && ret < 2)
788 // The standard ELF hash function. This hash function must not
789 // change, as the dynamic linker uses it also.
792 Dynobj::elf_hash(const char* name)
794 const unsigned char* nameu = reinterpret_cast<const unsigned char*>(name);
797 while ((c = *nameu++) != '\0')
800 uint32_t g = h & 0xf0000000;
804 // The ELF ABI says h &= ~g, but using xor is equivalent in
805 // this case (since g was set from h) and may save one
813 // Create a standard ELF hash table, setting *PPHASH and *PHASHLEN.
814 // DYNSYMS is a vector with all the global dynamic symbols.
815 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
819 Dynobj::create_elf_hash_table(const std::vector<Symbol*>& dynsyms,
820 unsigned int local_dynsym_count,
821 unsigned char** pphash,
822 unsigned int* phashlen)
824 unsigned int dynsym_count = dynsyms.size();
826 // Get the hash values for all the symbols.
827 std::vector<uint32_t> dynsym_hashvals(dynsym_count);
828 for (unsigned int i = 0; i < dynsym_count; ++i)
829 dynsym_hashvals[i] = Dynobj::elf_hash(dynsyms[i]->name());
831 const unsigned int bucketcount =
832 Dynobj::compute_bucket_count(dynsym_hashvals, false);
834 std::vector<uint32_t> bucket(bucketcount);
835 std::vector<uint32_t> chain(local_dynsym_count + dynsym_count);
837 for (unsigned int i = 0; i < dynsym_count; ++i)
839 unsigned int dynsym_index = dynsyms[i]->dynsym_index();
840 unsigned int bucketpos = dynsym_hashvals[i] % bucketcount;
841 chain[dynsym_index] = bucket[bucketpos];
842 bucket[bucketpos] = dynsym_index;
845 unsigned int hashlen = ((2
850 unsigned char* phash = new unsigned char[hashlen];
852 if (parameters->target().is_big_endian())
854 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
855 Dynobj::sized_create_elf_hash_table<true>(bucket, chain, phash,
863 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
864 Dynobj::sized_create_elf_hash_table<false>(bucket, chain, phash,
875 // Fill in an ELF hash table.
877 template<bool big_endian>
879 Dynobj::sized_create_elf_hash_table(const std::vector<uint32_t>& bucket,
880 const std::vector<uint32_t>& chain,
881 unsigned char* phash,
882 unsigned int hashlen)
884 unsigned char* p = phash;
886 const unsigned int bucketcount = bucket.size();
887 const unsigned int chaincount = chain.size();
889 elfcpp::Swap<32, big_endian>::writeval(p, bucketcount);
891 elfcpp::Swap<32, big_endian>::writeval(p, chaincount);
894 for (unsigned int i = 0; i < bucketcount; ++i)
896 elfcpp::Swap<32, big_endian>::writeval(p, bucket[i]);
900 for (unsigned int i = 0; i < chaincount; ++i)
902 elfcpp::Swap<32, big_endian>::writeval(p, chain[i]);
906 gold_assert(static_cast<unsigned int>(p - phash) == hashlen);
909 // The hash function used for the GNU hash table. This hash function
910 // must not change, as the dynamic linker uses it also.
913 Dynobj::gnu_hash(const char* name)
915 const unsigned char* nameu = reinterpret_cast<const unsigned char*>(name);
918 while ((c = *nameu++) != '\0')
919 h = (h << 5) + h + c;
923 // Create a GNU hash table, setting *PPHASH and *PHASHLEN. GNU hash
924 // tables are an extension to ELF which are recognized by the GNU
925 // dynamic linker. They are referenced using dynamic tag DT_GNU_HASH.
926 // TARGET is the target. DYNSYMS is a vector with all the global
927 // symbols which will be going into the dynamic symbol table.
928 // LOCAL_DYNSYM_COUNT is the number of local symbols in the dynamic
932 Dynobj::create_gnu_hash_table(const std::vector<Symbol*>& dynsyms,
933 unsigned int local_dynsym_count,
934 unsigned char** pphash,
935 unsigned int* phashlen)
937 const unsigned int count = dynsyms.size();
939 // Sort the dynamic symbols into two vectors. Symbols which we do
940 // not want to put into the hash table we store into
941 // UNHASHED_DYNSYMS. Symbols which we do want to store we put into
942 // HASHED_DYNSYMS. DYNSYM_HASHVALS is parallel to HASHED_DYNSYMS,
943 // and records the hash codes.
945 std::vector<Symbol*> unhashed_dynsyms;
946 unhashed_dynsyms.reserve(count);
948 std::vector<Symbol*> hashed_dynsyms;
949 hashed_dynsyms.reserve(count);
951 std::vector<uint32_t> dynsym_hashvals;
952 dynsym_hashvals.reserve(count);
954 for (unsigned int i = 0; i < count; ++i)
956 Symbol* sym = dynsyms[i];
958 // FIXME: Should put on unhashed_dynsyms if the symbol is
960 if (sym->is_undefined())
961 unhashed_dynsyms.push_back(sym);
964 hashed_dynsyms.push_back(sym);
965 dynsym_hashvals.push_back(Dynobj::gnu_hash(sym->name()));
969 // Put the unhashed symbols at the start of the global portion of
970 // the dynamic symbol table.
971 const unsigned int unhashed_count = unhashed_dynsyms.size();
972 unsigned int unhashed_dynsym_index = local_dynsym_count;
973 for (unsigned int i = 0; i < unhashed_count; ++i)
975 unhashed_dynsyms[i]->set_dynsym_index(unhashed_dynsym_index);
976 ++unhashed_dynsym_index;
979 // For the actual data generation we call out to a templatized
981 int size = parameters->target().get_size();
982 bool big_endian = parameters->target().is_big_endian();
987 #ifdef HAVE_TARGET_32_BIG
988 Dynobj::sized_create_gnu_hash_table<32, true>(hashed_dynsyms,
990 unhashed_dynsym_index,
999 #ifdef HAVE_TARGET_32_LITTLE
1000 Dynobj::sized_create_gnu_hash_table<32, false>(hashed_dynsyms,
1002 unhashed_dynsym_index,
1010 else if (size == 64)
1014 #ifdef HAVE_TARGET_64_BIG
1015 Dynobj::sized_create_gnu_hash_table<64, true>(hashed_dynsyms,
1017 unhashed_dynsym_index,
1026 #ifdef HAVE_TARGET_64_LITTLE
1027 Dynobj::sized_create_gnu_hash_table<64, false>(hashed_dynsyms,
1029 unhashed_dynsym_index,
1041 // Create the actual data for a GNU hash table. This is just a copy
1042 // of the code from the old GNU linker.
1044 template<int size, bool big_endian>
1046 Dynobj::sized_create_gnu_hash_table(
1047 const std::vector<Symbol*>& hashed_dynsyms,
1048 const std::vector<uint32_t>& dynsym_hashvals,
1049 unsigned int unhashed_dynsym_count,
1050 unsigned char** pphash,
1051 unsigned int* phashlen)
1053 if (hashed_dynsyms.empty())
1055 // Special case for the empty hash table.
1056 unsigned int hashlen = 5 * 4 + size / 8;
1057 unsigned char* phash = new unsigned char[hashlen];
1058 // One empty bucket.
1059 elfcpp::Swap<32, big_endian>::writeval(phash, 1);
1060 // Symbol index above unhashed symbols.
1061 elfcpp::Swap<32, big_endian>::writeval(phash + 4, unhashed_dynsym_count);
1062 // One word for bitmask.
1063 elfcpp::Swap<32, big_endian>::writeval(phash + 8, 1);
1064 // Only bloom filter.
1065 elfcpp::Swap<32, big_endian>::writeval(phash + 12, 0);
1067 elfcpp::Swap<size, big_endian>::writeval(phash + 16, 0);
1068 // No hashes in only bucket.
1069 elfcpp::Swap<32, big_endian>::writeval(phash + 16 + size / 8, 0);
1071 *phashlen = hashlen;
1077 const unsigned int bucketcount =
1078 Dynobj::compute_bucket_count(dynsym_hashvals, true);
1080 const unsigned int nsyms = hashed_dynsyms.size();
1082 uint32_t maskbitslog2 = 1;
1083 uint32_t x = nsyms >> 1;
1089 if (maskbitslog2 < 3)
1091 else if (((1U << (maskbitslog2 - 2)) & nsyms) != 0)
1101 if (maskbitslog2 == 5)
1105 uint32_t mask = (1U << shift1) - 1U;
1106 uint32_t shift2 = maskbitslog2;
1107 uint32_t maskbits = 1U << maskbitslog2;
1108 uint32_t maskwords = 1U << (maskbitslog2 - shift1);
1110 typedef typename elfcpp::Elf_types<size>::Elf_WXword Word;
1111 std::vector<Word> bitmask(maskwords);
1112 std::vector<uint32_t> counts(bucketcount);
1113 std::vector<uint32_t> indx(bucketcount);
1114 uint32_t symindx = unhashed_dynsym_count;
1116 // Count the number of times each hash bucket is used.
1117 for (unsigned int i = 0; i < nsyms; ++i)
1118 ++counts[dynsym_hashvals[i] % bucketcount];
1120 unsigned int cnt = symindx;
1121 for (unsigned int i = 0; i < bucketcount; ++i)
1127 unsigned int hashlen = (4 + bucketcount + nsyms) * 4;
1128 hashlen += maskbits / 8;
1129 unsigned char* phash = new unsigned char[hashlen];
1131 elfcpp::Swap<32, big_endian>::writeval(phash, bucketcount);
1132 elfcpp::Swap<32, big_endian>::writeval(phash + 4, symindx);
1133 elfcpp::Swap<32, big_endian>::writeval(phash + 8, maskwords);
1134 elfcpp::Swap<32, big_endian>::writeval(phash + 12, shift2);
1136 unsigned char* p = phash + 16 + maskbits / 8;
1137 for (unsigned int i = 0; i < bucketcount; ++i)
1140 elfcpp::Swap<32, big_endian>::writeval(p, 0);
1142 elfcpp::Swap<32, big_endian>::writeval(p, indx[i]);
1146 for (unsigned int i = 0; i < nsyms; ++i)
1148 Symbol* sym = hashed_dynsyms[i];
1149 uint32_t hashval = dynsym_hashvals[i];
1151 unsigned int bucket = hashval % bucketcount;
1152 unsigned int val = ((hashval >> shift1)
1153 & ((maskbits >> shift1) - 1));
1154 bitmask[val] |= (static_cast<Word>(1U)) << (hashval & mask);
1155 bitmask[val] |= (static_cast<Word>(1U)) << ((hashval >> shift2) & mask);
1156 val = hashval & ~ 1U;
1157 if (counts[bucket] == 1)
1159 // Last element terminates the chain.
1162 elfcpp::Swap<32, big_endian>::writeval(p + (indx[bucket] - symindx) * 4,
1166 sym->set_dynsym_index(indx[bucket]);
1171 for (unsigned int i = 0; i < maskwords; ++i)
1173 elfcpp::Swap<size, big_endian>::writeval(p, bitmask[i]);
1177 *phashlen = hashlen;
1183 // Write this definition to a buffer for the output section.
1185 template<int size, bool big_endian>
1187 Verdef::write(const Stringpool* dynpool, bool is_last, unsigned char* pb) const
1189 const int verdef_size = elfcpp::Elf_sizes<size>::verdef_size;
1190 const int verdaux_size = elfcpp::Elf_sizes<size>::verdaux_size;
1192 elfcpp::Verdef_write<size, big_endian> vd(pb);
1193 vd.set_vd_version(elfcpp::VER_DEF_CURRENT);
1194 vd.set_vd_flags((this->is_base_ ? elfcpp::VER_FLG_BASE : 0)
1195 | (this->is_weak_ ? elfcpp::VER_FLG_WEAK : 0));
1196 vd.set_vd_ndx(this->index());
1197 vd.set_vd_cnt(1 + this->deps_.size());
1198 vd.set_vd_hash(Dynobj::elf_hash(this->name()));
1199 vd.set_vd_aux(verdef_size);
1200 vd.set_vd_next(is_last
1202 : verdef_size + (1 + this->deps_.size()) * verdaux_size);
1205 elfcpp::Verdaux_write<size, big_endian> vda(pb);
1206 vda.set_vda_name(dynpool->get_offset(this->name()));
1207 vda.set_vda_next(this->deps_.empty() ? 0 : verdaux_size);
1210 Deps::const_iterator p;
1212 for (p = this->deps_.begin(), i = 0;
1213 p != this->deps_.end();
1216 elfcpp::Verdaux_write<size, big_endian> vda(pb);
1217 vda.set_vda_name(dynpool->get_offset(*p));
1218 vda.set_vda_next(i + 1 >= this->deps_.size() ? 0 : verdaux_size);
1229 for (Need_versions::iterator p = this->need_versions_.begin();
1230 p != this->need_versions_.end();
1235 // Add a new version to this file reference.
1238 Verneed::add_name(const char* name)
1240 Verneed_version* vv = new Verneed_version(name);
1241 this->need_versions_.push_back(vv);
1245 // Set the version indexes starting at INDEX.
1248 Verneed::finalize(unsigned int index)
1250 for (Need_versions::iterator p = this->need_versions_.begin();
1251 p != this->need_versions_.end();
1254 (*p)->set_index(index);
1260 // Write this list of referenced versions to a buffer for the output
1263 template<int size, bool big_endian>
1265 Verneed::write(const Stringpool* dynpool, bool is_last,
1266 unsigned char* pb) const
1268 const int verneed_size = elfcpp::Elf_sizes<size>::verneed_size;
1269 const int vernaux_size = elfcpp::Elf_sizes<size>::vernaux_size;
1271 elfcpp::Verneed_write<size, big_endian> vn(pb);
1272 vn.set_vn_version(elfcpp::VER_NEED_CURRENT);
1273 vn.set_vn_cnt(this->need_versions_.size());
1274 vn.set_vn_file(dynpool->get_offset(this->filename()));
1275 vn.set_vn_aux(verneed_size);
1276 vn.set_vn_next(is_last
1278 : verneed_size + this->need_versions_.size() * vernaux_size);
1281 Need_versions::const_iterator p;
1283 for (p = this->need_versions_.begin(), i = 0;
1284 p != this->need_versions_.end();
1287 elfcpp::Vernaux_write<size, big_endian> vna(pb);
1288 vna.set_vna_hash(Dynobj::elf_hash((*p)->version()));
1289 // FIXME: We need to sometimes set VER_FLG_WEAK here.
1290 vna.set_vna_flags(0);
1291 vna.set_vna_other((*p)->index());
1292 vna.set_vna_name(dynpool->get_offset((*p)->version()));
1293 vna.set_vna_next(i + 1 >= this->need_versions_.size()
1302 // Versions methods.
1304 Versions::Versions(const Version_script_info& version_script,
1305 Stringpool* dynpool)
1306 : defs_(), needs_(), version_table_(),
1307 is_finalized_(false), version_script_(version_script)
1309 // We always need a base version, so define that first. Nothing
1310 // explicitly declares itself as part of base, so it doesn't need to
1311 // be in version_table_.
1312 if (parameters->options().shared())
1314 const char* name = parameters->options().soname();
1316 name = parameters->options().output_file_name();
1317 name = dynpool->add(name, false, NULL);
1318 Verdef* vdbase = new Verdef(name, std::vector<std::string>(),
1320 this->defs_.push_back(vdbase);
1323 if (!this->version_script_.empty())
1325 // Parse the version script, and insert each declared version into
1326 // defs_ and version_table_.
1327 std::vector<std::string> versions = this->version_script_.get_versions();
1328 for (size_t k = 0; k < versions.size(); ++k)
1330 Stringpool::Key version_key;
1331 const char* version = dynpool->add(versions[k].c_str(),
1332 true, &version_key);
1333 Verdef* const vd = new Verdef(
1335 this->version_script_.get_dependencies(version),
1336 false, false, false);
1337 this->defs_.push_back(vd);
1338 Key key(version_key, 0);
1339 this->version_table_.insert(std::make_pair(key, vd));
1344 Versions::~Versions()
1346 for (Defs::iterator p = this->defs_.begin();
1347 p != this->defs_.end();
1351 for (Needs::iterator p = this->needs_.begin();
1352 p != this->needs_.end();
1357 // Return the dynamic object which a symbol refers to.
1360 Versions::get_dynobj_for_sym(const Symbol_table* symtab,
1361 const Symbol* sym) const
1363 if (sym->is_copied_from_dynobj())
1364 return symtab->get_copy_source(sym);
1367 Object* object = sym->object();
1368 gold_assert(object->is_dynamic());
1369 return static_cast<Dynobj*>(object);
1373 // Record version information for a symbol going into the dynamic
1377 Versions::record_version(const Symbol_table* symtab,
1378 Stringpool* dynpool, const Symbol* sym)
1380 gold_assert(!this->is_finalized_);
1381 gold_assert(sym->version() != NULL);
1383 Stringpool::Key version_key;
1384 const char* version = dynpool->add(sym->version(), false, &version_key);
1386 if (!sym->is_from_dynobj() && !sym->is_copied_from_dynobj())
1388 if (parameters->options().shared())
1389 this->add_def(sym, version, version_key);
1393 // This is a version reference.
1394 Dynobj* dynobj = this->get_dynobj_for_sym(symtab, sym);
1395 this->add_need(dynpool, dynobj->soname(), version, version_key);
1399 // We've found a symbol SYM defined in version VERSION.
1402 Versions::add_def(const Symbol* sym, const char* version,
1403 Stringpool::Key version_key)
1405 Key k(version_key, 0);
1406 Version_base* const vbnull = NULL;
1407 std::pair<Version_table::iterator, bool> ins =
1408 this->version_table_.insert(std::make_pair(k, vbnull));
1412 // We already have an entry for this version.
1413 Version_base* vb = ins.first->second;
1415 // We have now seen a symbol in this version, so it is not
1417 gold_assert(vb != NULL);
1422 // If we are creating a shared object, it is an error to
1423 // find a definition of a symbol with a version which is not
1424 // in the version script.
1425 if (parameters->options().shared())
1426 gold_error(_("symbol %s has undefined version %s"),
1427 sym->demangled_name().c_str(), version);
1429 // When creating a regular executable, automatically define
1431 Verdef* vd = new Verdef(version, std::vector<std::string>(),
1432 false, false, false);
1433 this->defs_.push_back(vd);
1434 ins.first->second = vd;
1438 // Add a reference to version NAME in file FILENAME.
1441 Versions::add_need(Stringpool* dynpool, const char* filename, const char* name,
1442 Stringpool::Key name_key)
1444 Stringpool::Key filename_key;
1445 filename = dynpool->add(filename, true, &filename_key);
1447 Key k(name_key, filename_key);
1448 Version_base* const vbnull = NULL;
1449 std::pair<Version_table::iterator, bool> ins =
1450 this->version_table_.insert(std::make_pair(k, vbnull));
1454 // We already have an entry for this filename/version.
1458 // See whether we already have this filename. We don't expect many
1459 // version references, so we just do a linear search. This could be
1460 // replaced by a hash table.
1462 for (Needs::iterator p = this->needs_.begin();
1463 p != this->needs_.end();
1466 if ((*p)->filename() == filename)
1475 // We have a new filename.
1476 vn = new Verneed(filename);
1477 this->needs_.push_back(vn);
1480 ins.first->second = vn->add_name(name);
1483 // Set the version indexes. Create a new dynamic version symbol for
1484 // each new version definition.
1487 Versions::finalize(Symbol_table* symtab, unsigned int dynsym_index,
1488 std::vector<Symbol*>* syms)
1490 gold_assert(!this->is_finalized_);
1492 unsigned int vi = 1;
1494 for (Defs::iterator p = this->defs_.begin();
1495 p != this->defs_.end();
1498 (*p)->set_index(vi);
1501 // Create a version symbol if necessary.
1502 if (!(*p)->is_symbol_created())
1504 Symbol* vsym = symtab->define_as_constant((*p)->name(),
1508 elfcpp::STV_DEFAULT, 0,
1510 vsym->set_needs_dynsym_entry();
1511 vsym->set_dynsym_index(dynsym_index);
1513 syms->push_back(vsym);
1514 // The name is already in the dynamic pool.
1518 // Index 1 is used for global symbols.
1521 gold_assert(this->defs_.empty());
1525 for (Needs::iterator p = this->needs_.begin();
1526 p != this->needs_.end();
1528 vi = (*p)->finalize(vi);
1530 this->is_finalized_ = true;
1532 return dynsym_index;
1535 // Return the version index to use for a symbol. This does two hash
1536 // table lookups: one in DYNPOOL and one in this->version_table_.
1537 // Another approach alternative would be store a pointer in SYM, which
1538 // would increase the size of the symbol table. Or perhaps we could
1539 // use a hash table from dynamic symbol pointer values to Version_base
1543 Versions::version_index(const Symbol_table* symtab, const Stringpool* dynpool,
1544 const Symbol* sym) const
1546 Stringpool::Key version_key;
1547 const char* version = dynpool->find(sym->version(), &version_key);
1548 gold_assert(version != NULL);
1551 if (!sym->is_from_dynobj() && !sym->is_copied_from_dynobj())
1553 if (!parameters->options().shared())
1554 return elfcpp::VER_NDX_GLOBAL;
1555 k = Key(version_key, 0);
1559 Dynobj* dynobj = this->get_dynobj_for_sym(symtab, sym);
1561 Stringpool::Key filename_key;
1562 const char* filename = dynpool->find(dynobj->soname(), &filename_key);
1563 gold_assert(filename != NULL);
1565 k = Key(version_key, filename_key);
1568 Version_table::const_iterator p = this->version_table_.find(k);
1569 gold_assert(p != this->version_table_.end());
1571 return p->second->index();
1574 // Return an allocated buffer holding the contents of the symbol
1577 template<int size, bool big_endian>
1579 Versions::symbol_section_contents(const Symbol_table* symtab,
1580 const Stringpool* dynpool,
1581 unsigned int local_symcount,
1582 const std::vector<Symbol*>& syms,
1584 unsigned int* psize) const
1586 gold_assert(this->is_finalized_);
1588 unsigned int sz = (local_symcount + syms.size()) * 2;
1589 unsigned char* pbuf = new unsigned char[sz];
1591 for (unsigned int i = 0; i < local_symcount; ++i)
1592 elfcpp::Swap<16, big_endian>::writeval(pbuf + i * 2,
1593 elfcpp::VER_NDX_LOCAL);
1595 for (std::vector<Symbol*>::const_iterator p = syms.begin();
1599 unsigned int version_index;
1600 const char* version = (*p)->version();
1601 if (version == NULL)
1602 version_index = elfcpp::VER_NDX_GLOBAL;
1604 version_index = this->version_index(symtab, dynpool, *p);
1605 // If the symbol was defined as foo@V1 instead of foo@@V1, add
1607 if ((*p)->version() != NULL && !(*p)->is_default())
1608 version_index |= elfcpp::VERSYM_HIDDEN;
1609 elfcpp::Swap<16, big_endian>::writeval(pbuf + (*p)->dynsym_index() * 2,
1617 // Return an allocated buffer holding the contents of the version
1618 // definition section.
1620 template<int size, bool big_endian>
1622 Versions::def_section_contents(const Stringpool* dynpool,
1623 unsigned char** pp, unsigned int* psize,
1624 unsigned int* pentries) const
1626 gold_assert(this->is_finalized_);
1627 gold_assert(!this->defs_.empty());
1629 const int verdef_size = elfcpp::Elf_sizes<size>::verdef_size;
1630 const int verdaux_size = elfcpp::Elf_sizes<size>::verdaux_size;
1632 unsigned int sz = 0;
1633 for (Defs::const_iterator p = this->defs_.begin();
1634 p != this->defs_.end();
1637 sz += verdef_size + verdaux_size;
1638 sz += (*p)->count_dependencies() * verdaux_size;
1641 unsigned char* pbuf = new unsigned char[sz];
1643 unsigned char* pb = pbuf;
1644 Defs::const_iterator p;
1646 for (p = this->defs_.begin(), i = 0;
1647 p != this->defs_.end();
1649 pb = (*p)->write<size, big_endian>(dynpool,
1650 i + 1 >= this->defs_.size(),
1653 gold_assert(static_cast<unsigned int>(pb - pbuf) == sz);
1657 *pentries = this->defs_.size();
1660 // Return an allocated buffer holding the contents of the version
1661 // reference section.
1663 template<int size, bool big_endian>
1665 Versions::need_section_contents(const Stringpool* dynpool,
1666 unsigned char** pp, unsigned int *psize,
1667 unsigned int *pentries) const
1669 gold_assert(this->is_finalized_);
1670 gold_assert(!this->needs_.empty());
1672 const int verneed_size = elfcpp::Elf_sizes<size>::verneed_size;
1673 const int vernaux_size = elfcpp::Elf_sizes<size>::vernaux_size;
1675 unsigned int sz = 0;
1676 for (Needs::const_iterator p = this->needs_.begin();
1677 p != this->needs_.end();
1681 sz += (*p)->count_versions() * vernaux_size;
1684 unsigned char* pbuf = new unsigned char[sz];
1686 unsigned char* pb = pbuf;
1687 Needs::const_iterator p;
1689 for (p = this->needs_.begin(), i = 0;
1690 p != this->needs_.end();
1692 pb = (*p)->write<size, big_endian>(dynpool,
1693 i + 1 >= this->needs_.size(),
1696 gold_assert(static_cast<unsigned int>(pb - pbuf) == sz);
1700 *pentries = this->needs_.size();
1703 // Instantiate the templates we need. We could use the configure
1704 // script to restrict this to only the ones for implemented targets.
1706 #ifdef HAVE_TARGET_32_LITTLE
1708 class Sized_dynobj<32, false>;
1711 #ifdef HAVE_TARGET_32_BIG
1713 class Sized_dynobj<32, true>;
1716 #ifdef HAVE_TARGET_64_LITTLE
1718 class Sized_dynobj<64, false>;
1721 #ifdef HAVE_TARGET_64_BIG
1723 class Sized_dynobj<64, true>;
1726 #ifdef HAVE_TARGET_32_LITTLE
1729 Versions::symbol_section_contents<32, false>(
1730 const Symbol_table*,
1733 const std::vector<Symbol*>&,
1735 unsigned int*) const;
1738 #ifdef HAVE_TARGET_32_BIG
1741 Versions::symbol_section_contents<32, true>(
1742 const Symbol_table*,
1745 const std::vector<Symbol*>&,
1747 unsigned int*) const;
1750 #ifdef HAVE_TARGET_64_LITTLE
1753 Versions::symbol_section_contents<64, false>(
1754 const Symbol_table*,
1757 const std::vector<Symbol*>&,
1759 unsigned int*) const;
1762 #ifdef HAVE_TARGET_64_BIG
1765 Versions::symbol_section_contents<64, true>(
1766 const Symbol_table*,
1769 const std::vector<Symbol*>&,
1771 unsigned int*) const;
1774 #ifdef HAVE_TARGET_32_LITTLE
1777 Versions::def_section_contents<32, false>(
1781 unsigned int*) const;
1784 #ifdef HAVE_TARGET_32_BIG
1787 Versions::def_section_contents<32, true>(
1791 unsigned int*) const;
1794 #ifdef HAVE_TARGET_64_LITTLE
1797 Versions::def_section_contents<64, false>(
1801 unsigned int*) const;
1804 #ifdef HAVE_TARGET_64_BIG
1807 Versions::def_section_contents<64, true>(
1811 unsigned int*) const;
1814 #ifdef HAVE_TARGET_32_LITTLE
1817 Versions::need_section_contents<32, false>(
1821 unsigned int*) const;
1824 #ifdef HAVE_TARGET_32_BIG
1827 Versions::need_section_contents<32, true>(
1831 unsigned int*) const;
1834 #ifdef HAVE_TARGET_64_LITTLE
1837 Versions::need_section_contents<64, false>(
1841 unsigned int*) const;
1844 #ifdef HAVE_TARGET_64_BIG
1847 Versions::need_section_contents<64, true>(
1851 unsigned int*) const;
1854 } // End namespace gold.