1 // symtab.cc -- the gold symbol table
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.
34 #include "dwarf_reader.h"
38 #include "workqueue.h"
46 // Initialize fields in Symbol. This initializes everything except u_
50 Symbol::init_fields(const char* name, const char* version,
51 elfcpp::STT type, elfcpp::STB binding,
52 elfcpp::STV visibility, unsigned char nonvis)
55 this->version_ = version;
56 this->symtab_index_ = 0;
57 this->dynsym_index_ = 0;
58 this->got_offsets_.init();
59 this->plt_offset_ = 0;
61 this->binding_ = binding;
62 this->visibility_ = visibility;
63 this->nonvis_ = nonvis;
64 this->is_target_special_ = false;
65 this->is_def_ = false;
66 this->is_forwarder_ = false;
67 this->has_alias_ = false;
68 this->needs_dynsym_entry_ = false;
69 this->in_reg_ = false;
70 this->in_dyn_ = false;
71 this->has_plt_offset_ = false;
72 this->has_warning_ = false;
73 this->is_copied_from_dynobj_ = false;
74 this->is_forced_local_ = false;
75 this->is_ordinary_shndx_ = false;
78 // Return the demangled version of the symbol's name, but only
79 // if the --demangle flag was set.
82 demangle(const char* name)
84 if (!parameters->options().do_demangle())
87 // cplus_demangle allocates memory for the result it returns,
88 // and returns NULL if the name is already demangled.
89 char* demangled_name = cplus_demangle(name, DMGL_ANSI | DMGL_PARAMS);
90 if (demangled_name == NULL)
93 std::string retval(demangled_name);
99 Symbol::demangled_name() const
101 return demangle(this->name());
104 // Initialize the fields in the base class Symbol for SYM in OBJECT.
106 template<int size, bool big_endian>
108 Symbol::init_base_object(const char* name, const char* version, Object* object,
109 const elfcpp::Sym<size, big_endian>& sym,
110 unsigned int st_shndx, bool is_ordinary)
112 this->init_fields(name, version, sym.get_st_type(), sym.get_st_bind(),
113 sym.get_st_visibility(), sym.get_st_nonvis());
114 this->u_.from_object.object = object;
115 this->u_.from_object.shndx = st_shndx;
116 this->is_ordinary_shndx_ = is_ordinary;
117 this->source_ = FROM_OBJECT;
118 this->in_reg_ = !object->is_dynamic();
119 this->in_dyn_ = object->is_dynamic();
122 // Initialize the fields in the base class Symbol for a symbol defined
123 // in an Output_data.
126 Symbol::init_base_output_data(const char* name, Output_data* od,
127 elfcpp::STT type, elfcpp::STB binding,
128 elfcpp::STV visibility, unsigned char nonvis,
129 bool offset_is_from_end)
131 this->init_fields(name, NULL, type, binding, visibility, nonvis);
132 this->u_.in_output_data.output_data = od;
133 this->u_.in_output_data.offset_is_from_end = offset_is_from_end;
134 this->source_ = IN_OUTPUT_DATA;
135 this->in_reg_ = true;
138 // Initialize the fields in the base class Symbol for a symbol defined
139 // in an Output_segment.
142 Symbol::init_base_output_segment(const char* name, Output_segment* os,
143 elfcpp::STT type, elfcpp::STB binding,
144 elfcpp::STV visibility, unsigned char nonvis,
145 Segment_offset_base offset_base)
147 this->init_fields(name, NULL, type, binding, visibility, nonvis);
148 this->u_.in_output_segment.output_segment = os;
149 this->u_.in_output_segment.offset_base = offset_base;
150 this->source_ = IN_OUTPUT_SEGMENT;
151 this->in_reg_ = true;
154 // Initialize the fields in the base class Symbol for a symbol defined
158 Symbol::init_base_constant(const char* name, elfcpp::STT type,
159 elfcpp::STB binding, elfcpp::STV visibility,
160 unsigned char nonvis)
162 this->init_fields(name, NULL, type, binding, visibility, nonvis);
163 this->source_ = IS_CONSTANT;
164 this->in_reg_ = true;
167 // Initialize the fields in the base class Symbol for an undefined
171 Symbol::init_base_undefined(const char* name, elfcpp::STT type,
172 elfcpp::STB binding, elfcpp::STV visibility,
173 unsigned char nonvis)
175 this->init_fields(name, NULL, type, binding, visibility, nonvis);
176 this->source_ = IS_UNDEFINED;
177 this->in_reg_ = true;
180 // Allocate a common symbol in the base.
183 Symbol::allocate_base_common(Output_data* od)
185 gold_assert(this->is_common());
186 this->source_ = IN_OUTPUT_DATA;
187 this->u_.in_output_data.output_data = od;
188 this->u_.in_output_data.offset_is_from_end = false;
191 // Initialize the fields in Sized_symbol for SYM in OBJECT.
194 template<bool big_endian>
196 Sized_symbol<size>::init_object(const char* name, const char* version,
198 const elfcpp::Sym<size, big_endian>& sym,
199 unsigned int st_shndx, bool is_ordinary)
201 this->init_base_object(name, version, object, sym, st_shndx, is_ordinary);
202 this->value_ = sym.get_st_value();
203 this->symsize_ = sym.get_st_size();
206 // Initialize the fields in Sized_symbol for a symbol defined in an
211 Sized_symbol<size>::init_output_data(const char* name, Output_data* od,
212 Value_type value, Size_type symsize,
213 elfcpp::STT type, elfcpp::STB binding,
214 elfcpp::STV visibility,
215 unsigned char nonvis,
216 bool offset_is_from_end)
218 this->init_base_output_data(name, od, type, binding, visibility, nonvis,
220 this->value_ = value;
221 this->symsize_ = symsize;
224 // Initialize the fields in Sized_symbol for a symbol defined in an
229 Sized_symbol<size>::init_output_segment(const char* name, Output_segment* os,
230 Value_type value, Size_type symsize,
231 elfcpp::STT type, elfcpp::STB binding,
232 elfcpp::STV visibility,
233 unsigned char nonvis,
234 Segment_offset_base offset_base)
236 this->init_base_output_segment(name, os, type, binding, visibility, nonvis,
238 this->value_ = value;
239 this->symsize_ = symsize;
242 // Initialize the fields in Sized_symbol for a symbol defined as a
247 Sized_symbol<size>::init_constant(const char* name, Value_type value,
248 Size_type symsize, elfcpp::STT type,
249 elfcpp::STB binding, elfcpp::STV visibility,
250 unsigned char nonvis)
252 this->init_base_constant(name, type, binding, visibility, nonvis);
253 this->value_ = value;
254 this->symsize_ = symsize;
257 // Initialize the fields in Sized_symbol for an undefined symbol.
261 Sized_symbol<size>::init_undefined(const char* name, elfcpp::STT type,
262 elfcpp::STB binding, elfcpp::STV visibility,
263 unsigned char nonvis)
265 this->init_base_undefined(name, type, binding, visibility, nonvis);
270 // Allocate a common symbol.
274 Sized_symbol<size>::allocate_common(Output_data* od, Value_type value)
276 this->allocate_base_common(od);
277 this->value_ = value;
280 // Return true if this symbol should be added to the dynamic symbol
284 Symbol::should_add_dynsym_entry() const
286 // If the symbol is used by a dynamic relocation, we need to add it.
287 if (this->needs_dynsym_entry())
290 // If the symbol was forced local in a version script, do not add it.
291 if (this->is_forced_local())
294 // If exporting all symbols or building a shared library,
295 // and the symbol is defined in a regular object and is
296 // externally visible, we need to add it.
297 if ((parameters->options().export_dynamic() || parameters->options().shared())
298 && !this->is_from_dynobj()
299 && this->is_externally_visible())
305 // Return true if the final value of this symbol is known at link
309 Symbol::final_value_is_known() const
311 // If we are not generating an executable, then no final values are
312 // known, since they will change at runtime.
313 if (parameters->options().shared() || parameters->options().relocatable())
316 // If the symbol is not from an object file, and is not undefined,
317 // then it is defined, and known.
318 if (this->source_ != FROM_OBJECT)
320 if (this->source_ != IS_UNDEFINED)
325 // If the symbol is from a dynamic object, then the final value
327 if (this->object()->is_dynamic())
330 // If the symbol is not undefined (it is defined or common),
331 // then the final value is known.
332 if (!this->is_undefined())
336 // If the symbol is undefined, then whether the final value is known
337 // depends on whether we are doing a static link. If we are doing a
338 // dynamic link, then the final value could be filled in at runtime.
339 // This could reasonably be the case for a weak undefined symbol.
340 return parameters->doing_static_link();
343 // Return the output section where this symbol is defined.
346 Symbol::output_section() const
348 switch (this->source_)
352 unsigned int shndx = this->u_.from_object.shndx;
353 if (shndx != elfcpp::SHN_UNDEF && this->is_ordinary_shndx_)
355 gold_assert(!this->u_.from_object.object->is_dynamic());
356 Relobj* relobj = static_cast<Relobj*>(this->u_.from_object.object);
357 section_offset_type dummy;
358 return relobj->output_section(shndx, &dummy);
364 return this->u_.in_output_data.output_data->output_section();
366 case IN_OUTPUT_SEGMENT:
376 // Set the symbol's output section. This is used for symbols defined
377 // in scripts. This should only be called after the symbol table has
381 Symbol::set_output_section(Output_section* os)
383 switch (this->source_)
387 gold_assert(this->output_section() == os);
390 this->source_ = IN_OUTPUT_DATA;
391 this->u_.in_output_data.output_data = os;
392 this->u_.in_output_data.offset_is_from_end = false;
394 case IN_OUTPUT_SEGMENT:
401 // Class Symbol_table.
403 Symbol_table::Symbol_table(unsigned int count,
404 const Version_script_info& version_script)
405 : saw_undefined_(0), offset_(0), table_(count), namepool_(),
406 forwarders_(), commons_(), tls_commons_(), forced_locals_(), warnings_(),
407 version_script_(version_script)
409 namepool_.reserve(count);
412 Symbol_table::~Symbol_table()
416 // The hash function. The key values are Stringpool keys.
419 Symbol_table::Symbol_table_hash::operator()(const Symbol_table_key& key) const
421 return key.first ^ key.second;
424 // The symbol table key equality function. This is called with
428 Symbol_table::Symbol_table_eq::operator()(const Symbol_table_key& k1,
429 const Symbol_table_key& k2) const
431 return k1.first == k2.first && k1.second == k2.second;
434 // Make TO a symbol which forwards to FROM.
437 Symbol_table::make_forwarder(Symbol* from, Symbol* to)
439 gold_assert(from != to);
440 gold_assert(!from->is_forwarder() && !to->is_forwarder());
441 this->forwarders_[from] = to;
442 from->set_forwarder();
445 // Resolve the forwards from FROM, returning the real symbol.
448 Symbol_table::resolve_forwards(const Symbol* from) const
450 gold_assert(from->is_forwarder());
451 Unordered_map<const Symbol*, Symbol*>::const_iterator p =
452 this->forwarders_.find(from);
453 gold_assert(p != this->forwarders_.end());
457 // Look up a symbol by name.
460 Symbol_table::lookup(const char* name, const char* version) const
462 Stringpool::Key name_key;
463 name = this->namepool_.find(name, &name_key);
467 Stringpool::Key version_key = 0;
470 version = this->namepool_.find(version, &version_key);
475 Symbol_table_key key(name_key, version_key);
476 Symbol_table::Symbol_table_type::const_iterator p = this->table_.find(key);
477 if (p == this->table_.end())
482 // Resolve a Symbol with another Symbol. This is only used in the
483 // unusual case where there are references to both an unversioned
484 // symbol and a symbol with a version, and we then discover that that
485 // version is the default version. Because this is unusual, we do
486 // this the slow way, by converting back to an ELF symbol.
488 template<int size, bool big_endian>
490 Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
493 unsigned char buf[elfcpp::Elf_sizes<size>::sym_size];
494 elfcpp::Sym_write<size, big_endian> esym(buf);
495 // We don't bother to set the st_name or the st_shndx field.
496 esym.put_st_value(from->value());
497 esym.put_st_size(from->symsize());
498 esym.put_st_info(from->binding(), from->type());
499 esym.put_st_other(from->visibility(), from->nonvis());
501 unsigned int shndx = from->shndx(&is_ordinary);
502 this->resolve(to, esym.sym(), shndx, is_ordinary, shndx, from->object(),
510 // Record that a symbol is forced to be local by a version script.
513 Symbol_table::force_local(Symbol* sym)
515 if (!sym->is_defined() && !sym->is_common())
517 if (sym->is_forced_local())
519 // We already got this one.
522 sym->set_is_forced_local();
523 this->forced_locals_.push_back(sym);
526 // Adjust NAME for wrapping, and update *NAME_KEY if necessary. This
527 // is only called for undefined symbols, when at least one --wrap
531 Symbol_table::wrap_symbol(Object* object, const char* name,
532 Stringpool::Key* name_key)
534 // For some targets, we need to ignore a specific character when
535 // wrapping, and add it back later.
537 if (name[0] == object->target()->wrap_char())
543 if (parameters->options().is_wrap(name))
545 // Turn NAME into __wrap_NAME.
552 // This will give us both the old and new name in NAMEPOOL_, but
553 // that is OK. Only the versions we need will wind up in the
554 // real string table in the output file.
555 return this->namepool_.add(s.c_str(), true, name_key);
558 const char* const real_prefix = "__real_";
559 const size_t real_prefix_length = strlen(real_prefix);
560 if (strncmp(name, real_prefix, real_prefix_length) == 0
561 && parameters->options().is_wrap(name + real_prefix_length))
563 // Turn __real_NAME into NAME.
567 s += name + real_prefix_length;
568 return this->namepool_.add(s.c_str(), true, name_key);
574 // Add one symbol from OBJECT to the symbol table. NAME is symbol
575 // name and VERSION is the version; both are canonicalized. DEF is
576 // whether this is the default version. ST_SHNDX is the symbol's
577 // section index; IS_ORDINARY is whether this is a normal section
578 // rather than a special code.
580 // If DEF is true, then this is the definition of a default version of
581 // a symbol. That means that any lookup of NAME/NULL and any lookup
582 // of NAME/VERSION should always return the same symbol. This is
583 // obvious for references, but in particular we want to do this for
584 // definitions: overriding NAME/NULL should also override
585 // NAME/VERSION. If we don't do that, it would be very hard to
586 // override functions in a shared library which uses versioning.
588 // We implement this by simply making both entries in the hash table
589 // point to the same Symbol structure. That is easy enough if this is
590 // the first time we see NAME/NULL or NAME/VERSION, but it is possible
591 // that we have seen both already, in which case they will both have
592 // independent entries in the symbol table. We can't simply change
593 // the symbol table entry, because we have pointers to the entries
594 // attached to the object files. So we mark the entry attached to the
595 // object file as a forwarder, and record it in the forwarders_ map.
596 // Note that entries in the hash table will never be marked as
599 // ORIG_ST_SHNDX and ST_SHNDX are almost always the same.
600 // ORIG_ST_SHNDX is the section index in the input file, or SHN_UNDEF
601 // for a special section code. ST_SHNDX may be modified if the symbol
602 // is defined in a section being discarded.
604 template<int size, bool big_endian>
606 Symbol_table::add_from_object(Object* object,
608 Stringpool::Key name_key,
610 Stringpool::Key version_key,
612 const elfcpp::Sym<size, big_endian>& sym,
613 unsigned int st_shndx,
615 unsigned int orig_st_shndx)
617 // Print a message if this symbol is being traced.
618 if (parameters->options().is_trace_symbol(name))
620 if (orig_st_shndx == elfcpp::SHN_UNDEF)
621 gold_info(_("%s: reference to %s"), object->name().c_str(), name);
623 gold_info(_("%s: definition of %s"), object->name().c_str(), name);
626 // For an undefined symbol, we may need to adjust the name using
628 if (orig_st_shndx == elfcpp::SHN_UNDEF
629 && parameters->options().any_wrap())
631 const char* wrap_name = this->wrap_symbol(object, name, &name_key);
632 if (wrap_name != name)
634 // If we see a reference to malloc with version GLIBC_2.0,
635 // and we turn it into a reference to __wrap_malloc, then we
636 // discard the version number. Otherwise the user would be
637 // required to specify the correct version for
645 Symbol* const snull = NULL;
646 std::pair<typename Symbol_table_type::iterator, bool> ins =
647 this->table_.insert(std::make_pair(std::make_pair(name_key, version_key),
650 std::pair<typename Symbol_table_type::iterator, bool> insdef =
651 std::make_pair(this->table_.end(), false);
654 const Stringpool::Key vnull_key = 0;
655 insdef = this->table_.insert(std::make_pair(std::make_pair(name_key,
660 // ins.first: an iterator, which is a pointer to a pair.
661 // ins.first->first: the key (a pair of name and version).
662 // ins.first->second: the value (Symbol*).
663 // ins.second: true if new entry was inserted, false if not.
665 Sized_symbol<size>* ret;
670 // We already have an entry for NAME/VERSION.
671 ret = this->get_sized_symbol<size>(ins.first->second);
672 gold_assert(ret != NULL);
674 was_undefined = ret->is_undefined();
675 was_common = ret->is_common();
677 this->resolve(ret, sym, st_shndx, is_ordinary, orig_st_shndx, object,
684 // This is the first time we have seen NAME/NULL. Make
685 // NAME/NULL point to NAME/VERSION.
686 insdef.first->second = ret;
688 else if (insdef.first->second != ret
689 && insdef.first->second->is_undefined())
691 // This is the unfortunate case where we already have
692 // entries for both NAME/VERSION and NAME/NULL. Note
693 // that we don't want to combine them if the existing
694 // symbol is going to override the new one. FIXME: We
695 // currently just test is_undefined, but this may not do
696 // the right thing if the existing symbol is from a
697 // shared library and the new one is from a regular
700 const Sized_symbol<size>* sym2;
701 sym2 = this->get_sized_symbol<size>(insdef.first->second);
702 Symbol_table::resolve<size, big_endian>(ret, sym2, version);
703 this->make_forwarder(insdef.first->second, ret);
704 insdef.first->second = ret;
712 // This is the first time we have seen NAME/VERSION.
713 gold_assert(ins.first->second == NULL);
715 if (def && !insdef.second)
717 // We already have an entry for NAME/NULL. If we override
718 // it, then change it to NAME/VERSION.
719 ret = this->get_sized_symbol<size>(insdef.first->second);
721 was_undefined = ret->is_undefined();
722 was_common = ret->is_common();
724 this->resolve(ret, sym, st_shndx, is_ordinary, orig_st_shndx, object,
726 ins.first->second = ret;
730 was_undefined = false;
733 Sized_target<size, big_endian>* target =
734 object->sized_target<size, big_endian>();
735 if (!target->has_make_symbol())
736 ret = new Sized_symbol<size>();
739 ret = target->make_symbol();
742 // This means that we don't want a symbol table
745 this->table_.erase(ins.first);
748 this->table_.erase(insdef.first);
749 // Inserting insdef invalidated ins.
750 this->table_.erase(std::make_pair(name_key,
757 ret->init_object(name, version, object, sym, st_shndx, is_ordinary);
759 ins.first->second = ret;
762 // This is the first time we have seen NAME/NULL. Point
763 // it at the new entry for NAME/VERSION.
764 gold_assert(insdef.second);
765 insdef.first->second = ret;
770 // Record every time we see a new undefined symbol, to speed up
772 if (!was_undefined && ret->is_undefined())
773 ++this->saw_undefined_;
775 // Keep track of common symbols, to speed up common symbol
777 if (!was_common && ret->is_common())
779 if (ret->type() != elfcpp::STT_TLS)
780 this->commons_.push_back(ret);
782 this->tls_commons_.push_back(ret);
786 ret->set_is_default();
790 // Add all the symbols in a relocatable object to the hash table.
792 template<int size, bool big_endian>
794 Symbol_table::add_from_relobj(
795 Sized_relobj<size, big_endian>* relobj,
796 const unsigned char* syms,
798 size_t symndx_offset,
799 const char* sym_names,
800 size_t sym_name_size,
801 typename Sized_relobj<size, big_endian>::Symbols* sympointers)
803 gold_assert(size == relobj->target()->get_size());
804 gold_assert(size == parameters->target().get_size());
806 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
808 const bool just_symbols = relobj->just_symbols();
810 const unsigned char* p = syms;
811 for (size_t i = 0; i < count; ++i, p += sym_size)
813 elfcpp::Sym<size, big_endian> sym(p);
815 unsigned int st_name = sym.get_st_name();
816 if (st_name >= sym_name_size)
818 relobj->error(_("bad global symbol name offset %u at %zu"),
823 const char* name = sym_names + st_name;
826 unsigned int st_shndx = relobj->adjust_sym_shndx(i + symndx_offset,
829 unsigned int orig_st_shndx = st_shndx;
831 orig_st_shndx = elfcpp::SHN_UNDEF;
833 // A symbol defined in a section which we are not including must
834 // be treated as an undefined symbol.
835 if (st_shndx != elfcpp::SHN_UNDEF
837 && !relobj->is_section_included(st_shndx))
838 st_shndx = elfcpp::SHN_UNDEF;
840 // In an object file, an '@' in the name separates the symbol
841 // name from the version name. If there are two '@' characters,
842 // this is the default version.
843 const char* ver = strchr(name, '@');
845 // DEF: is the version default? LOCAL: is the symbol forced local?
851 // The symbol name is of the form foo@VERSION or foo@@VERSION
852 namelen = ver - name;
860 // We don't want to assign a version to an undefined symbol,
861 // even if it is listed in the version script. FIXME: What
862 // about a common symbol?
863 else if (!version_script_.empty()
864 && st_shndx != elfcpp::SHN_UNDEF)
866 // The symbol name did not have a version, but
867 // the version script may assign a version anyway.
868 namelen = strlen(name);
870 // Check the global: entries from the version script.
871 const std::string& version =
872 version_script_.get_symbol_version(name);
873 if (!version.empty())
874 ver = version.c_str();
875 // Check the local: entries from the version script
876 if (version_script_.symbol_is_local(name))
880 elfcpp::Sym<size, big_endian>* psym = &sym;
881 unsigned char symbuf[sym_size];
882 elfcpp::Sym<size, big_endian> sym2(symbuf);
885 memcpy(symbuf, p, sym_size);
886 elfcpp::Sym_write<size, big_endian> sw(symbuf);
887 if (orig_st_shndx != elfcpp::SHN_UNDEF && is_ordinary)
889 // Symbol values in object files are section relative.
890 // This is normally what we want, but since here we are
891 // converting the symbol to absolute we need to add the
892 // section address. The section address in an object
893 // file is normally zero, but people can use a linker
894 // script to change it.
895 sw.put_st_value(sym.get_st_value()
896 + relobj->section_address(orig_st_shndx));
898 st_shndx = elfcpp::SHN_ABS;
903 Sized_symbol<size>* res;
906 Stringpool::Key name_key;
907 name = this->namepool_.add(name, true, &name_key);
908 res = this->add_from_object(relobj, name, name_key, NULL, 0,
909 false, *psym, st_shndx, is_ordinary,
912 this->force_local(res);
916 Stringpool::Key name_key;
917 name = this->namepool_.add_with_length(name, namelen, true,
919 Stringpool::Key ver_key;
920 ver = this->namepool_.add(ver, true, &ver_key);
922 res = this->add_from_object(relobj, name, name_key, ver, ver_key,
923 def, *psym, st_shndx, is_ordinary,
927 (*sympointers)[i] = res;
931 // Add all the symbols in a dynamic object to the hash table.
933 template<int size, bool big_endian>
935 Symbol_table::add_from_dynobj(
936 Sized_dynobj<size, big_endian>* dynobj,
937 const unsigned char* syms,
939 const char* sym_names,
940 size_t sym_name_size,
941 const unsigned char* versym,
943 const std::vector<const char*>* version_map)
945 gold_assert(size == dynobj->target()->get_size());
946 gold_assert(size == parameters->target().get_size());
948 if (dynobj->just_symbols())
950 gold_error(_("--just-symbols does not make sense with a shared object"));
954 if (versym != NULL && versym_size / 2 < count)
956 dynobj->error(_("too few symbol versions"));
960 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
962 // We keep a list of all STT_OBJECT symbols, so that we can resolve
963 // weak aliases. This is necessary because if the dynamic object
964 // provides the same variable under two names, one of which is a
965 // weak definition, and the regular object refers to the weak
966 // definition, we have to put both the weak definition and the
967 // strong definition into the dynamic symbol table. Given a weak
968 // definition, the only way that we can find the corresponding
969 // strong definition, if any, is to search the symbol table.
970 std::vector<Sized_symbol<size>*> object_symbols;
972 const unsigned char* p = syms;
973 const unsigned char* vs = versym;
974 for (size_t i = 0; i < count; ++i, p += sym_size, vs += 2)
976 elfcpp::Sym<size, big_endian> sym(p);
978 // Ignore symbols with local binding or that have
979 // internal or hidden visibility.
980 if (sym.get_st_bind() == elfcpp::STB_LOCAL
981 || sym.get_st_visibility() == elfcpp::STV_INTERNAL
982 || sym.get_st_visibility() == elfcpp::STV_HIDDEN)
985 // A protected symbol in a shared library must be treated as a
986 // normal symbol when viewed from outside the shared library.
987 // Implement this by overriding the visibility here.
988 elfcpp::Sym<size, big_endian>* psym = &sym;
989 unsigned char symbuf[sym_size];
990 elfcpp::Sym<size, big_endian> sym2(symbuf);
991 if (sym.get_st_visibility() == elfcpp::STV_PROTECTED)
993 memcpy(symbuf, p, sym_size);
994 elfcpp::Sym_write<size, big_endian> sw(symbuf);
995 sw.put_st_other(elfcpp::STV_DEFAULT, sym.get_st_nonvis());
999 unsigned int st_name = psym->get_st_name();
1000 if (st_name >= sym_name_size)
1002 dynobj->error(_("bad symbol name offset %u at %zu"),
1007 const char* name = sym_names + st_name;
1010 unsigned int st_shndx = dynobj->adjust_sym_shndx(i, psym->get_st_shndx(),
1013 Sized_symbol<size>* res;
1017 Stringpool::Key name_key;
1018 name = this->namepool_.add(name, true, &name_key);
1019 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
1020 false, *psym, st_shndx, is_ordinary,
1025 // Read the version information.
1027 unsigned int v = elfcpp::Swap<16, big_endian>::readval(vs);
1029 bool hidden = (v & elfcpp::VERSYM_HIDDEN) != 0;
1030 v &= elfcpp::VERSYM_VERSION;
1032 // The Sun documentation says that V can be VER_NDX_LOCAL,
1033 // or VER_NDX_GLOBAL, or a version index. The meaning of
1034 // VER_NDX_LOCAL is defined as "Symbol has local scope."
1035 // The old GNU linker will happily generate VER_NDX_LOCAL
1036 // for an undefined symbol. I don't know what the Sun
1037 // linker will generate.
1039 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
1040 && st_shndx != elfcpp::SHN_UNDEF)
1042 // This symbol should not be visible outside the object.
1046 // At this point we are definitely going to add this symbol.
1047 Stringpool::Key name_key;
1048 name = this->namepool_.add(name, true, &name_key);
1050 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
1051 || v == static_cast<unsigned int>(elfcpp::VER_NDX_GLOBAL))
1053 // This symbol does not have a version.
1054 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
1055 false, *psym, st_shndx, is_ordinary,
1060 if (v >= version_map->size())
1062 dynobj->error(_("versym for symbol %zu out of range: %u"),
1067 const char* version = (*version_map)[v];
1068 if (version == NULL)
1070 dynobj->error(_("versym for symbol %zu has no name: %u"),
1075 Stringpool::Key version_key;
1076 version = this->namepool_.add(version, true, &version_key);
1078 // If this is an absolute symbol, and the version name
1079 // and symbol name are the same, then this is the
1080 // version definition symbol. These symbols exist to
1081 // support using -u to pull in particular versions. We
1082 // do not want to record a version for them.
1083 if (st_shndx == elfcpp::SHN_ABS
1085 && name_key == version_key)
1086 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
1087 false, *psym, st_shndx, is_ordinary,
1091 const bool def = (!hidden
1092 && st_shndx != elfcpp::SHN_UNDEF);
1093 res = this->add_from_object(dynobj, name, name_key, version,
1094 version_key, def, *psym, st_shndx,
1095 is_ordinary, st_shndx);
1100 // Note that it is possible that RES was overridden by an
1101 // earlier object, in which case it can't be aliased here.
1102 if (st_shndx != elfcpp::SHN_UNDEF
1104 && psym->get_st_type() == elfcpp::STT_OBJECT
1105 && res->source() == Symbol::FROM_OBJECT
1106 && res->object() == dynobj)
1107 object_symbols.push_back(res);
1110 this->record_weak_aliases(&object_symbols);
1113 // This is used to sort weak aliases. We sort them first by section
1114 // index, then by offset, then by weak ahead of strong.
1117 class Weak_alias_sorter
1120 bool operator()(const Sized_symbol<size>*, const Sized_symbol<size>*) const;
1125 Weak_alias_sorter<size>::operator()(const Sized_symbol<size>* s1,
1126 const Sized_symbol<size>* s2) const
1129 unsigned int s1_shndx = s1->shndx(&is_ordinary);
1130 gold_assert(is_ordinary);
1131 unsigned int s2_shndx = s2->shndx(&is_ordinary);
1132 gold_assert(is_ordinary);
1133 if (s1_shndx != s2_shndx)
1134 return s1_shndx < s2_shndx;
1136 if (s1->value() != s2->value())
1137 return s1->value() < s2->value();
1138 if (s1->binding() != s2->binding())
1140 if (s1->binding() == elfcpp::STB_WEAK)
1142 if (s2->binding() == elfcpp::STB_WEAK)
1145 return std::string(s1->name()) < std::string(s2->name());
1148 // SYMBOLS is a list of object symbols from a dynamic object. Look
1149 // for any weak aliases, and record them so that if we add the weak
1150 // alias to the dynamic symbol table, we also add the corresponding
1155 Symbol_table::record_weak_aliases(std::vector<Sized_symbol<size>*>* symbols)
1157 // Sort the vector by section index, then by offset, then by weak
1159 std::sort(symbols->begin(), symbols->end(), Weak_alias_sorter<size>());
1161 // Walk through the vector. For each weak definition, record
1163 for (typename std::vector<Sized_symbol<size>*>::const_iterator p =
1165 p != symbols->end();
1168 if ((*p)->binding() != elfcpp::STB_WEAK)
1171 // Build a circular list of weak aliases. Each symbol points to
1172 // the next one in the circular list.
1174 Sized_symbol<size>* from_sym = *p;
1175 typename std::vector<Sized_symbol<size>*>::const_iterator q;
1176 for (q = p + 1; q != symbols->end(); ++q)
1179 if ((*q)->shndx(&dummy) != from_sym->shndx(&dummy)
1180 || (*q)->value() != from_sym->value())
1183 this->weak_aliases_[from_sym] = *q;
1184 from_sym->set_has_alias();
1190 this->weak_aliases_[from_sym] = *p;
1191 from_sym->set_has_alias();
1198 // Create and return a specially defined symbol. If ONLY_IF_REF is
1199 // true, then only create the symbol if there is a reference to it.
1200 // If this does not return NULL, it sets *POLDSYM to the existing
1201 // symbol if there is one. This canonicalizes *PNAME and *PVERSION.
1203 template<int size, bool big_endian>
1205 Symbol_table::define_special_symbol(const char** pname, const char** pversion,
1207 Sized_symbol<size>** poldsym)
1210 Sized_symbol<size>* sym;
1211 bool add_to_table = false;
1212 typename Symbol_table_type::iterator add_loc = this->table_.end();
1214 // If the caller didn't give us a version, see if we get one from
1215 // the version script.
1216 if (*pversion == NULL)
1218 const std::string& v(this->version_script_.get_symbol_version(*pname));
1220 *pversion = v.c_str();
1225 oldsym = this->lookup(*pname, *pversion);
1226 if (oldsym == NULL || !oldsym->is_undefined())
1229 *pname = oldsym->name();
1230 *pversion = oldsym->version();
1234 // Canonicalize NAME and VERSION.
1235 Stringpool::Key name_key;
1236 *pname = this->namepool_.add(*pname, true, &name_key);
1238 Stringpool::Key version_key = 0;
1239 if (*pversion != NULL)
1240 *pversion = this->namepool_.add(*pversion, true, &version_key);
1242 Symbol* const snull = NULL;
1243 std::pair<typename Symbol_table_type::iterator, bool> ins =
1244 this->table_.insert(std::make_pair(std::make_pair(name_key,
1250 // We already have a symbol table entry for NAME/VERSION.
1251 oldsym = ins.first->second;
1252 gold_assert(oldsym != NULL);
1256 // We haven't seen this symbol before.
1257 gold_assert(ins.first->second == NULL);
1258 add_to_table = true;
1259 add_loc = ins.first;
1264 const Target& target = parameters->target();
1265 if (!target.has_make_symbol())
1266 sym = new Sized_symbol<size>();
1269 gold_assert(target.get_size() == size);
1270 gold_assert(target.is_big_endian() ? big_endian : !big_endian);
1271 typedef Sized_target<size, big_endian> My_target;
1272 const My_target* sized_target =
1273 static_cast<const My_target*>(&target);
1274 sym = sized_target->make_symbol();
1280 add_loc->second = sym;
1282 gold_assert(oldsym != NULL);
1284 *poldsym = this->get_sized_symbol<size>(oldsym);
1289 // Define a symbol based on an Output_data.
1292 Symbol_table::define_in_output_data(const char* name,
1293 const char* version,
1298 elfcpp::STB binding,
1299 elfcpp::STV visibility,
1300 unsigned char nonvis,
1301 bool offset_is_from_end,
1304 if (parameters->target().get_size() == 32)
1306 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1307 return this->do_define_in_output_data<32>(name, version, od,
1308 value, symsize, type, binding,
1316 else if (parameters->target().get_size() == 64)
1318 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1319 return this->do_define_in_output_data<64>(name, version, od,
1320 value, symsize, type, binding,
1332 // Define a symbol in an Output_data, sized version.
1336 Symbol_table::do_define_in_output_data(
1338 const char* version,
1340 typename elfcpp::Elf_types<size>::Elf_Addr value,
1341 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
1343 elfcpp::STB binding,
1344 elfcpp::STV visibility,
1345 unsigned char nonvis,
1346 bool offset_is_from_end,
1349 Sized_symbol<size>* sym;
1350 Sized_symbol<size>* oldsym;
1352 if (parameters->target().is_big_endian())
1354 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1355 sym = this->define_special_symbol<size, true>(&name, &version,
1356 only_if_ref, &oldsym);
1363 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1364 sym = this->define_special_symbol<size, false>(&name, &version,
1365 only_if_ref, &oldsym);
1374 gold_assert(version == NULL || oldsym != NULL);
1375 sym->init_output_data(name, od, value, symsize, type, binding, visibility,
1376 nonvis, offset_is_from_end);
1380 if (binding == elfcpp::STB_LOCAL
1381 || this->version_script_.symbol_is_local(name))
1382 this->force_local(sym);
1386 if (Symbol_table::should_override_with_special(oldsym))
1387 this->override_with_special(oldsym, sym);
1392 // Define a symbol based on an Output_segment.
1395 Symbol_table::define_in_output_segment(const char* name,
1396 const char* version, Output_segment* os,
1400 elfcpp::STB binding,
1401 elfcpp::STV visibility,
1402 unsigned char nonvis,
1403 Symbol::Segment_offset_base offset_base,
1406 if (parameters->target().get_size() == 32)
1408 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1409 return this->do_define_in_output_segment<32>(name, version, os,
1410 value, symsize, type,
1411 binding, visibility, nonvis,
1412 offset_base, only_if_ref);
1417 else if (parameters->target().get_size() == 64)
1419 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1420 return this->do_define_in_output_segment<64>(name, version, os,
1421 value, symsize, type,
1422 binding, visibility, nonvis,
1423 offset_base, only_if_ref);
1432 // Define a symbol in an Output_segment, sized version.
1436 Symbol_table::do_define_in_output_segment(
1438 const char* version,
1440 typename elfcpp::Elf_types<size>::Elf_Addr value,
1441 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
1443 elfcpp::STB binding,
1444 elfcpp::STV visibility,
1445 unsigned char nonvis,
1446 Symbol::Segment_offset_base offset_base,
1449 Sized_symbol<size>* sym;
1450 Sized_symbol<size>* oldsym;
1452 if (parameters->target().is_big_endian())
1454 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1455 sym = this->define_special_symbol<size, true>(&name, &version,
1456 only_if_ref, &oldsym);
1463 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1464 sym = this->define_special_symbol<size, false>(&name, &version,
1465 only_if_ref, &oldsym);
1474 gold_assert(version == NULL || oldsym != NULL);
1475 sym->init_output_segment(name, os, value, symsize, type, binding,
1476 visibility, nonvis, offset_base);
1480 if (binding == elfcpp::STB_LOCAL
1481 || this->version_script_.symbol_is_local(name))
1482 this->force_local(sym);
1486 if (Symbol_table::should_override_with_special(oldsym))
1487 this->override_with_special(oldsym, sym);
1492 // Define a special symbol with a constant value. It is a multiple
1493 // definition error if this symbol is already defined.
1496 Symbol_table::define_as_constant(const char* name,
1497 const char* version,
1501 elfcpp::STB binding,
1502 elfcpp::STV visibility,
1503 unsigned char nonvis,
1505 bool force_override)
1507 if (parameters->target().get_size() == 32)
1509 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1510 return this->do_define_as_constant<32>(name, version, value,
1511 symsize, type, binding,
1512 visibility, nonvis, only_if_ref,
1518 else if (parameters->target().get_size() == 64)
1520 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1521 return this->do_define_as_constant<64>(name, version, value,
1522 symsize, type, binding,
1523 visibility, nonvis, only_if_ref,
1533 // Define a symbol as a constant, sized version.
1537 Symbol_table::do_define_as_constant(
1539 const char* version,
1540 typename elfcpp::Elf_types<size>::Elf_Addr value,
1541 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
1543 elfcpp::STB binding,
1544 elfcpp::STV visibility,
1545 unsigned char nonvis,
1547 bool force_override)
1549 Sized_symbol<size>* sym;
1550 Sized_symbol<size>* oldsym;
1552 if (parameters->target().is_big_endian())
1554 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1555 sym = this->define_special_symbol<size, true>(&name, &version,
1556 only_if_ref, &oldsym);
1563 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1564 sym = this->define_special_symbol<size, false>(&name, &version,
1565 only_if_ref, &oldsym);
1574 gold_assert(version == NULL || version == name || oldsym != NULL);
1575 sym->init_constant(name, value, symsize, type, binding, visibility, nonvis);
1579 // Version symbols are absolute symbols with name == version.
1580 // We don't want to force them to be local.
1581 if ((version == NULL
1584 && (binding == elfcpp::STB_LOCAL
1585 || this->version_script_.symbol_is_local(name)))
1586 this->force_local(sym);
1590 if (force_override || Symbol_table::should_override_with_special(oldsym))
1591 this->override_with_special(oldsym, sym);
1596 // Define a set of symbols in output sections.
1599 Symbol_table::define_symbols(const Layout* layout, int count,
1600 const Define_symbol_in_section* p,
1603 for (int i = 0; i < count; ++i, ++p)
1605 Output_section* os = layout->find_output_section(p->output_section);
1607 this->define_in_output_data(p->name, NULL, os, p->value,
1608 p->size, p->type, p->binding,
1609 p->visibility, p->nonvis,
1610 p->offset_is_from_end,
1611 only_if_ref || p->only_if_ref);
1613 this->define_as_constant(p->name, NULL, 0, p->size, p->type,
1614 p->binding, p->visibility, p->nonvis,
1615 only_if_ref || p->only_if_ref,
1620 // Define a set of symbols in output segments.
1623 Symbol_table::define_symbols(const Layout* layout, int count,
1624 const Define_symbol_in_segment* p,
1627 for (int i = 0; i < count; ++i, ++p)
1629 Output_segment* os = layout->find_output_segment(p->segment_type,
1630 p->segment_flags_set,
1631 p->segment_flags_clear);
1633 this->define_in_output_segment(p->name, NULL, os, p->value,
1634 p->size, p->type, p->binding,
1635 p->visibility, p->nonvis,
1637 only_if_ref || p->only_if_ref);
1639 this->define_as_constant(p->name, NULL, 0, p->size, p->type,
1640 p->binding, p->visibility, p->nonvis,
1641 only_if_ref || p->only_if_ref,
1646 // Define CSYM using a COPY reloc. POSD is the Output_data where the
1647 // symbol should be defined--typically a .dyn.bss section. VALUE is
1648 // the offset within POSD.
1652 Symbol_table::define_with_copy_reloc(
1653 Sized_symbol<size>* csym,
1655 typename elfcpp::Elf_types<size>::Elf_Addr value)
1657 gold_assert(csym->is_from_dynobj());
1658 gold_assert(!csym->is_copied_from_dynobj());
1659 Object* object = csym->object();
1660 gold_assert(object->is_dynamic());
1661 Dynobj* dynobj = static_cast<Dynobj*>(object);
1663 // Our copied variable has to override any variable in a shared
1665 elfcpp::STB binding = csym->binding();
1666 if (binding == elfcpp::STB_WEAK)
1667 binding = elfcpp::STB_GLOBAL;
1669 this->define_in_output_data(csym->name(), csym->version(),
1670 posd, value, csym->symsize(),
1671 csym->type(), binding,
1672 csym->visibility(), csym->nonvis(),
1675 csym->set_is_copied_from_dynobj();
1676 csym->set_needs_dynsym_entry();
1678 this->copied_symbol_dynobjs_[csym] = dynobj;
1680 // We have now defined all aliases, but we have not entered them all
1681 // in the copied_symbol_dynobjs_ map.
1682 if (csym->has_alias())
1687 sym = this->weak_aliases_[sym];
1690 gold_assert(sym->output_data() == posd);
1692 sym->set_is_copied_from_dynobj();
1693 this->copied_symbol_dynobjs_[sym] = dynobj;
1698 // SYM is defined using a COPY reloc. Return the dynamic object where
1699 // the original definition was found.
1702 Symbol_table::get_copy_source(const Symbol* sym) const
1704 gold_assert(sym->is_copied_from_dynobj());
1705 Copied_symbol_dynobjs::const_iterator p =
1706 this->copied_symbol_dynobjs_.find(sym);
1707 gold_assert(p != this->copied_symbol_dynobjs_.end());
1711 // Add any undefined symbols named on the command line.
1714 Symbol_table::add_undefined_symbols_from_command_line()
1716 if (parameters->options().any_undefined())
1718 if (parameters->target().get_size() == 32)
1720 #if defined(HAVE_TARGET_32_LITTL) || defined(HAVE_TARGET_32_BIG)
1721 this->do_add_undefined_symbols_from_command_line<32>();
1726 else if (parameters->target().get_size() == 64)
1728 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1729 this->do_add_undefined_symbols_from_command_line<64>();
1741 Symbol_table::do_add_undefined_symbols_from_command_line()
1743 for (options::String_set::const_iterator p =
1744 parameters->options().undefined_begin();
1745 p != parameters->options().undefined_end();
1748 const char* name = p->c_str();
1750 if (this->lookup(name) != NULL)
1753 const char* version = NULL;
1755 Sized_symbol<size>* sym;
1756 Sized_symbol<size>* oldsym;
1757 if (parameters->target().is_big_endian())
1759 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1760 sym = this->define_special_symbol<size, true>(&name, &version,
1768 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1769 sym = this->define_special_symbol<size, false>(&name, &version,
1776 gold_assert(oldsym == NULL);
1778 sym->init_undefined(name, elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL,
1779 elfcpp::STV_DEFAULT, 0);
1780 ++this->saw_undefined_;
1784 // Set the dynamic symbol indexes. INDEX is the index of the first
1785 // global dynamic symbol. Pointers to the symbols are stored into the
1786 // vector SYMS. The names are added to DYNPOOL. This returns an
1787 // updated dynamic symbol index.
1790 Symbol_table::set_dynsym_indexes(unsigned int index,
1791 std::vector<Symbol*>* syms,
1792 Stringpool* dynpool,
1795 for (Symbol_table_type::iterator p = this->table_.begin();
1796 p != this->table_.end();
1799 Symbol* sym = p->second;
1801 // Note that SYM may already have a dynamic symbol index, since
1802 // some symbols appear more than once in the symbol table, with
1803 // and without a version.
1805 if (!sym->should_add_dynsym_entry())
1806 sym->set_dynsym_index(-1U);
1807 else if (!sym->has_dynsym_index())
1809 sym->set_dynsym_index(index);
1811 syms->push_back(sym);
1812 dynpool->add(sym->name(), false, NULL);
1814 // Record any version information.
1815 if (sym->version() != NULL)
1816 versions->record_version(this, dynpool, sym);
1820 // Finish up the versions. In some cases this may add new dynamic
1822 index = versions->finalize(this, index, syms);
1827 // Set the final values for all the symbols. The index of the first
1828 // global symbol in the output file is *PLOCAL_SYMCOUNT. Record the
1829 // file offset OFF. Add their names to POOL. Return the new file
1830 // offset. Update *PLOCAL_SYMCOUNT if necessary.
1833 Symbol_table::finalize(off_t off, off_t dynoff, size_t dyn_global_index,
1834 size_t dyncount, Stringpool* pool,
1835 unsigned int *plocal_symcount)
1839 gold_assert(*plocal_symcount != 0);
1840 this->first_global_index_ = *plocal_symcount;
1842 this->dynamic_offset_ = dynoff;
1843 this->first_dynamic_global_index_ = dyn_global_index;
1844 this->dynamic_count_ = dyncount;
1846 if (parameters->target().get_size() == 32)
1848 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_32_LITTLE)
1849 ret = this->sized_finalize<32>(off, pool, plocal_symcount);
1854 else if (parameters->target().get_size() == 64)
1856 #if defined(HAVE_TARGET_64_BIG) || defined(HAVE_TARGET_64_LITTLE)
1857 ret = this->sized_finalize<64>(off, pool, plocal_symcount);
1865 // Now that we have the final symbol table, we can reliably note
1866 // which symbols should get warnings.
1867 this->warnings_.note_warnings(this);
1872 // SYM is going into the symbol table at *PINDEX. Add the name to
1873 // POOL, update *PINDEX and *POFF.
1877 Symbol_table::add_to_final_symtab(Symbol* sym, Stringpool* pool,
1878 unsigned int* pindex, off_t* poff)
1880 sym->set_symtab_index(*pindex);
1881 pool->add(sym->name(), false, NULL);
1883 *poff += elfcpp::Elf_sizes<size>::sym_size;
1886 // Set the final value for all the symbols. This is called after
1887 // Layout::finalize, so all the output sections have their final
1892 Symbol_table::sized_finalize(off_t off, Stringpool* pool,
1893 unsigned int* plocal_symcount)
1895 off = align_address(off, size >> 3);
1896 this->offset_ = off;
1898 unsigned int index = *plocal_symcount;
1899 const unsigned int orig_index = index;
1901 // First do all the symbols which have been forced to be local, as
1902 // they must appear before all global symbols.
1903 for (Forced_locals::iterator p = this->forced_locals_.begin();
1904 p != this->forced_locals_.end();
1908 gold_assert(sym->is_forced_local());
1909 if (this->sized_finalize_symbol<size>(sym))
1911 this->add_to_final_symtab<size>(sym, pool, &index, &off);
1916 // Now do all the remaining symbols.
1917 for (Symbol_table_type::iterator p = this->table_.begin();
1918 p != this->table_.end();
1921 Symbol* sym = p->second;
1922 if (this->sized_finalize_symbol<size>(sym))
1923 this->add_to_final_symtab<size>(sym, pool, &index, &off);
1926 this->output_count_ = index - orig_index;
1931 // Finalize the symbol SYM. This returns true if the symbol should be
1932 // added to the symbol table, false otherwise.
1936 Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
1938 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(unsized_sym);
1940 // The default version of a symbol may appear twice in the symbol
1941 // table. We only need to finalize it once.
1942 if (sym->has_symtab_index())
1947 gold_assert(!sym->has_symtab_index());
1948 sym->set_symtab_index(-1U);
1949 gold_assert(sym->dynsym_index() == -1U);
1953 typename Sized_symbol<size>::Value_type value;
1955 switch (sym->source())
1957 case Symbol::FROM_OBJECT:
1960 unsigned int shndx = sym->shndx(&is_ordinary);
1962 // FIXME: We need some target specific support here.
1964 && shndx != elfcpp::SHN_ABS
1965 && shndx != elfcpp::SHN_COMMON)
1967 gold_error(_("%s: unsupported symbol section 0x%x"),
1968 sym->demangled_name().c_str(), shndx);
1969 shndx = elfcpp::SHN_UNDEF;
1972 Object* symobj = sym->object();
1973 if (symobj->is_dynamic())
1976 shndx = elfcpp::SHN_UNDEF;
1978 else if (shndx == elfcpp::SHN_UNDEF)
1980 else if (!is_ordinary
1981 && (shndx == elfcpp::SHN_ABS || shndx == elfcpp::SHN_COMMON))
1982 value = sym->value();
1985 Relobj* relobj = static_cast<Relobj*>(symobj);
1986 section_offset_type secoff;
1987 Output_section* os = relobj->output_section(shndx, &secoff);
1991 sym->set_symtab_index(-1U);
1992 gold_assert(sym->dynsym_index() == -1U);
1996 if (sym->type() == elfcpp::STT_TLS)
1997 value = sym->value() + os->tls_offset() + secoff;
1999 value = sym->value() + os->address() + secoff;
2004 case Symbol::IN_OUTPUT_DATA:
2006 Output_data* od = sym->output_data();
2007 value = sym->value();
2008 if (sym->type() != elfcpp::STT_TLS)
2009 value += od->address();
2012 Output_section* os = od->output_section();
2013 gold_assert(os != NULL);
2014 value += os->tls_offset() + (od->address() - os->address());
2016 if (sym->offset_is_from_end())
2017 value += od->data_size();
2021 case Symbol::IN_OUTPUT_SEGMENT:
2023 Output_segment* os = sym->output_segment();
2024 value = sym->value();
2025 if (sym->type() != elfcpp::STT_TLS)
2026 value += os->vaddr();
2027 switch (sym->offset_base())
2029 case Symbol::SEGMENT_START:
2031 case Symbol::SEGMENT_END:
2032 value += os->memsz();
2034 case Symbol::SEGMENT_BSS:
2035 value += os->filesz();
2043 case Symbol::IS_CONSTANT:
2044 value = sym->value();
2047 case Symbol::IS_UNDEFINED:
2055 sym->set_value(value);
2057 if (parameters->options().strip_all())
2059 sym->set_symtab_index(-1U);
2066 // Write out the global symbols.
2069 Symbol_table::write_globals(const Input_objects* input_objects,
2070 const Stringpool* sympool,
2071 const Stringpool* dynpool,
2072 Output_symtab_xindex* symtab_xindex,
2073 Output_symtab_xindex* dynsym_xindex,
2074 Output_file* of) const
2076 switch (parameters->size_and_endianness())
2078 #ifdef HAVE_TARGET_32_LITTLE
2079 case Parameters::TARGET_32_LITTLE:
2080 this->sized_write_globals<32, false>(input_objects, sympool,
2081 dynpool, symtab_xindex,
2085 #ifdef HAVE_TARGET_32_BIG
2086 case Parameters::TARGET_32_BIG:
2087 this->sized_write_globals<32, true>(input_objects, sympool,
2088 dynpool, symtab_xindex,
2092 #ifdef HAVE_TARGET_64_LITTLE
2093 case Parameters::TARGET_64_LITTLE:
2094 this->sized_write_globals<64, false>(input_objects, sympool,
2095 dynpool, symtab_xindex,
2099 #ifdef HAVE_TARGET_64_BIG
2100 case Parameters::TARGET_64_BIG:
2101 this->sized_write_globals<64, true>(input_objects, sympool,
2102 dynpool, symtab_xindex,
2111 // Write out the global symbols.
2113 template<int size, bool big_endian>
2115 Symbol_table::sized_write_globals(const Input_objects* input_objects,
2116 const Stringpool* sympool,
2117 const Stringpool* dynpool,
2118 Output_symtab_xindex* symtab_xindex,
2119 Output_symtab_xindex* dynsym_xindex,
2120 Output_file* of) const
2122 const Target& target = parameters->target();
2124 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
2126 const unsigned int output_count = this->output_count_;
2127 const section_size_type oview_size = output_count * sym_size;
2128 const unsigned int first_global_index = this->first_global_index_;
2129 unsigned char* psyms;
2130 if (this->offset_ == 0 || output_count == 0)
2133 psyms = of->get_output_view(this->offset_, oview_size);
2135 const unsigned int dynamic_count = this->dynamic_count_;
2136 const section_size_type dynamic_size = dynamic_count * sym_size;
2137 const unsigned int first_dynamic_global_index =
2138 this->first_dynamic_global_index_;
2139 unsigned char* dynamic_view;
2140 if (this->dynamic_offset_ == 0 || dynamic_count == 0)
2141 dynamic_view = NULL;
2143 dynamic_view = of->get_output_view(this->dynamic_offset_, dynamic_size);
2145 for (Symbol_table_type::const_iterator p = this->table_.begin();
2146 p != this->table_.end();
2149 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
2151 // Possibly warn about unresolved symbols in shared libraries.
2152 this->warn_about_undefined_dynobj_symbol(input_objects, sym);
2154 unsigned int sym_index = sym->symtab_index();
2155 unsigned int dynsym_index;
2156 if (dynamic_view == NULL)
2159 dynsym_index = sym->dynsym_index();
2161 if (sym_index == -1U && dynsym_index == -1U)
2163 // This symbol is not included in the output file.
2168 typename elfcpp::Elf_types<size>::Elf_Addr sym_value = sym->value();
2169 typename elfcpp::Elf_types<size>::Elf_Addr dynsym_value = sym_value;
2170 switch (sym->source())
2172 case Symbol::FROM_OBJECT:
2175 unsigned int in_shndx = sym->shndx(&is_ordinary);
2177 // FIXME: We need some target specific support here.
2179 && in_shndx != elfcpp::SHN_ABS
2180 && in_shndx != elfcpp::SHN_COMMON)
2182 gold_error(_("%s: unsupported symbol section 0x%x"),
2183 sym->demangled_name().c_str(), in_shndx);
2188 Object* symobj = sym->object();
2189 if (symobj->is_dynamic())
2191 if (sym->needs_dynsym_value())
2192 dynsym_value = target.dynsym_value(sym);
2193 shndx = elfcpp::SHN_UNDEF;
2195 else if (in_shndx == elfcpp::SHN_UNDEF
2197 && (in_shndx == elfcpp::SHN_ABS
2198 || in_shndx == elfcpp::SHN_COMMON)))
2202 Relobj* relobj = static_cast<Relobj*>(symobj);
2203 section_offset_type secoff;
2204 Output_section* os = relobj->output_section(in_shndx,
2206 gold_assert(os != NULL);
2207 shndx = os->out_shndx();
2209 if (shndx >= elfcpp::SHN_LORESERVE)
2211 if (sym_index != -1U)
2212 symtab_xindex->add(sym_index, shndx);
2213 if (dynsym_index != -1U)
2214 dynsym_xindex->add(dynsym_index, shndx);
2215 shndx = elfcpp::SHN_XINDEX;
2218 // In object files symbol values are section
2220 if (parameters->options().relocatable())
2221 sym_value -= os->address();
2227 case Symbol::IN_OUTPUT_DATA:
2228 shndx = sym->output_data()->out_shndx();
2229 if (shndx >= elfcpp::SHN_LORESERVE)
2231 if (sym_index != -1U)
2232 symtab_xindex->add(sym_index, shndx);
2233 if (dynsym_index != -1U)
2234 dynsym_xindex->add(dynsym_index, shndx);
2235 shndx = elfcpp::SHN_XINDEX;
2239 case Symbol::IN_OUTPUT_SEGMENT:
2240 shndx = elfcpp::SHN_ABS;
2243 case Symbol::IS_CONSTANT:
2244 shndx = elfcpp::SHN_ABS;
2247 case Symbol::IS_UNDEFINED:
2248 shndx = elfcpp::SHN_UNDEF;
2255 if (sym_index != -1U)
2257 sym_index -= first_global_index;
2258 gold_assert(sym_index < output_count);
2259 unsigned char* ps = psyms + (sym_index * sym_size);
2260 this->sized_write_symbol<size, big_endian>(sym, sym_value, shndx,
2264 if (dynsym_index != -1U)
2266 dynsym_index -= first_dynamic_global_index;
2267 gold_assert(dynsym_index < dynamic_count);
2268 unsigned char* pd = dynamic_view + (dynsym_index * sym_size);
2269 this->sized_write_symbol<size, big_endian>(sym, dynsym_value, shndx,
2274 of->write_output_view(this->offset_, oview_size, psyms);
2275 if (dynamic_view != NULL)
2276 of->write_output_view(this->dynamic_offset_, dynamic_size, dynamic_view);
2279 // Write out the symbol SYM, in section SHNDX, to P. POOL is the
2280 // strtab holding the name.
2282 template<int size, bool big_endian>
2284 Symbol_table::sized_write_symbol(
2285 Sized_symbol<size>* sym,
2286 typename elfcpp::Elf_types<size>::Elf_Addr value,
2288 const Stringpool* pool,
2289 unsigned char* p) const
2291 elfcpp::Sym_write<size, big_endian> osym(p);
2292 osym.put_st_name(pool->get_offset(sym->name()));
2293 osym.put_st_value(value);
2294 osym.put_st_size(sym->symsize());
2295 // A version script may have overridden the default binding.
2296 if (sym->is_forced_local())
2297 osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL, sym->type()));
2299 osym.put_st_info(elfcpp::elf_st_info(sym->binding(), sym->type()));
2300 osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), sym->nonvis()));
2301 osym.put_st_shndx(shndx);
2304 // Check for unresolved symbols in shared libraries. This is
2305 // controlled by the --allow-shlib-undefined option.
2307 // We only warn about libraries for which we have seen all the
2308 // DT_NEEDED entries. We don't try to track down DT_NEEDED entries
2309 // which were not seen in this link. If we didn't see a DT_NEEDED
2310 // entry, we aren't going to be able to reliably report whether the
2311 // symbol is undefined.
2313 // We also don't warn about libraries found in the system library
2314 // directory (the directory were we find libc.so); we assume that
2315 // those libraries are OK. This heuristic avoids problems in
2316 // GNU/Linux, in which -ldl can have undefined references satisfied by
2320 Symbol_table::warn_about_undefined_dynobj_symbol(
2321 const Input_objects* input_objects,
2325 if (sym->source() == Symbol::FROM_OBJECT
2326 && sym->object()->is_dynamic()
2327 && sym->shndx(&dummy) == elfcpp::SHN_UNDEF
2328 && sym->binding() != elfcpp::STB_WEAK
2329 && !parameters->options().allow_shlib_undefined()
2330 && !parameters->target().is_defined_by_abi(sym)
2331 && !input_objects->found_in_system_library_directory(sym->object()))
2333 // A very ugly cast.
2334 Dynobj* dynobj = static_cast<Dynobj*>(sym->object());
2335 if (!dynobj->has_unknown_needed_entries())
2336 gold_error(_("%s: undefined reference to '%s'"),
2337 sym->object()->name().c_str(),
2338 sym->demangled_name().c_str());
2342 // Write out a section symbol. Return the update offset.
2345 Symbol_table::write_section_symbol(const Output_section *os,
2346 Output_symtab_xindex* symtab_xindex,
2350 switch (parameters->size_and_endianness())
2352 #ifdef HAVE_TARGET_32_LITTLE
2353 case Parameters::TARGET_32_LITTLE:
2354 this->sized_write_section_symbol<32, false>(os, symtab_xindex, of,
2358 #ifdef HAVE_TARGET_32_BIG
2359 case Parameters::TARGET_32_BIG:
2360 this->sized_write_section_symbol<32, true>(os, symtab_xindex, of,
2364 #ifdef HAVE_TARGET_64_LITTLE
2365 case Parameters::TARGET_64_LITTLE:
2366 this->sized_write_section_symbol<64, false>(os, symtab_xindex, of,
2370 #ifdef HAVE_TARGET_64_BIG
2371 case Parameters::TARGET_64_BIG:
2372 this->sized_write_section_symbol<64, true>(os, symtab_xindex, of,
2381 // Write out a section symbol, specialized for size and endianness.
2383 template<int size, bool big_endian>
2385 Symbol_table::sized_write_section_symbol(const Output_section* os,
2386 Output_symtab_xindex* symtab_xindex,
2390 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
2392 unsigned char* pov = of->get_output_view(offset, sym_size);
2394 elfcpp::Sym_write<size, big_endian> osym(pov);
2395 osym.put_st_name(0);
2396 osym.put_st_value(os->address());
2397 osym.put_st_size(0);
2398 osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL,
2399 elfcpp::STT_SECTION));
2400 osym.put_st_other(elfcpp::elf_st_other(elfcpp::STV_DEFAULT, 0));
2402 unsigned int shndx = os->out_shndx();
2403 if (shndx >= elfcpp::SHN_LORESERVE)
2405 symtab_xindex->add(os->symtab_index(), shndx);
2406 shndx = elfcpp::SHN_XINDEX;
2408 osym.put_st_shndx(shndx);
2410 of->write_output_view(offset, sym_size, pov);
2413 // Print statistical information to stderr. This is used for --stats.
2416 Symbol_table::print_stats() const
2418 #if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_EXT_HASH_MAP)
2419 fprintf(stderr, _("%s: symbol table entries: %zu; buckets: %zu\n"),
2420 program_name, this->table_.size(), this->table_.bucket_count());
2422 fprintf(stderr, _("%s: symbol table entries: %zu\n"),
2423 program_name, this->table_.size());
2425 this->namepool_.print_stats("symbol table stringpool");
2428 // We check for ODR violations by looking for symbols with the same
2429 // name for which the debugging information reports that they were
2430 // defined in different source locations. When comparing the source
2431 // location, we consider instances with the same base filename and
2432 // line number to be the same. This is because different object
2433 // files/shared libraries can include the same header file using
2434 // different paths, and we don't want to report an ODR violation in
2437 // This struct is used to compare line information, as returned by
2438 // Dwarf_line_info::one_addr2line. It implements a < comparison
2439 // operator used with std::set.
2441 struct Odr_violation_compare
2444 operator()(const std::string& s1, const std::string& s2) const
2446 std::string::size_type pos1 = s1.rfind('/');
2447 std::string::size_type pos2 = s2.rfind('/');
2448 if (pos1 == std::string::npos
2449 || pos2 == std::string::npos)
2451 return s1.compare(pos1, std::string::npos,
2452 s2, pos2, std::string::npos) < 0;
2456 // Check candidate_odr_violations_ to find symbols with the same name
2457 // but apparently different definitions (different source-file/line-no).
2460 Symbol_table::detect_odr_violations(const Task* task,
2461 const char* output_file_name) const
2463 for (Odr_map::const_iterator it = candidate_odr_violations_.begin();
2464 it != candidate_odr_violations_.end();
2467 const char* symbol_name = it->first;
2468 // We use a sorted set so the output is deterministic.
2469 std::set<std::string, Odr_violation_compare> line_nums;
2471 for (Unordered_set<Symbol_location, Symbol_location_hash>::const_iterator
2472 locs = it->second.begin();
2473 locs != it->second.end();
2476 // We need to lock the object in order to read it. This
2477 // means that we have to run in a singleton Task. If we
2478 // want to run this in a general Task for better
2479 // performance, we will need one Task for object, plus
2480 // appropriate locking to ensure that we don't conflict with
2481 // other uses of the object. Also note, one_addr2line is not
2482 // currently thread-safe.
2483 Task_lock_obj<Object> tl(task, locs->object);
2484 // 16 is the size of the object-cache that one_addr2line should use.
2485 std::string lineno = Dwarf_line_info::one_addr2line(
2486 locs->object, locs->shndx, locs->offset, 16);
2487 if (!lineno.empty())
2488 line_nums.insert(lineno);
2491 if (line_nums.size() > 1)
2493 gold_warning(_("while linking %s: symbol '%s' defined in multiple "
2494 "places (possible ODR violation):"),
2495 output_file_name, demangle(symbol_name).c_str());
2496 for (std::set<std::string>::const_iterator it2 = line_nums.begin();
2497 it2 != line_nums.end();
2499 fprintf(stderr, " %s\n", it2->c_str());
2502 // We only call one_addr2line() in this function, so we can clear its cache.
2503 Dwarf_line_info::clear_addr2line_cache();
2506 // Warnings functions.
2508 // Add a new warning.
2511 Warnings::add_warning(Symbol_table* symtab, const char* name, Object* obj,
2512 const std::string& warning)
2514 name = symtab->canonicalize_name(name);
2515 this->warnings_[name].set(obj, warning);
2518 // Look through the warnings and mark the symbols for which we should
2519 // warn. This is called during Layout::finalize when we know the
2520 // sources for all the symbols.
2523 Warnings::note_warnings(Symbol_table* symtab)
2525 for (Warning_table::iterator p = this->warnings_.begin();
2526 p != this->warnings_.end();
2529 Symbol* sym = symtab->lookup(p->first, NULL);
2531 && sym->source() == Symbol::FROM_OBJECT
2532 && sym->object() == p->second.object)
2533 sym->set_has_warning();
2537 // Issue a warning. This is called when we see a relocation against a
2538 // symbol for which has a warning.
2540 template<int size, bool big_endian>
2542 Warnings::issue_warning(const Symbol* sym,
2543 const Relocate_info<size, big_endian>* relinfo,
2544 size_t relnum, off_t reloffset) const
2546 gold_assert(sym->has_warning());
2547 Warning_table::const_iterator p = this->warnings_.find(sym->name());
2548 gold_assert(p != this->warnings_.end());
2549 gold_warning_at_location(relinfo, relnum, reloffset,
2550 "%s", p->second.text.c_str());
2553 // Instantiate the templates we need. We could use the configure
2554 // script to restrict this to only the ones needed for implemented
2557 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
2560 Sized_symbol<32>::allocate_common(Output_data*, Value_type);
2563 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
2566 Sized_symbol<64>::allocate_common(Output_data*, Value_type);
2569 #ifdef HAVE_TARGET_32_LITTLE
2572 Symbol_table::add_from_relobj<32, false>(
2573 Sized_relobj<32, false>* relobj,
2574 const unsigned char* syms,
2576 size_t symndx_offset,
2577 const char* sym_names,
2578 size_t sym_name_size,
2579 Sized_relobj<32, true>::Symbols* sympointers);
2582 #ifdef HAVE_TARGET_32_BIG
2585 Symbol_table::add_from_relobj<32, true>(
2586 Sized_relobj<32, true>* relobj,
2587 const unsigned char* syms,
2589 size_t symndx_offset,
2590 const char* sym_names,
2591 size_t sym_name_size,
2592 Sized_relobj<32, false>::Symbols* sympointers);
2595 #ifdef HAVE_TARGET_64_LITTLE
2598 Symbol_table::add_from_relobj<64, false>(
2599 Sized_relobj<64, false>* relobj,
2600 const unsigned char* syms,
2602 size_t symndx_offset,
2603 const char* sym_names,
2604 size_t sym_name_size,
2605 Sized_relobj<64, true>::Symbols* sympointers);
2608 #ifdef HAVE_TARGET_64_BIG
2611 Symbol_table::add_from_relobj<64, true>(
2612 Sized_relobj<64, true>* relobj,
2613 const unsigned char* syms,
2615 size_t symndx_offset,
2616 const char* sym_names,
2617 size_t sym_name_size,
2618 Sized_relobj<64, false>::Symbols* sympointers);
2621 #ifdef HAVE_TARGET_32_LITTLE
2624 Symbol_table::add_from_dynobj<32, false>(
2625 Sized_dynobj<32, false>* dynobj,
2626 const unsigned char* syms,
2628 const char* sym_names,
2629 size_t sym_name_size,
2630 const unsigned char* versym,
2632 const std::vector<const char*>* version_map);
2635 #ifdef HAVE_TARGET_32_BIG
2638 Symbol_table::add_from_dynobj<32, true>(
2639 Sized_dynobj<32, true>* dynobj,
2640 const unsigned char* syms,
2642 const char* sym_names,
2643 size_t sym_name_size,
2644 const unsigned char* versym,
2646 const std::vector<const char*>* version_map);
2649 #ifdef HAVE_TARGET_64_LITTLE
2652 Symbol_table::add_from_dynobj<64, false>(
2653 Sized_dynobj<64, false>* dynobj,
2654 const unsigned char* syms,
2656 const char* sym_names,
2657 size_t sym_name_size,
2658 const unsigned char* versym,
2660 const std::vector<const char*>* version_map);
2663 #ifdef HAVE_TARGET_64_BIG
2666 Symbol_table::add_from_dynobj<64, true>(
2667 Sized_dynobj<64, true>* dynobj,
2668 const unsigned char* syms,
2670 const char* sym_names,
2671 size_t sym_name_size,
2672 const unsigned char* versym,
2674 const std::vector<const char*>* version_map);
2677 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
2680 Symbol_table::define_with_copy_reloc<32>(
2681 Sized_symbol<32>* sym,
2683 elfcpp::Elf_types<32>::Elf_Addr value);
2686 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
2689 Symbol_table::define_with_copy_reloc<64>(
2690 Sized_symbol<64>* sym,
2692 elfcpp::Elf_types<64>::Elf_Addr value);
2695 #ifdef HAVE_TARGET_32_LITTLE
2698 Warnings::issue_warning<32, false>(const Symbol* sym,
2699 const Relocate_info<32, false>* relinfo,
2700 size_t relnum, off_t reloffset) const;
2703 #ifdef HAVE_TARGET_32_BIG
2706 Warnings::issue_warning<32, true>(const Symbol* sym,
2707 const Relocate_info<32, true>* relinfo,
2708 size_t relnum, off_t reloffset) const;
2711 #ifdef HAVE_TARGET_64_LITTLE
2714 Warnings::issue_warning<64, false>(const Symbol* sym,
2715 const Relocate_info<64, false>* relinfo,
2716 size_t relnum, off_t reloffset) const;
2719 #ifdef HAVE_TARGET_64_BIG
2722 Warnings::issue_warning<64, true>(const Symbol* sym,
2723 const Relocate_info<64, true>* relinfo,
2724 size_t relnum, off_t reloffset) const;
2727 } // End namespace gold.