1 // symtab.cc -- the gold symbol table
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
33 #include "workqueue.h"
41 // Initialize fields in Symbol. This initializes everything except u_
45 Symbol::init_fields(const char* name, const char* version,
46 elfcpp::STT type, elfcpp::STB binding,
47 elfcpp::STV visibility, unsigned char nonvis)
50 this->version_ = version;
51 this->symtab_index_ = 0;
52 this->dynsym_index_ = 0;
53 this->got_offset_ = 0;
54 this->plt_offset_ = 0;
56 this->binding_ = binding;
57 this->visibility_ = visibility;
58 this->nonvis_ = nonvis;
59 this->is_target_special_ = false;
60 this->is_def_ = false;
61 this->is_forwarder_ = false;
62 this->has_alias_ = false;
63 this->needs_dynsym_entry_ = false;
64 this->in_reg_ = false;
65 this->in_dyn_ = false;
66 this->has_got_offset_ = false;
67 this->has_plt_offset_ = false;
68 this->has_warning_ = false;
69 this->is_copied_from_dynobj_ = false;
72 // Initialize the fields in the base class Symbol for SYM in OBJECT.
74 template<int size, bool big_endian>
76 Symbol::init_base(const char* name, const char* version, Object* object,
77 const elfcpp::Sym<size, big_endian>& sym)
79 this->init_fields(name, version, sym.get_st_type(), sym.get_st_bind(),
80 sym.get_st_visibility(), sym.get_st_nonvis());
81 this->u_.from_object.object = object;
82 // FIXME: Handle SHN_XINDEX.
83 this->u_.from_object.shndx = sym.get_st_shndx();
84 this->source_ = FROM_OBJECT;
85 this->in_reg_ = !object->is_dynamic();
86 this->in_dyn_ = object->is_dynamic();
89 // Initialize the fields in the base class Symbol for a symbol defined
93 Symbol::init_base(const char* name, Output_data* od, elfcpp::STT type,
94 elfcpp::STB binding, elfcpp::STV visibility,
95 unsigned char nonvis, bool offset_is_from_end)
97 this->init_fields(name, NULL, type, binding, visibility, nonvis);
98 this->u_.in_output_data.output_data = od;
99 this->u_.in_output_data.offset_is_from_end = offset_is_from_end;
100 this->source_ = IN_OUTPUT_DATA;
101 this->in_reg_ = true;
104 // Initialize the fields in the base class Symbol for a symbol defined
105 // in an Output_segment.
108 Symbol::init_base(const char* name, Output_segment* os, elfcpp::STT type,
109 elfcpp::STB binding, elfcpp::STV visibility,
110 unsigned char nonvis, Segment_offset_base offset_base)
112 this->init_fields(name, NULL, type, binding, visibility, nonvis);
113 this->u_.in_output_segment.output_segment = os;
114 this->u_.in_output_segment.offset_base = offset_base;
115 this->source_ = IN_OUTPUT_SEGMENT;
116 this->in_reg_ = true;
119 // Initialize the fields in the base class Symbol for a symbol defined
123 Symbol::init_base(const char* name, elfcpp::STT type,
124 elfcpp::STB binding, elfcpp::STV visibility,
125 unsigned char nonvis)
127 this->init_fields(name, NULL, type, binding, visibility, nonvis);
128 this->source_ = CONSTANT;
129 this->in_reg_ = true;
132 // Initialize the fields in Sized_symbol for SYM in OBJECT.
135 template<bool big_endian>
137 Sized_symbol<size>::init(const char* name, const char* version, Object* object,
138 const elfcpp::Sym<size, big_endian>& sym)
140 this->init_base(name, version, object, sym);
141 this->value_ = sym.get_st_value();
142 this->symsize_ = sym.get_st_size();
145 // Initialize the fields in Sized_symbol for a symbol defined in an
150 Sized_symbol<size>::init(const char* name, Output_data* od,
151 Value_type value, Size_type symsize,
152 elfcpp::STT type, elfcpp::STB binding,
153 elfcpp::STV visibility, unsigned char nonvis,
154 bool offset_is_from_end)
156 this->init_base(name, od, type, binding, visibility, nonvis,
158 this->value_ = value;
159 this->symsize_ = symsize;
162 // Initialize the fields in Sized_symbol for a symbol defined in an
167 Sized_symbol<size>::init(const char* name, Output_segment* os,
168 Value_type value, Size_type symsize,
169 elfcpp::STT type, elfcpp::STB binding,
170 elfcpp::STV visibility, unsigned char nonvis,
171 Segment_offset_base offset_base)
173 this->init_base(name, os, type, binding, visibility, nonvis, offset_base);
174 this->value_ = value;
175 this->symsize_ = symsize;
178 // Initialize the fields in Sized_symbol for a symbol defined as a
183 Sized_symbol<size>::init(const char* name, Value_type value, Size_type symsize,
184 elfcpp::STT type, elfcpp::STB binding,
185 elfcpp::STV visibility, unsigned char nonvis)
187 this->init_base(name, type, binding, visibility, nonvis);
188 this->value_ = value;
189 this->symsize_ = symsize;
192 // Return true if this symbol should be added to the dynamic symbol
196 Symbol::should_add_dynsym_entry() const
198 // If the symbol is used by a dynamic relocation, we need to add it.
199 if (this->needs_dynsym_entry())
202 // If exporting all symbols or building a shared library,
203 // and the symbol is defined in a regular object and is
204 // externally visible, we need to add it.
205 if ((parameters->export_dynamic() || parameters->output_is_shared())
206 && !this->is_from_dynobj()
207 && this->is_externally_visible())
213 // Return true if the final value of this symbol is known at link
217 Symbol::final_value_is_known() const
219 // If we are not generating an executable, then no final values are
220 // known, since they will change at runtime.
221 if (!parameters->output_is_executable())
224 // If the symbol is not from an object file, then it is defined, and
226 if (this->source_ != FROM_OBJECT)
229 // If the symbol is from a dynamic object, then the final value is
231 if (this->object()->is_dynamic())
234 // If the symbol is not undefined (it is defined or common), then
235 // the final value is known.
236 if (!this->is_undefined())
239 // If the symbol is undefined, then whether the final value is known
240 // depends on whether we are doing a static link. If we are doing a
241 // dynamic link, then the final value could be filled in at runtime.
242 // This could reasonably be the case for a weak undefined symbol.
243 return parameters->doing_static_link();
246 // Class Symbol_table.
248 Symbol_table::Symbol_table()
249 : saw_undefined_(0), offset_(0), table_(), namepool_(),
250 forwarders_(), commons_(), warnings_()
254 Symbol_table::~Symbol_table()
258 // The hash function. The key is always canonicalized, so we use a
259 // simple combination of the pointers.
262 Symbol_table::Symbol_table_hash::operator()(const Symbol_table_key& key) const
264 return key.first ^ key.second;
267 // The symbol table key equality function. This is only called with
268 // canonicalized name and version strings, so we can use pointer
272 Symbol_table::Symbol_table_eq::operator()(const Symbol_table_key& k1,
273 const Symbol_table_key& k2) const
275 return k1.first == k2.first && k1.second == k2.second;
278 // Make TO a symbol which forwards to FROM.
281 Symbol_table::make_forwarder(Symbol* from, Symbol* to)
283 gold_assert(from != to);
284 gold_assert(!from->is_forwarder() && !to->is_forwarder());
285 this->forwarders_[from] = to;
286 from->set_forwarder();
289 // Resolve the forwards from FROM, returning the real symbol.
292 Symbol_table::resolve_forwards(const Symbol* from) const
294 gold_assert(from->is_forwarder());
295 Unordered_map<const Symbol*, Symbol*>::const_iterator p =
296 this->forwarders_.find(from);
297 gold_assert(p != this->forwarders_.end());
301 // Look up a symbol by name.
304 Symbol_table::lookup(const char* name, const char* version) const
306 Stringpool::Key name_key;
307 name = this->namepool_.find(name, &name_key);
311 Stringpool::Key version_key = 0;
314 version = this->namepool_.find(version, &version_key);
319 Symbol_table_key key(name_key, version_key);
320 Symbol_table::Symbol_table_type::const_iterator p = this->table_.find(key);
321 if (p == this->table_.end())
326 // Resolve a Symbol with another Symbol. This is only used in the
327 // unusual case where there are references to both an unversioned
328 // symbol and a symbol with a version, and we then discover that that
329 // version is the default version. Because this is unusual, we do
330 // this the slow way, by converting back to an ELF symbol.
332 template<int size, bool big_endian>
334 Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
335 const char* version ACCEPT_SIZE_ENDIAN)
337 unsigned char buf[elfcpp::Elf_sizes<size>::sym_size];
338 elfcpp::Sym_write<size, big_endian> esym(buf);
339 // We don't bother to set the st_name field.
340 esym.put_st_value(from->value());
341 esym.put_st_size(from->symsize());
342 esym.put_st_info(from->binding(), from->type());
343 esym.put_st_other(from->visibility(), from->nonvis());
344 esym.put_st_shndx(from->shndx());
345 this->resolve(to, esym.sym(), from->object(), version);
352 // Add one symbol from OBJECT to the symbol table. NAME is symbol
353 // name and VERSION is the version; both are canonicalized. DEF is
354 // whether this is the default version.
356 // If DEF is true, then this is the definition of a default version of
357 // a symbol. That means that any lookup of NAME/NULL and any lookup
358 // of NAME/VERSION should always return the same symbol. This is
359 // obvious for references, but in particular we want to do this for
360 // definitions: overriding NAME/NULL should also override
361 // NAME/VERSION. If we don't do that, it would be very hard to
362 // override functions in a shared library which uses versioning.
364 // We implement this by simply making both entries in the hash table
365 // point to the same Symbol structure. That is easy enough if this is
366 // the first time we see NAME/NULL or NAME/VERSION, but it is possible
367 // that we have seen both already, in which case they will both have
368 // independent entries in the symbol table. We can't simply change
369 // the symbol table entry, because we have pointers to the entries
370 // attached to the object files. So we mark the entry attached to the
371 // object file as a forwarder, and record it in the forwarders_ map.
372 // Note that entries in the hash table will never be marked as
375 template<int size, bool big_endian>
377 Symbol_table::add_from_object(Object* object,
379 Stringpool::Key name_key,
381 Stringpool::Key version_key,
383 const elfcpp::Sym<size, big_endian>& sym)
385 Symbol* const snull = NULL;
386 std::pair<typename Symbol_table_type::iterator, bool> ins =
387 this->table_.insert(std::make_pair(std::make_pair(name_key, version_key),
390 std::pair<typename Symbol_table_type::iterator, bool> insdef =
391 std::make_pair(this->table_.end(), false);
394 const Stringpool::Key vnull_key = 0;
395 insdef = this->table_.insert(std::make_pair(std::make_pair(name_key,
400 // ins.first: an iterator, which is a pointer to a pair.
401 // ins.first->first: the key (a pair of name and version).
402 // ins.first->second: the value (Symbol*).
403 // ins.second: true if new entry was inserted, false if not.
405 Sized_symbol<size>* ret;
410 // We already have an entry for NAME/VERSION.
411 ret = this->get_sized_symbol SELECT_SIZE_NAME(size) (ins.first->second
413 gold_assert(ret != NULL);
415 was_undefined = ret->is_undefined();
416 was_common = ret->is_common();
418 this->resolve(ret, sym, object, version);
424 // This is the first time we have seen NAME/NULL. Make
425 // NAME/NULL point to NAME/VERSION.
426 insdef.first->second = ret;
428 else if (insdef.first->second != ret)
430 // This is the unfortunate case where we already have
431 // entries for both NAME/VERSION and NAME/NULL.
432 const Sized_symbol<size>* sym2;
433 sym2 = this->get_sized_symbol SELECT_SIZE_NAME(size) (
436 Symbol_table::resolve SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
437 ret, sym2, version SELECT_SIZE_ENDIAN(size, big_endian));
438 this->make_forwarder(insdef.first->second, ret);
439 insdef.first->second = ret;
445 // This is the first time we have seen NAME/VERSION.
446 gold_assert(ins.first->second == NULL);
448 was_undefined = false;
451 if (def && !insdef.second)
453 // We already have an entry for NAME/NULL. If we override
454 // it, then change it to NAME/VERSION.
455 ret = this->get_sized_symbol SELECT_SIZE_NAME(size) (
458 this->resolve(ret, sym, object, version);
459 ins.first->second = ret;
463 Sized_target<size, big_endian>* target =
464 object->sized_target SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
465 SELECT_SIZE_ENDIAN_ONLY(size, big_endian));
466 if (!target->has_make_symbol())
467 ret = new Sized_symbol<size>();
470 ret = target->make_symbol();
473 // This means that we don't want a symbol table
476 this->table_.erase(ins.first);
479 this->table_.erase(insdef.first);
480 // Inserting insdef invalidated ins.
481 this->table_.erase(std::make_pair(name_key,
488 ret->init(name, version, object, sym);
490 ins.first->second = ret;
493 // This is the first time we have seen NAME/NULL. Point
494 // it at the new entry for NAME/VERSION.
495 gold_assert(insdef.second);
496 insdef.first->second = ret;
501 // Record every time we see a new undefined symbol, to speed up
503 if (!was_undefined && ret->is_undefined())
504 ++this->saw_undefined_;
506 // Keep track of common symbols, to speed up common symbol
508 if (!was_common && ret->is_common())
509 this->commons_.push_back(ret);
514 // Add all the symbols in a relocatable object to the hash table.
516 template<int size, bool big_endian>
518 Symbol_table::add_from_relobj(
519 Sized_relobj<size, big_endian>* relobj,
520 const unsigned char* syms,
522 const char* sym_names,
523 size_t sym_name_size,
524 Symbol** sympointers)
526 gold_assert(size == relobj->target()->get_size());
527 gold_assert(size == parameters->get_size());
529 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
531 const unsigned char* p = syms;
532 for (size_t i = 0; i < count; ++i, p += sym_size)
534 elfcpp::Sym<size, big_endian> sym(p);
535 elfcpp::Sym<size, big_endian>* psym = &sym;
537 unsigned int st_name = psym->get_st_name();
538 if (st_name >= sym_name_size)
540 relobj->error(_("bad global symbol name offset %u at %zu"),
545 const char* name = sym_names + st_name;
547 // A symbol defined in a section which we are not including must
548 // be treated as an undefined symbol.
549 unsigned char symbuf[sym_size];
550 elfcpp::Sym<size, big_endian> sym2(symbuf);
551 unsigned int st_shndx = psym->get_st_shndx();
552 if (st_shndx != elfcpp::SHN_UNDEF
553 && st_shndx < elfcpp::SHN_LORESERVE
554 && !relobj->is_section_included(st_shndx))
556 memcpy(symbuf, p, sym_size);
557 elfcpp::Sym_write<size, big_endian> sw(symbuf);
558 sw.put_st_shndx(elfcpp::SHN_UNDEF);
562 // In an object file, an '@' in the name separates the symbol
563 // name from the version name. If there are two '@' characters,
564 // this is the default version.
565 const char* ver = strchr(name, '@');
567 Sized_symbol<size>* res;
570 Stringpool::Key name_key;
571 name = this->namepool_.add(name, true, &name_key);
572 res = this->add_from_object(relobj, name, name_key, NULL, 0,
577 Stringpool::Key name_key;
578 name = this->namepool_.add_prefix(name, ver - name, &name_key);
588 Stringpool::Key ver_key;
589 ver = this->namepool_.add(ver, true, &ver_key);
591 res = this->add_from_object(relobj, name, name_key, ver, ver_key,
595 *sympointers++ = res;
599 // Add all the symbols in a dynamic object to the hash table.
601 template<int size, bool big_endian>
603 Symbol_table::add_from_dynobj(
604 Sized_dynobj<size, big_endian>* dynobj,
605 const unsigned char* syms,
607 const char* sym_names,
608 size_t sym_name_size,
609 const unsigned char* versym,
611 const std::vector<const char*>* version_map)
613 gold_assert(size == dynobj->target()->get_size());
614 gold_assert(size == parameters->get_size());
616 if (versym != NULL && versym_size / 2 < count)
618 dynobj->error(_("too few symbol versions"));
622 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
624 // We keep a list of all STT_OBJECT symbols, so that we can resolve
625 // weak aliases. This is necessary because if the dynamic object
626 // provides the same variable under two names, one of which is a
627 // weak definition, and the regular object refers to the weak
628 // definition, we have to put both the weak definition and the
629 // strong definition into the dynamic symbol table. Given a weak
630 // definition, the only way that we can find the corresponding
631 // strong definition, if any, is to search the symbol table.
632 std::vector<Sized_symbol<size>*> object_symbols;
634 const unsigned char* p = syms;
635 const unsigned char* vs = versym;
636 for (size_t i = 0; i < count; ++i, p += sym_size, vs += 2)
638 elfcpp::Sym<size, big_endian> sym(p);
640 // Ignore symbols with local binding.
641 if (sym.get_st_bind() == elfcpp::STB_LOCAL)
644 unsigned int st_name = sym.get_st_name();
645 if (st_name >= sym_name_size)
647 dynobj->error(_("bad symbol name offset %u at %zu"),
652 const char* name = sym_names + st_name;
654 Sized_symbol<size>* res;
658 Stringpool::Key name_key;
659 name = this->namepool_.add(name, true, &name_key);
660 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
665 // Read the version information.
667 unsigned int v = elfcpp::Swap<16, big_endian>::readval(vs);
669 bool hidden = (v & elfcpp::VERSYM_HIDDEN) != 0;
670 v &= elfcpp::VERSYM_VERSION;
672 // The Sun documentation says that V can be VER_NDX_LOCAL,
673 // or VER_NDX_GLOBAL, or a version index. The meaning of
674 // VER_NDX_LOCAL is defined as "Symbol has local scope."
675 // The old GNU linker will happily generate VER_NDX_LOCAL
676 // for an undefined symbol. I don't know what the Sun
677 // linker will generate.
679 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
680 && sym.get_st_shndx() != elfcpp::SHN_UNDEF)
682 // This symbol should not be visible outside the object.
686 // At this point we are definitely going to add this symbol.
687 Stringpool::Key name_key;
688 name = this->namepool_.add(name, true, &name_key);
690 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
691 || v == static_cast<unsigned int>(elfcpp::VER_NDX_GLOBAL))
693 // This symbol does not have a version.
694 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
699 if (v >= version_map->size())
701 dynobj->error(_("versym for symbol %zu out of range: %u"),
706 const char* version = (*version_map)[v];
709 dynobj->error(_("versym for symbol %zu has no name: %u"),
714 Stringpool::Key version_key;
715 version = this->namepool_.add(version, true, &version_key);
717 // If this is an absolute symbol, and the version name
718 // and symbol name are the same, then this is the
719 // version definition symbol. These symbols exist to
720 // support using -u to pull in particular versions. We
721 // do not want to record a version for them.
722 if (sym.get_st_shndx() == elfcpp::SHN_ABS
723 && name_key == version_key)
724 res = this->add_from_object(dynobj, name, name_key, NULL, 0,
728 const bool def = (!hidden
729 && (sym.get_st_shndx()
730 != elfcpp::SHN_UNDEF));
731 res = this->add_from_object(dynobj, name, name_key, version,
732 version_key, def, sym);
737 if (sym.get_st_shndx() != elfcpp::SHN_UNDEF
738 && sym.get_st_type() == elfcpp::STT_OBJECT)
739 object_symbols.push_back(res);
742 this->record_weak_aliases(&object_symbols);
745 // This is used to sort weak aliases. We sort them first by section
746 // index, then by offset, then by weak ahead of strong.
749 class Weak_alias_sorter
752 bool operator()(const Sized_symbol<size>*, const Sized_symbol<size>*) const;
757 Weak_alias_sorter<size>::operator()(const Sized_symbol<size>* s1,
758 const Sized_symbol<size>* s2) const
760 if (s1->shndx() != s2->shndx())
761 return s1->shndx() < s2->shndx();
762 if (s1->value() != s2->value())
763 return s1->value() < s2->value();
764 if (s1->binding() != s2->binding())
766 if (s1->binding() == elfcpp::STB_WEAK)
768 if (s2->binding() == elfcpp::STB_WEAK)
771 return std::string(s1->name()) < std::string(s2->name());
774 // SYMBOLS is a list of object symbols from a dynamic object. Look
775 // for any weak aliases, and record them so that if we add the weak
776 // alias to the dynamic symbol table, we also add the corresponding
781 Symbol_table::record_weak_aliases(std::vector<Sized_symbol<size>*>* symbols)
783 // Sort the vector by section index, then by offset, then by weak
785 std::sort(symbols->begin(), symbols->end(), Weak_alias_sorter<size>());
787 // Walk through the vector. For each weak definition, record
789 for (typename std::vector<Sized_symbol<size>*>::const_iterator p =
794 if ((*p)->binding() != elfcpp::STB_WEAK)
797 // Build a circular list of weak aliases. Each symbol points to
798 // the next one in the circular list.
800 Sized_symbol<size>* from_sym = *p;
801 typename std::vector<Sized_symbol<size>*>::const_iterator q;
802 for (q = p + 1; q != symbols->end(); ++q)
804 if ((*q)->shndx() != from_sym->shndx()
805 || (*q)->value() != from_sym->value())
808 this->weak_aliases_[from_sym] = *q;
809 from_sym->set_has_alias();
815 this->weak_aliases_[from_sym] = *p;
816 from_sym->set_has_alias();
823 // Create and return a specially defined symbol. If ONLY_IF_REF is
824 // true, then only create the symbol if there is a reference to it.
825 // If this does not return NULL, it sets *POLDSYM to the existing
826 // symbol if there is one. This canonicalizes *PNAME and *PVERSION.
828 template<int size, bool big_endian>
830 Symbol_table::define_special_symbol(const Target* target, const char** pname,
831 const char** pversion, bool only_if_ref,
832 Sized_symbol<size>** poldsym
836 Sized_symbol<size>* sym;
837 bool add_to_table = false;
838 typename Symbol_table_type::iterator add_loc = this->table_.end();
842 oldsym = this->lookup(*pname, *pversion);
843 if (oldsym == NULL || !oldsym->is_undefined())
846 *pname = oldsym->name();
847 *pversion = oldsym->version();
851 // Canonicalize NAME and VERSION.
852 Stringpool::Key name_key;
853 *pname = this->namepool_.add(*pname, true, &name_key);
855 Stringpool::Key version_key = 0;
856 if (*pversion != NULL)
857 *pversion = this->namepool_.add(*pversion, true, &version_key);
859 Symbol* const snull = NULL;
860 std::pair<typename Symbol_table_type::iterator, bool> ins =
861 this->table_.insert(std::make_pair(std::make_pair(name_key,
867 // We already have a symbol table entry for NAME/VERSION.
868 oldsym = ins.first->second;
869 gold_assert(oldsym != NULL);
873 // We haven't seen this symbol before.
874 gold_assert(ins.first->second == NULL);
881 if (!target->has_make_symbol())
882 sym = new Sized_symbol<size>();
885 gold_assert(target->get_size() == size);
886 gold_assert(target->is_big_endian() ? big_endian : !big_endian);
887 typedef Sized_target<size, big_endian> My_target;
888 const My_target* sized_target =
889 static_cast<const My_target*>(target);
890 sym = sized_target->make_symbol();
896 add_loc->second = sym;
898 gold_assert(oldsym != NULL);
900 *poldsym = this->get_sized_symbol SELECT_SIZE_NAME(size) (oldsym
906 // Define a symbol based on an Output_data.
909 Symbol_table::define_in_output_data(const Target* target, const char* name,
910 const char* version, Output_data* od,
911 uint64_t value, uint64_t symsize,
912 elfcpp::STT type, elfcpp::STB binding,
913 elfcpp::STV visibility,
914 unsigned char nonvis,
915 bool offset_is_from_end,
918 if (parameters->get_size() == 32)
920 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
921 return this->do_define_in_output_data<32>(target, name, version, od,
922 value, symsize, type, binding,
930 else if (parameters->get_size() == 64)
932 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
933 return this->do_define_in_output_data<64>(target, name, version, od,
934 value, symsize, type, binding,
946 // Define a symbol in an Output_data, sized version.
950 Symbol_table::do_define_in_output_data(
951 const Target* target,
955 typename elfcpp::Elf_types<size>::Elf_Addr value,
956 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
959 elfcpp::STV visibility,
960 unsigned char nonvis,
961 bool offset_is_from_end,
964 Sized_symbol<size>* sym;
965 Sized_symbol<size>* oldsym;
967 if (parameters->is_big_endian())
969 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
970 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
971 target, &name, &version, only_if_ref, &oldsym
972 SELECT_SIZE_ENDIAN(size, true));
979 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
980 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
981 target, &name, &version, only_if_ref, &oldsym
982 SELECT_SIZE_ENDIAN(size, false));
991 gold_assert(version == NULL || oldsym != NULL);
992 sym->init(name, od, value, symsize, type, binding, visibility, nonvis,
996 && Symbol_table::should_override_with_special(oldsym))
997 this->override_with_special(oldsym, sym);
1002 // Define a symbol based on an Output_segment.
1005 Symbol_table::define_in_output_segment(const Target* target, const char* name,
1006 const char* version, Output_segment* os,
1007 uint64_t value, uint64_t symsize,
1008 elfcpp::STT type, elfcpp::STB binding,
1009 elfcpp::STV visibility,
1010 unsigned char nonvis,
1011 Symbol::Segment_offset_base offset_base,
1014 if (parameters->get_size() == 32)
1016 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1017 return this->do_define_in_output_segment<32>(target, name, version, os,
1018 value, symsize, type,
1019 binding, visibility, nonvis,
1020 offset_base, only_if_ref);
1025 else if (parameters->get_size() == 64)
1027 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1028 return this->do_define_in_output_segment<64>(target, name, version, os,
1029 value, symsize, type,
1030 binding, visibility, nonvis,
1031 offset_base, only_if_ref);
1040 // Define a symbol in an Output_segment, sized version.
1044 Symbol_table::do_define_in_output_segment(
1045 const Target* target,
1047 const char* version,
1049 typename elfcpp::Elf_types<size>::Elf_Addr value,
1050 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
1052 elfcpp::STB binding,
1053 elfcpp::STV visibility,
1054 unsigned char nonvis,
1055 Symbol::Segment_offset_base offset_base,
1058 Sized_symbol<size>* sym;
1059 Sized_symbol<size>* oldsym;
1061 if (parameters->is_big_endian())
1063 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1064 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
1065 target, &name, &version, only_if_ref, &oldsym
1066 SELECT_SIZE_ENDIAN(size, true));
1073 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1074 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
1075 target, &name, &version, only_if_ref, &oldsym
1076 SELECT_SIZE_ENDIAN(size, false));
1085 gold_assert(version == NULL || oldsym != NULL);
1086 sym->init(name, os, value, symsize, type, binding, visibility, nonvis,
1090 && Symbol_table::should_override_with_special(oldsym))
1091 this->override_with_special(oldsym, sym);
1096 // Define a special symbol with a constant value. It is a multiple
1097 // definition error if this symbol is already defined.
1100 Symbol_table::define_as_constant(const Target* target, const char* name,
1101 const char* version, uint64_t value,
1102 uint64_t symsize, elfcpp::STT type,
1103 elfcpp::STB binding, elfcpp::STV visibility,
1104 unsigned char nonvis, bool only_if_ref)
1106 if (parameters->get_size() == 32)
1108 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1109 return this->do_define_as_constant<32>(target, name, version, value,
1110 symsize, type, binding,
1111 visibility, nonvis, only_if_ref);
1116 else if (parameters->get_size() == 64)
1118 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1119 return this->do_define_as_constant<64>(target, name, version, value,
1120 symsize, type, binding,
1121 visibility, nonvis, only_if_ref);
1130 // Define a symbol as a constant, sized version.
1134 Symbol_table::do_define_as_constant(
1135 const Target* target,
1137 const char* version,
1138 typename elfcpp::Elf_types<size>::Elf_Addr value,
1139 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
1141 elfcpp::STB binding,
1142 elfcpp::STV visibility,
1143 unsigned char nonvis,
1146 Sized_symbol<size>* sym;
1147 Sized_symbol<size>* oldsym;
1149 if (parameters->is_big_endian())
1151 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
1152 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
1153 target, &name, &version, only_if_ref, &oldsym
1154 SELECT_SIZE_ENDIAN(size, true));
1161 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
1162 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
1163 target, &name, &version, only_if_ref, &oldsym
1164 SELECT_SIZE_ENDIAN(size, false));
1173 gold_assert(version == NULL || oldsym != NULL);
1174 sym->init(name, value, symsize, type, binding, visibility, nonvis);
1177 && Symbol_table::should_override_with_special(oldsym))
1178 this->override_with_special(oldsym, sym);
1183 // Define a set of symbols in output sections.
1186 Symbol_table::define_symbols(const Layout* layout, const Target* target,
1187 int count, const Define_symbol_in_section* p)
1189 for (int i = 0; i < count; ++i, ++p)
1191 Output_section* os = layout->find_output_section(p->output_section);
1193 this->define_in_output_data(target, p->name, NULL, os, p->value,
1194 p->size, p->type, p->binding,
1195 p->visibility, p->nonvis,
1196 p->offset_is_from_end, p->only_if_ref);
1198 this->define_as_constant(target, p->name, NULL, 0, p->size, p->type,
1199 p->binding, p->visibility, p->nonvis,
1204 // Define a set of symbols in output segments.
1207 Symbol_table::define_symbols(const Layout* layout, const Target* target,
1208 int count, const Define_symbol_in_segment* p)
1210 for (int i = 0; i < count; ++i, ++p)
1212 Output_segment* os = layout->find_output_segment(p->segment_type,
1213 p->segment_flags_set,
1214 p->segment_flags_clear);
1216 this->define_in_output_segment(target, p->name, NULL, os, p->value,
1217 p->size, p->type, p->binding,
1218 p->visibility, p->nonvis,
1219 p->offset_base, p->only_if_ref);
1221 this->define_as_constant(target, p->name, NULL, 0, p->size, p->type,
1222 p->binding, p->visibility, p->nonvis,
1227 // Define CSYM using a COPY reloc. POSD is the Output_data where the
1228 // symbol should be defined--typically a .dyn.bss section. VALUE is
1229 // the offset within POSD.
1233 Symbol_table::define_with_copy_reloc(const Target* target,
1234 Sized_symbol<size>* csym,
1235 Output_data* posd, uint64_t value)
1237 gold_assert(csym->is_from_dynobj());
1238 gold_assert(!csym->is_copied_from_dynobj());
1239 Object* object = csym->object();
1240 gold_assert(object->is_dynamic());
1241 Dynobj* dynobj = static_cast<Dynobj*>(object);
1243 // Our copied variable has to override any variable in a shared
1245 elfcpp::STB binding = csym->binding();
1246 if (binding == elfcpp::STB_WEAK)
1247 binding = elfcpp::STB_GLOBAL;
1249 this->define_in_output_data(target, csym->name(), csym->version(),
1250 posd, value, csym->symsize(),
1251 csym->type(), binding,
1252 csym->visibility(), csym->nonvis(),
1255 csym->set_is_copied_from_dynobj();
1256 csym->set_needs_dynsym_entry();
1258 this->copied_symbol_dynobjs_[csym] = dynobj;
1260 // We have now defined all aliases, but we have not entered them all
1261 // in the copied_symbol_dynobjs_ map.
1262 if (csym->has_alias())
1267 sym = this->weak_aliases_[sym];
1270 gold_assert(sym->output_data() == posd);
1272 sym->set_is_copied_from_dynobj();
1273 this->copied_symbol_dynobjs_[sym] = dynobj;
1278 // SYM is defined using a COPY reloc. Return the dynamic object where
1279 // the original definition was found.
1282 Symbol_table::get_copy_source(const Symbol* sym) const
1284 gold_assert(sym->is_copied_from_dynobj());
1285 Copied_symbol_dynobjs::const_iterator p =
1286 this->copied_symbol_dynobjs_.find(sym);
1287 gold_assert(p != this->copied_symbol_dynobjs_.end());
1291 // Set the dynamic symbol indexes. INDEX is the index of the first
1292 // global dynamic symbol. Pointers to the symbols are stored into the
1293 // vector SYMS. The names are added to DYNPOOL. This returns an
1294 // updated dynamic symbol index.
1297 Symbol_table::set_dynsym_indexes(const General_options* options,
1298 const Target* target,
1300 std::vector<Symbol*>* syms,
1301 Stringpool* dynpool,
1304 for (Symbol_table_type::iterator p = this->table_.begin();
1305 p != this->table_.end();
1308 Symbol* sym = p->second;
1310 // Note that SYM may already have a dynamic symbol index, since
1311 // some symbols appear more than once in the symbol table, with
1312 // and without a version.
1314 if (!sym->should_add_dynsym_entry())
1315 sym->set_dynsym_index(-1U);
1316 else if (!sym->has_dynsym_index())
1318 sym->set_dynsym_index(index);
1320 syms->push_back(sym);
1321 dynpool->add(sym->name(), false, NULL);
1323 // Record any version information.
1324 if (sym->version() != NULL)
1325 versions->record_version(options, this, dynpool, sym);
1329 // Finish up the versions. In some cases this may add new dynamic
1331 index = versions->finalize(target, this, index, syms);
1336 // Set the final values for all the symbols. The index of the first
1337 // global symbol in the output file is INDEX. Record the file offset
1338 // OFF. Add their names to POOL. Return the new file offset.
1341 Symbol_table::finalize(unsigned int index, off_t off, off_t dynoff,
1342 size_t dyn_global_index, size_t dyncount,
1347 gold_assert(index != 0);
1348 this->first_global_index_ = index;
1350 this->dynamic_offset_ = dynoff;
1351 this->first_dynamic_global_index_ = dyn_global_index;
1352 this->dynamic_count_ = dyncount;
1354 if (parameters->get_size() == 32)
1356 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_32_LITTLE)
1357 ret = this->sized_finalize<32>(index, off, pool);
1362 else if (parameters->get_size() == 64)
1364 #if defined(HAVE_TARGET_64_BIG) || defined(HAVE_TARGET_64_LITTLE)
1365 ret = this->sized_finalize<64>(index, off, pool);
1373 // Now that we have the final symbol table, we can reliably note
1374 // which symbols should get warnings.
1375 this->warnings_.note_warnings(this);
1380 // Set the final value for all the symbols. This is called after
1381 // Layout::finalize, so all the output sections have their final
1386 Symbol_table::sized_finalize(unsigned index, off_t off, Stringpool* pool)
1388 off = align_address(off, size >> 3);
1389 this->offset_ = off;
1391 size_t orig_index = index;
1393 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1394 for (Symbol_table_type::iterator p = this->table_.begin();
1395 p != this->table_.end();
1398 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
1400 // FIXME: Here we need to decide which symbols should go into
1401 // the output file, based on --strip.
1403 // The default version of a symbol may appear twice in the
1404 // symbol table. We only need to finalize it once.
1405 if (sym->has_symtab_index())
1410 gold_assert(!sym->has_symtab_index());
1411 sym->set_symtab_index(-1U);
1412 gold_assert(sym->dynsym_index() == -1U);
1416 typename Sized_symbol<size>::Value_type value;
1418 switch (sym->source())
1420 case Symbol::FROM_OBJECT:
1422 unsigned int shndx = sym->shndx();
1424 // FIXME: We need some target specific support here.
1425 if (shndx >= elfcpp::SHN_LORESERVE
1426 && shndx != elfcpp::SHN_ABS)
1428 gold_error(_("%s: unsupported symbol section 0x%x"),
1429 sym->name(), shndx);
1430 shndx = elfcpp::SHN_UNDEF;
1433 Object* symobj = sym->object();
1434 if (symobj->is_dynamic())
1437 shndx = elfcpp::SHN_UNDEF;
1439 else if (shndx == elfcpp::SHN_UNDEF)
1441 else if (shndx == elfcpp::SHN_ABS)
1442 value = sym->value();
1445 Relobj* relobj = static_cast<Relobj*>(symobj);
1447 Output_section* os = relobj->output_section(shndx, &secoff);
1451 sym->set_symtab_index(-1U);
1452 gold_assert(sym->dynsym_index() == -1U);
1456 value = sym->value() + os->address() + secoff;
1461 case Symbol::IN_OUTPUT_DATA:
1463 Output_data* od = sym->output_data();
1464 value = sym->value() + od->address();
1465 if (sym->offset_is_from_end())
1466 value += od->data_size();
1470 case Symbol::IN_OUTPUT_SEGMENT:
1472 Output_segment* os = sym->output_segment();
1473 value = sym->value() + os->vaddr();
1474 switch (sym->offset_base())
1476 case Symbol::SEGMENT_START:
1478 case Symbol::SEGMENT_END:
1479 value += os->memsz();
1481 case Symbol::SEGMENT_BSS:
1482 value += os->filesz();
1490 case Symbol::CONSTANT:
1491 value = sym->value();
1498 sym->set_value(value);
1500 if (parameters->strip_all())
1501 sym->set_symtab_index(-1U);
1504 sym->set_symtab_index(index);
1505 pool->add(sym->name(), false, NULL);
1511 this->output_count_ = index - orig_index;
1516 // Write out the global symbols.
1519 Symbol_table::write_globals(const Target* target, const Stringpool* sympool,
1520 const Stringpool* dynpool, Output_file* of) const
1522 if (parameters->get_size() == 32)
1524 if (parameters->is_big_endian())
1526 #ifdef HAVE_TARGET_32_BIG
1527 this->sized_write_globals<32, true>(target, sympool, dynpool, of);
1534 #ifdef HAVE_TARGET_32_LITTLE
1535 this->sized_write_globals<32, false>(target, sympool, dynpool, of);
1541 else if (parameters->get_size() == 64)
1543 if (parameters->is_big_endian())
1545 #ifdef HAVE_TARGET_64_BIG
1546 this->sized_write_globals<64, true>(target, sympool, dynpool, of);
1553 #ifdef HAVE_TARGET_64_LITTLE
1554 this->sized_write_globals<64, false>(target, sympool, dynpool, of);
1564 // Write out the global symbols.
1566 template<int size, bool big_endian>
1568 Symbol_table::sized_write_globals(const Target* target,
1569 const Stringpool* sympool,
1570 const Stringpool* dynpool,
1571 Output_file* of) const
1573 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1574 unsigned int index = this->first_global_index_;
1575 const off_t oview_size = this->output_count_ * sym_size;
1576 unsigned char* const psyms = of->get_output_view(this->offset_, oview_size);
1578 unsigned int dynamic_count = this->dynamic_count_;
1579 off_t dynamic_size = dynamic_count * sym_size;
1580 unsigned int first_dynamic_global_index = this->first_dynamic_global_index_;
1581 unsigned char* dynamic_view;
1582 if (this->dynamic_offset_ == 0)
1583 dynamic_view = NULL;
1585 dynamic_view = of->get_output_view(this->dynamic_offset_, dynamic_size);
1587 unsigned char* ps = psyms;
1588 for (Symbol_table_type::const_iterator p = this->table_.begin();
1589 p != this->table_.end();
1592 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
1594 unsigned int sym_index = sym->symtab_index();
1595 unsigned int dynsym_index;
1596 if (dynamic_view == NULL)
1599 dynsym_index = sym->dynsym_index();
1601 if (sym_index == -1U && dynsym_index == -1U)
1603 // This symbol is not included in the output file.
1607 if (sym_index == index)
1609 else if (sym_index != -1U)
1611 // We have already seen this symbol, because it has a
1613 gold_assert(sym_index < index);
1614 if (dynsym_index == -1U)
1620 typename elfcpp::Elf_types<32>::Elf_Addr value = sym->value();
1621 switch (sym->source())
1623 case Symbol::FROM_OBJECT:
1625 unsigned int in_shndx = sym->shndx();
1627 // FIXME: We need some target specific support here.
1628 if (in_shndx >= elfcpp::SHN_LORESERVE
1629 && in_shndx != elfcpp::SHN_ABS)
1631 gold_error(_("%s: unsupported symbol section 0x%x"),
1632 sym->name(), in_shndx);
1637 Object* symobj = sym->object();
1638 if (symobj->is_dynamic())
1640 if (sym->needs_dynsym_value())
1641 value = target->dynsym_value(sym);
1642 shndx = elfcpp::SHN_UNDEF;
1644 else if (in_shndx == elfcpp::SHN_UNDEF
1645 || in_shndx == elfcpp::SHN_ABS)
1649 Relobj* relobj = static_cast<Relobj*>(symobj);
1651 Output_section* os = relobj->output_section(in_shndx,
1653 gold_assert(os != NULL);
1654 shndx = os->out_shndx();
1660 case Symbol::IN_OUTPUT_DATA:
1661 shndx = sym->output_data()->out_shndx();
1664 case Symbol::IN_OUTPUT_SEGMENT:
1665 shndx = elfcpp::SHN_ABS;
1668 case Symbol::CONSTANT:
1669 shndx = elfcpp::SHN_ABS;
1676 if (sym_index != -1U)
1678 this->sized_write_symbol SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
1679 sym, sym->value(), shndx, sympool, ps
1680 SELECT_SIZE_ENDIAN(size, big_endian));
1684 if (dynsym_index != -1U)
1686 dynsym_index -= first_dynamic_global_index;
1687 gold_assert(dynsym_index < dynamic_count);
1688 unsigned char* pd = dynamic_view + (dynsym_index * sym_size);
1689 this->sized_write_symbol SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
1690 sym, value, shndx, dynpool, pd
1691 SELECT_SIZE_ENDIAN(size, big_endian));
1695 gold_assert(ps - psyms == oview_size);
1697 of->write_output_view(this->offset_, oview_size, psyms);
1698 if (dynamic_view != NULL)
1699 of->write_output_view(this->dynamic_offset_, dynamic_size, dynamic_view);
1702 // Write out the symbol SYM, in section SHNDX, to P. POOL is the
1703 // strtab holding the name.
1705 template<int size, bool big_endian>
1707 Symbol_table::sized_write_symbol(
1708 Sized_symbol<size>* sym,
1709 typename elfcpp::Elf_types<size>::Elf_Addr value,
1711 const Stringpool* pool,
1713 ACCEPT_SIZE_ENDIAN) const
1715 elfcpp::Sym_write<size, big_endian> osym(p);
1716 osym.put_st_name(pool->get_offset(sym->name()));
1717 osym.put_st_value(value);
1718 osym.put_st_size(sym->symsize());
1719 osym.put_st_info(elfcpp::elf_st_info(sym->binding(), sym->type()));
1720 osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), sym->nonvis()));
1721 osym.put_st_shndx(shndx);
1724 // Write out a section symbol. Return the update offset.
1727 Symbol_table::write_section_symbol(const Output_section *os,
1731 if (parameters->get_size() == 32)
1733 if (parameters->is_big_endian())
1735 #ifdef HAVE_TARGET_32_BIG
1736 this->sized_write_section_symbol<32, true>(os, of, offset);
1743 #ifdef HAVE_TARGET_32_LITTLE
1744 this->sized_write_section_symbol<32, false>(os, of, offset);
1750 else if (parameters->get_size() == 64)
1752 if (parameters->is_big_endian())
1754 #ifdef HAVE_TARGET_64_BIG
1755 this->sized_write_section_symbol<64, true>(os, of, offset);
1762 #ifdef HAVE_TARGET_64_LITTLE
1763 this->sized_write_section_symbol<64, false>(os, of, offset);
1773 // Write out a section symbol, specialized for size and endianness.
1775 template<int size, bool big_endian>
1777 Symbol_table::sized_write_section_symbol(const Output_section* os,
1781 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1783 unsigned char* pov = of->get_output_view(offset, sym_size);
1785 elfcpp::Sym_write<size, big_endian> osym(pov);
1786 osym.put_st_name(0);
1787 osym.put_st_value(os->address());
1788 osym.put_st_size(0);
1789 osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL,
1790 elfcpp::STT_SECTION));
1791 osym.put_st_other(elfcpp::elf_st_other(elfcpp::STV_DEFAULT, 0));
1792 osym.put_st_shndx(os->out_shndx());
1794 of->write_output_view(offset, sym_size, pov);
1797 // Warnings functions.
1799 // Add a new warning.
1802 Warnings::add_warning(Symbol_table* symtab, const char* name, Object* obj,
1805 name = symtab->canonicalize_name(name);
1806 this->warnings_[name].set(obj, shndx);
1809 // Look through the warnings and mark the symbols for which we should
1810 // warn. This is called during Layout::finalize when we know the
1811 // sources for all the symbols.
1814 Warnings::note_warnings(Symbol_table* symtab)
1816 for (Warning_table::iterator p = this->warnings_.begin();
1817 p != this->warnings_.end();
1820 Symbol* sym = symtab->lookup(p->first, NULL);
1822 && sym->source() == Symbol::FROM_OBJECT
1823 && sym->object() == p->second.object)
1825 sym->set_has_warning();
1827 // Read the section contents to get the warning text. It
1828 // would be nicer if we only did this if we have to actually
1829 // issue a warning. Unfortunately, warnings are issued as
1830 // we relocate sections. That means that we can not lock
1831 // the object then, as we might try to issue the same
1832 // warning multiple times simultaneously.
1834 Task_locker_obj<Object> tl(*p->second.object);
1835 const unsigned char* c;
1837 c = p->second.object->section_contents(p->second.shndx, &len,
1839 p->second.set_text(reinterpret_cast<const char*>(c), len);
1845 // Issue a warning. This is called when we see a relocation against a
1846 // symbol for which has a warning.
1848 template<int size, bool big_endian>
1850 Warnings::issue_warning(const Symbol* sym,
1851 const Relocate_info<size, big_endian>* relinfo,
1852 size_t relnum, off_t reloffset) const
1854 gold_assert(sym->has_warning());
1855 Warning_table::const_iterator p = this->warnings_.find(sym->name());
1856 gold_assert(p != this->warnings_.end());
1857 gold_warning_at_location(relinfo, relnum, reloffset,
1858 "%s", p->second.text.c_str());
1861 // Instantiate the templates we need. We could use the configure
1862 // script to restrict this to only the ones needed for implemented
1865 #ifdef HAVE_TARGET_32_LITTLE
1868 Symbol_table::add_from_relobj<32, false>(
1869 Sized_relobj<32, false>* relobj,
1870 const unsigned char* syms,
1872 const char* sym_names,
1873 size_t sym_name_size,
1874 Symbol** sympointers);
1877 #ifdef HAVE_TARGET_32_BIG
1880 Symbol_table::add_from_relobj<32, true>(
1881 Sized_relobj<32, true>* relobj,
1882 const unsigned char* syms,
1884 const char* sym_names,
1885 size_t sym_name_size,
1886 Symbol** sympointers);
1889 #ifdef HAVE_TARGET_64_LITTLE
1892 Symbol_table::add_from_relobj<64, false>(
1893 Sized_relobj<64, false>* relobj,
1894 const unsigned char* syms,
1896 const char* sym_names,
1897 size_t sym_name_size,
1898 Symbol** sympointers);
1901 #ifdef HAVE_TARGET_64_BIG
1904 Symbol_table::add_from_relobj<64, true>(
1905 Sized_relobj<64, true>* relobj,
1906 const unsigned char* syms,
1908 const char* sym_names,
1909 size_t sym_name_size,
1910 Symbol** sympointers);
1913 #ifdef HAVE_TARGET_32_LITTLE
1916 Symbol_table::add_from_dynobj<32, false>(
1917 Sized_dynobj<32, false>* dynobj,
1918 const unsigned char* syms,
1920 const char* sym_names,
1921 size_t sym_name_size,
1922 const unsigned char* versym,
1924 const std::vector<const char*>* version_map);
1927 #ifdef HAVE_TARGET_32_BIG
1930 Symbol_table::add_from_dynobj<32, true>(
1931 Sized_dynobj<32, true>* dynobj,
1932 const unsigned char* syms,
1934 const char* sym_names,
1935 size_t sym_name_size,
1936 const unsigned char* versym,
1938 const std::vector<const char*>* version_map);
1941 #ifdef HAVE_TARGET_64_LITTLE
1944 Symbol_table::add_from_dynobj<64, false>(
1945 Sized_dynobj<64, false>* dynobj,
1946 const unsigned char* syms,
1948 const char* sym_names,
1949 size_t sym_name_size,
1950 const unsigned char* versym,
1952 const std::vector<const char*>* version_map);
1955 #ifdef HAVE_TARGET_64_BIG
1958 Symbol_table::add_from_dynobj<64, true>(
1959 Sized_dynobj<64, true>* dynobj,
1960 const unsigned char* syms,
1962 const char* sym_names,
1963 size_t sym_name_size,
1964 const unsigned char* versym,
1966 const std::vector<const char*>* version_map);
1969 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
1972 Symbol_table::define_with_copy_reloc<32>(const Target* target,
1973 Sized_symbol<32>* sym,
1974 Output_data* posd, uint64_t value);
1977 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
1980 Symbol_table::define_with_copy_reloc<64>(const Target* target,
1981 Sized_symbol<64>* sym,
1982 Output_data* posd, uint64_t value);
1985 #ifdef HAVE_TARGET_32_LITTLE
1988 Warnings::issue_warning<32, false>(const Symbol* sym,
1989 const Relocate_info<32, false>* relinfo,
1990 size_t relnum, off_t reloffset) const;
1993 #ifdef HAVE_TARGET_32_BIG
1996 Warnings::issue_warning<32, true>(const Symbol* sym,
1997 const Relocate_info<32, true>* relinfo,
1998 size_t relnum, off_t reloffset) const;
2001 #ifdef HAVE_TARGET_64_LITTLE
2004 Warnings::issue_warning<64, false>(const Symbol* sym,
2005 const Relocate_info<64, false>* relinfo,
2006 size_t relnum, off_t reloffset) const;
2009 #ifdef HAVE_TARGET_64_BIG
2012 Warnings::issue_warning<64, true>(const Symbol* sym,
2013 const Relocate_info<64, true>* relinfo,
2014 size_t relnum, off_t reloffset) const;
2017 } // End namespace gold.