Set Stringpool zero_null option via a call, not a default constructor
[binutils.git] / gold / symtab.cc
blobd29f751ad8c1ae3384c2082b144b95b15fbb1e93
1 // symtab.cc -- the gold symbol table
3 #include "gold.h"
5 #include <stdint.h>
6 #include <string>
7 #include <utility>
9 #include "object.h"
10 #include "dynobj.h"
11 #include "output.h"
12 #include "target.h"
13 #include "workqueue.h"
14 #include "symtab.h"
16 namespace gold
19 // Class Symbol.
21 // Initialize fields in Symbol. This initializes everything except u_
22 // and source_.
24 void
25 Symbol::init_fields(const char* name, const char* version,
26 elfcpp::STT type, elfcpp::STB binding,
27 elfcpp::STV visibility, unsigned char nonvis)
29 this->name_ = name;
30 this->version_ = version;
31 this->symtab_index_ = 0;
32 this->dynsym_index_ = 0;
33 this->got_offset_ = 0;
34 this->plt_offset_ = 0;
35 this->type_ = type;
36 this->binding_ = binding;
37 this->visibility_ = visibility;
38 this->nonvis_ = nonvis;
39 this->is_target_special_ = false;
40 this->is_def_ = false;
41 this->is_forwarder_ = false;
42 this->needs_dynsym_entry_ = false;
43 this->in_reg_ = false;
44 this->in_dyn_ = false;
45 this->has_got_offset_ = false;
46 this->has_plt_offset_ = false;
47 this->has_warning_ = false;
50 // Initialize the fields in the base class Symbol for SYM in OBJECT.
52 template<int size, bool big_endian>
53 void
54 Symbol::init_base(const char* name, const char* version, Object* object,
55 const elfcpp::Sym<size, big_endian>& sym)
57 this->init_fields(name, version, sym.get_st_type(), sym.get_st_bind(),
58 sym.get_st_visibility(), sym.get_st_nonvis());
59 this->u_.from_object.object = object;
60 // FIXME: Handle SHN_XINDEX.
61 this->u_.from_object.shndx = sym.get_st_shndx();
62 this->source_ = FROM_OBJECT;
63 this->in_reg_ = !object->is_dynamic();
64 this->in_dyn_ = object->is_dynamic();
67 // Initialize the fields in the base class Symbol for a symbol defined
68 // in an Output_data.
70 void
71 Symbol::init_base(const char* name, Output_data* od, elfcpp::STT type,
72 elfcpp::STB binding, elfcpp::STV visibility,
73 unsigned char nonvis, bool offset_is_from_end)
75 this->init_fields(name, NULL, type, binding, visibility, nonvis);
76 this->u_.in_output_data.output_data = od;
77 this->u_.in_output_data.offset_is_from_end = offset_is_from_end;
78 this->source_ = IN_OUTPUT_DATA;
79 this->in_reg_ = true;
82 // Initialize the fields in the base class Symbol for a symbol defined
83 // in an Output_segment.
85 void
86 Symbol::init_base(const char* name, Output_segment* os, elfcpp::STT type,
87 elfcpp::STB binding, elfcpp::STV visibility,
88 unsigned char nonvis, Segment_offset_base offset_base)
90 this->init_fields(name, NULL, type, binding, visibility, nonvis);
91 this->u_.in_output_segment.output_segment = os;
92 this->u_.in_output_segment.offset_base = offset_base;
93 this->source_ = IN_OUTPUT_SEGMENT;
94 this->in_reg_ = true;
97 // Initialize the fields in the base class Symbol for a symbol defined
98 // as a constant.
100 void
101 Symbol::init_base(const char* name, elfcpp::STT type,
102 elfcpp::STB binding, elfcpp::STV visibility,
103 unsigned char nonvis)
105 this->init_fields(name, NULL, type, binding, visibility, nonvis);
106 this->source_ = CONSTANT;
107 this->in_reg_ = true;
110 // Initialize the fields in Sized_symbol for SYM in OBJECT.
112 template<int size>
113 template<bool big_endian>
114 void
115 Sized_symbol<size>::init(const char* name, const char* version, Object* object,
116 const elfcpp::Sym<size, big_endian>& sym)
118 this->init_base(name, version, object, sym);
119 this->value_ = sym.get_st_value();
120 this->symsize_ = sym.get_st_size();
123 // Initialize the fields in Sized_symbol for a symbol defined in an
124 // Output_data.
126 template<int size>
127 void
128 Sized_symbol<size>::init(const char* name, Output_data* od,
129 Value_type value, Size_type symsize,
130 elfcpp::STT type, elfcpp::STB binding,
131 elfcpp::STV visibility, unsigned char nonvis,
132 bool offset_is_from_end)
134 this->init_base(name, od, type, binding, visibility, nonvis,
135 offset_is_from_end);
136 this->value_ = value;
137 this->symsize_ = symsize;
140 // Initialize the fields in Sized_symbol for a symbol defined in an
141 // Output_segment.
143 template<int size>
144 void
145 Sized_symbol<size>::init(const char* name, Output_segment* os,
146 Value_type value, Size_type symsize,
147 elfcpp::STT type, elfcpp::STB binding,
148 elfcpp::STV visibility, unsigned char nonvis,
149 Segment_offset_base offset_base)
151 this->init_base(name, os, type, binding, visibility, nonvis, offset_base);
152 this->value_ = value;
153 this->symsize_ = symsize;
156 // Initialize the fields in Sized_symbol for a symbol defined as a
157 // constant.
159 template<int size>
160 void
161 Sized_symbol<size>::init(const char* name, Value_type value, Size_type symsize,
162 elfcpp::STT type, elfcpp::STB binding,
163 elfcpp::STV visibility, unsigned char nonvis)
165 this->init_base(name, type, binding, visibility, nonvis);
166 this->value_ = value;
167 this->symsize_ = symsize;
170 // Class Symbol_table.
172 Symbol_table::Symbol_table()
173 : size_(0), saw_undefined_(0), offset_(0), table_(), namepool_(),
174 forwarders_(), commons_(), warnings_()
178 Symbol_table::~Symbol_table()
182 // The hash function. The key is always canonicalized, so we use a
183 // simple combination of the pointers.
185 size_t
186 Symbol_table::Symbol_table_hash::operator()(const Symbol_table_key& key) const
188 return key.first ^ key.second;
191 // The symbol table key equality function. This is only called with
192 // canonicalized name and version strings, so we can use pointer
193 // comparison.
195 bool
196 Symbol_table::Symbol_table_eq::operator()(const Symbol_table_key& k1,
197 const Symbol_table_key& k2) const
199 return k1.first == k2.first && k1.second == k2.second;
202 // Make TO a symbol which forwards to FROM.
204 void
205 Symbol_table::make_forwarder(Symbol* from, Symbol* to)
207 gold_assert(from != to);
208 gold_assert(!from->is_forwarder() && !to->is_forwarder());
209 this->forwarders_[from] = to;
210 from->set_forwarder();
213 // Resolve the forwards from FROM, returning the real symbol.
215 Symbol*
216 Symbol_table::resolve_forwards(const Symbol* from) const
218 gold_assert(from->is_forwarder());
219 Unordered_map<const Symbol*, Symbol*>::const_iterator p =
220 this->forwarders_.find(from);
221 gold_assert(p != this->forwarders_.end());
222 return p->second;
225 // Look up a symbol by name.
227 Symbol*
228 Symbol_table::lookup(const char* name, const char* version) const
230 Stringpool::Key name_key;
231 name = this->namepool_.find(name, &name_key);
232 if (name == NULL)
233 return NULL;
235 Stringpool::Key version_key = 0;
236 if (version != NULL)
238 version = this->namepool_.find(version, &version_key);
239 if (version == NULL)
240 return NULL;
243 Symbol_table_key key(name_key, version_key);
244 Symbol_table::Symbol_table_type::const_iterator p = this->table_.find(key);
245 if (p == this->table_.end())
246 return NULL;
247 return p->second;
250 // Resolve a Symbol with another Symbol. This is only used in the
251 // unusual case where there are references to both an unversioned
252 // symbol and a symbol with a version, and we then discover that that
253 // version is the default version. Because this is unusual, we do
254 // this the slow way, by converting back to an ELF symbol.
256 template<int size, bool big_endian>
257 void
258 Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
259 const char* version ACCEPT_SIZE_ENDIAN)
261 unsigned char buf[elfcpp::Elf_sizes<size>::sym_size];
262 elfcpp::Sym_write<size, big_endian> esym(buf);
263 // We don't bother to set the st_name field.
264 esym.put_st_value(from->value());
265 esym.put_st_size(from->symsize());
266 esym.put_st_info(from->binding(), from->type());
267 esym.put_st_other(from->visibility(), from->nonvis());
268 esym.put_st_shndx(from->shndx());
269 Symbol_table::resolve(to, esym.sym(), from->object(), version);
270 if (from->in_reg())
271 to->set_in_reg();
272 if (from->in_dyn())
273 to->set_in_dyn();
276 // Add one symbol from OBJECT to the symbol table. NAME is symbol
277 // name and VERSION is the version; both are canonicalized. DEF is
278 // whether this is the default version.
280 // If DEF is true, then this is the definition of a default version of
281 // a symbol. That means that any lookup of NAME/NULL and any lookup
282 // of NAME/VERSION should always return the same symbol. This is
283 // obvious for references, but in particular we want to do this for
284 // definitions: overriding NAME/NULL should also override
285 // NAME/VERSION. If we don't do that, it would be very hard to
286 // override functions in a shared library which uses versioning.
288 // We implement this by simply making both entries in the hash table
289 // point to the same Symbol structure. That is easy enough if this is
290 // the first time we see NAME/NULL or NAME/VERSION, but it is possible
291 // that we have seen both already, in which case they will both have
292 // independent entries in the symbol table. We can't simply change
293 // the symbol table entry, because we have pointers to the entries
294 // attached to the object files. So we mark the entry attached to the
295 // object file as a forwarder, and record it in the forwarders_ map.
296 // Note that entries in the hash table will never be marked as
297 // forwarders.
299 template<int size, bool big_endian>
300 Symbol*
301 Symbol_table::add_from_object(Object* object,
302 const char *name,
303 Stringpool::Key name_key,
304 const char *version,
305 Stringpool::Key version_key,
306 bool def,
307 const elfcpp::Sym<size, big_endian>& sym)
309 Symbol* const snull = NULL;
310 std::pair<typename Symbol_table_type::iterator, bool> ins =
311 this->table_.insert(std::make_pair(std::make_pair(name_key, version_key),
312 snull));
314 std::pair<typename Symbol_table_type::iterator, bool> insdef =
315 std::make_pair(this->table_.end(), false);
316 if (def)
318 const Stringpool::Key vnull_key = 0;
319 insdef = this->table_.insert(std::make_pair(std::make_pair(name_key,
320 vnull_key),
321 snull));
324 // ins.first: an iterator, which is a pointer to a pair.
325 // ins.first->first: the key (a pair of name and version).
326 // ins.first->second: the value (Symbol*).
327 // ins.second: true if new entry was inserted, false if not.
329 Sized_symbol<size>* ret;
330 bool was_undefined;
331 bool was_common;
332 if (!ins.second)
334 // We already have an entry for NAME/VERSION.
335 ret = this->get_sized_symbol SELECT_SIZE_NAME(size) (ins.first->second
336 SELECT_SIZE(size));
337 gold_assert(ret != NULL);
339 was_undefined = ret->is_undefined();
340 was_common = ret->is_common();
342 Symbol_table::resolve(ret, sym, object, version);
344 if (def)
346 if (insdef.second)
348 // This is the first time we have seen NAME/NULL. Make
349 // NAME/NULL point to NAME/VERSION.
350 insdef.first->second = ret;
352 else if (insdef.first->second != ret)
354 // This is the unfortunate case where we already have
355 // entries for both NAME/VERSION and NAME/NULL.
356 const Sized_symbol<size>* sym2;
357 sym2 = this->get_sized_symbol SELECT_SIZE_NAME(size) (
358 insdef.first->second
359 SELECT_SIZE(size));
360 Symbol_table::resolve SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
361 ret, sym2, version SELECT_SIZE_ENDIAN(size, big_endian));
362 this->make_forwarder(insdef.first->second, ret);
363 insdef.first->second = ret;
367 else
369 // This is the first time we have seen NAME/VERSION.
370 gold_assert(ins.first->second == NULL);
372 was_undefined = false;
373 was_common = false;
375 if (def && !insdef.second)
377 // We already have an entry for NAME/NULL. If we override
378 // it, then change it to NAME/VERSION.
379 ret = this->get_sized_symbol SELECT_SIZE_NAME(size) (
380 insdef.first->second
381 SELECT_SIZE(size));
382 Symbol_table::resolve(ret, sym, object, version);
383 ins.first->second = ret;
385 else
387 Sized_target<size, big_endian>* target =
388 object->sized_target SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
389 SELECT_SIZE_ENDIAN_ONLY(size, big_endian));
390 if (!target->has_make_symbol())
391 ret = new Sized_symbol<size>();
392 else
394 ret = target->make_symbol();
395 if (ret == NULL)
397 // This means that we don't want a symbol table
398 // entry after all.
399 if (!def)
400 this->table_.erase(ins.first);
401 else
403 this->table_.erase(insdef.first);
404 // Inserting insdef invalidated ins.
405 this->table_.erase(std::make_pair(name_key,
406 version_key));
408 return NULL;
412 ret->init(name, version, object, sym);
414 ins.first->second = ret;
415 if (def)
417 // This is the first time we have seen NAME/NULL. Point
418 // it at the new entry for NAME/VERSION.
419 gold_assert(insdef.second);
420 insdef.first->second = ret;
425 // Record every time we see a new undefined symbol, to speed up
426 // archive groups.
427 if (!was_undefined && ret->is_undefined())
428 ++this->saw_undefined_;
430 // Keep track of common symbols, to speed up common symbol
431 // allocation.
432 if (!was_common && ret->is_common())
433 this->commons_.push_back(ret);
435 return ret;
438 // Add all the symbols in a relocatable object to the hash table.
440 template<int size, bool big_endian>
441 void
442 Symbol_table::add_from_relobj(
443 Sized_relobj<size, big_endian>* relobj,
444 const unsigned char* syms,
445 size_t count,
446 const char* sym_names,
447 size_t sym_name_size,
448 Symbol** sympointers)
450 // We take the size from the first object we see.
451 if (this->get_size() == 0)
452 this->set_size(size);
454 if (size != this->get_size() || size != relobj->target()->get_size())
456 fprintf(stderr, _("%s: %s: mixing 32-bit and 64-bit ELF objects\n"),
457 program_name, relobj->name().c_str());
458 gold_exit(false);
461 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
463 const unsigned char* p = syms;
464 for (size_t i = 0; i < count; ++i, p += sym_size)
466 elfcpp::Sym<size, big_endian> sym(p);
467 elfcpp::Sym<size, big_endian>* psym = &sym;
469 unsigned int st_name = psym->get_st_name();
470 if (st_name >= sym_name_size)
472 fprintf(stderr,
473 _("%s: %s: bad global symbol name offset %u at %lu\n"),
474 program_name, relobj->name().c_str(), st_name,
475 static_cast<unsigned long>(i));
476 gold_exit(false);
479 const char* name = sym_names + st_name;
481 // A symbol defined in a section which we are not including must
482 // be treated as an undefined symbol.
483 unsigned char symbuf[sym_size];
484 elfcpp::Sym<size, big_endian> sym2(symbuf);
485 unsigned int st_shndx = psym->get_st_shndx();
486 if (st_shndx != elfcpp::SHN_UNDEF
487 && st_shndx < elfcpp::SHN_LORESERVE
488 && !relobj->is_section_included(st_shndx))
490 memcpy(symbuf, p, sym_size);
491 elfcpp::Sym_write<size, big_endian> sw(symbuf);
492 sw.put_st_shndx(elfcpp::SHN_UNDEF);
493 psym = &sym2;
496 // In an object file, an '@' in the name separates the symbol
497 // name from the version name. If there are two '@' characters,
498 // this is the default version.
499 const char* ver = strchr(name, '@');
501 Symbol* res;
502 if (ver == NULL)
504 Stringpool::Key name_key;
505 name = this->namepool_.add(name, &name_key);
506 res = this->add_from_object(relobj, name, name_key, NULL, 0,
507 false, *psym);
509 else
511 Stringpool::Key name_key;
512 name = this->namepool_.add(name, ver - name, &name_key);
514 bool def = false;
515 ++ver;
516 if (*ver == '@')
518 def = true;
519 ++ver;
522 Stringpool::Key ver_key;
523 ver = this->namepool_.add(ver, &ver_key);
525 res = this->add_from_object(relobj, name, name_key, ver, ver_key,
526 def, *psym);
529 *sympointers++ = res;
533 // Add all the symbols in a dynamic object to the hash table.
535 template<int size, bool big_endian>
536 void
537 Symbol_table::add_from_dynobj(
538 Sized_dynobj<size, big_endian>* dynobj,
539 const unsigned char* syms,
540 size_t count,
541 const char* sym_names,
542 size_t sym_name_size,
543 const unsigned char* versym,
544 size_t versym_size,
545 const std::vector<const char*>* version_map)
547 // We take the size from the first object we see.
548 if (this->get_size() == 0)
549 this->set_size(size);
551 if (size != this->get_size() || size != dynobj->target()->get_size())
553 fprintf(stderr, _("%s: %s: mixing 32-bit and 64-bit ELF objects\n"),
554 program_name, dynobj->name().c_str());
555 gold_exit(false);
558 if (versym != NULL && versym_size / 2 < count)
560 fprintf(stderr, _("%s: %s: too few symbol versions\n"),
561 program_name, dynobj->name().c_str());
562 gold_exit(false);
565 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
567 const unsigned char* p = syms;
568 const unsigned char* vs = versym;
569 for (size_t i = 0; i < count; ++i, p += sym_size, vs += 2)
571 elfcpp::Sym<size, big_endian> sym(p);
573 // Ignore symbols with local binding.
574 if (sym.get_st_bind() == elfcpp::STB_LOCAL)
575 continue;
577 unsigned int st_name = sym.get_st_name();
578 if (st_name >= sym_name_size)
580 fprintf(stderr, _("%s: %s: bad symbol name offset %u at %lu\n"),
581 program_name, dynobj->name().c_str(), st_name,
582 static_cast<unsigned long>(i));
583 gold_exit(false);
586 const char* name = sym_names + st_name;
588 if (versym == NULL)
590 Stringpool::Key name_key;
591 name = this->namepool_.add(name, &name_key);
592 this->add_from_object(dynobj, name, name_key, NULL, 0,
593 false, sym);
594 continue;
597 // Read the version information.
599 unsigned int v = elfcpp::Swap<16, big_endian>::readval(vs);
601 bool hidden = (v & elfcpp::VERSYM_HIDDEN) != 0;
602 v &= elfcpp::VERSYM_VERSION;
604 // The Sun documentation says that V can be VER_NDX_LOCAL, or
605 // VER_NDX_GLOBAL, or a version index. The meaning of
606 // VER_NDX_LOCAL is defined as "Symbol has local scope." The
607 // old GNU linker will happily generate VER_NDX_LOCAL for an
608 // undefined symbol. I don't know what the Sun linker will
609 // generate.
611 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
612 && sym.get_st_shndx() != elfcpp::SHN_UNDEF)
614 // This symbol should not be visible outside the object.
615 continue;
618 // At this point we are definitely going to add this symbol.
619 Stringpool::Key name_key;
620 name = this->namepool_.add(name, &name_key);
622 if (v == static_cast<unsigned int>(elfcpp::VER_NDX_LOCAL)
623 || v == static_cast<unsigned int>(elfcpp::VER_NDX_GLOBAL))
625 // This symbol does not have a version.
626 this->add_from_object(dynobj, name, name_key, NULL, 0, false, sym);
627 continue;
630 if (v >= version_map->size())
632 fprintf(stderr,
633 _("%s: %s: versym for symbol %zu out of range: %u\n"),
634 program_name, dynobj->name().c_str(), i, v);
635 gold_exit(false);
638 const char* version = (*version_map)[v];
639 if (version == NULL)
641 fprintf(stderr, _("%s: %s: versym for symbol %zu has no name: %u\n"),
642 program_name, dynobj->name().c_str(), i, v);
643 gold_exit(false);
646 Stringpool::Key version_key;
647 version = this->namepool_.add(version, &version_key);
649 // If this is an absolute symbol, and the version name and
650 // symbol name are the same, then this is the version definition
651 // symbol. These symbols exist to support using -u to pull in
652 // particular versions. We do not want to record a version for
653 // them.
654 if (sym.get_st_shndx() == elfcpp::SHN_ABS && name_key == version_key)
656 this->add_from_object(dynobj, name, name_key, NULL, 0, false, sym);
657 continue;
660 const bool def = !hidden && sym.get_st_shndx() != elfcpp::SHN_UNDEF;
662 this->add_from_object(dynobj, name, name_key, version, version_key,
663 def, sym);
667 // Create and return a specially defined symbol. If ONLY_IF_REF is
668 // true, then only create the symbol if there is a reference to it.
669 // If this does not return NULL, it sets *POLDSYM to the existing
670 // symbol if there is one.
672 template<int size, bool big_endian>
673 Sized_symbol<size>*
674 Symbol_table::define_special_symbol(const Target* target, const char* name,
675 const char* version, bool only_if_ref,
676 Sized_symbol<size>** poldsym
677 ACCEPT_SIZE_ENDIAN)
679 gold_assert(this->size_ == size);
681 Symbol* oldsym;
682 Sized_symbol<size>* sym;
683 bool add_to_table = false;
684 typename Symbol_table_type::iterator add_loc = this->table_.end();
686 if (only_if_ref)
688 oldsym = this->lookup(name, version);
689 if (oldsym == NULL || !oldsym->is_undefined())
690 return NULL;
692 else
694 // Canonicalize NAME and VERSION.
695 Stringpool::Key name_key;
696 name = this->namepool_.add(name, &name_key);
698 Stringpool::Key version_key = 0;
699 if (version != NULL)
700 version = this->namepool_.add(version, &version_key);
702 Symbol* const snull = NULL;
703 std::pair<typename Symbol_table_type::iterator, bool> ins =
704 this->table_.insert(std::make_pair(std::make_pair(name_key,
705 version_key),
706 snull));
708 if (!ins.second)
710 // We already have a symbol table entry for NAME/VERSION.
711 oldsym = ins.first->second;
712 gold_assert(oldsym != NULL);
714 else
716 // We haven't seen this symbol before.
717 gold_assert(ins.first->second == NULL);
718 add_to_table = true;
719 add_loc = ins.first;
720 oldsym = NULL;
724 if (!target->has_make_symbol())
725 sym = new Sized_symbol<size>();
726 else
728 gold_assert(target->get_size() == size);
729 gold_assert(target->is_big_endian() ? big_endian : !big_endian);
730 typedef Sized_target<size, big_endian> My_target;
731 const My_target* sized_target =
732 static_cast<const My_target*>(target);
733 sym = sized_target->make_symbol();
734 if (sym == NULL)
735 return NULL;
738 if (add_to_table)
739 add_loc->second = sym;
740 else
741 gold_assert(oldsym != NULL);
743 *poldsym = this->get_sized_symbol SELECT_SIZE_NAME(size) (oldsym
744 SELECT_SIZE(size));
746 return sym;
749 // Define a symbol based on an Output_data.
751 Symbol*
752 Symbol_table::define_in_output_data(const Target* target, const char* name,
753 const char* version, Output_data* od,
754 uint64_t value, uint64_t symsize,
755 elfcpp::STT type, elfcpp::STB binding,
756 elfcpp::STV visibility,
757 unsigned char nonvis,
758 bool offset_is_from_end,
759 bool only_if_ref)
761 gold_assert(target->get_size() == this->size_);
762 if (this->size_ == 32)
764 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
765 return this->do_define_in_output_data<32>(target, name, version, od,
766 value, symsize, type, binding,
767 visibility, nonvis,
768 offset_is_from_end,
769 only_if_ref);
770 #else
771 gold_unreachable();
772 #endif
774 else if (this->size_ == 64)
776 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
777 return this->do_define_in_output_data<64>(target, name, version, od,
778 value, symsize, type, binding,
779 visibility, nonvis,
780 offset_is_from_end,
781 only_if_ref);
782 #else
783 gold_unreachable();
784 #endif
786 else
787 gold_unreachable();
790 // Define a symbol in an Output_data, sized version.
792 template<int size>
793 Sized_symbol<size>*
794 Symbol_table::do_define_in_output_data(
795 const Target* target,
796 const char* name,
797 const char* version,
798 Output_data* od,
799 typename elfcpp::Elf_types<size>::Elf_Addr value,
800 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
801 elfcpp::STT type,
802 elfcpp::STB binding,
803 elfcpp::STV visibility,
804 unsigned char nonvis,
805 bool offset_is_from_end,
806 bool only_if_ref)
808 Sized_symbol<size>* sym;
809 Sized_symbol<size>* oldsym;
811 if (target->is_big_endian())
813 #if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
814 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
815 target, name, version, only_if_ref, &oldsym
816 SELECT_SIZE_ENDIAN(size, true));
817 #else
818 gold_unreachable();
819 #endif
821 else
823 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
824 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
825 target, name, version, only_if_ref, &oldsym
826 SELECT_SIZE_ENDIAN(size, false));
827 #else
828 gold_unreachable();
829 #endif
832 if (sym == NULL)
833 return NULL;
835 sym->init(name, od, value, symsize, type, binding, visibility, nonvis,
836 offset_is_from_end);
838 if (oldsym != NULL
839 && Symbol_table::should_override_with_special(oldsym))
840 oldsym->override_with_special(sym);
842 return sym;
845 // Define a symbol based on an Output_segment.
847 Symbol*
848 Symbol_table::define_in_output_segment(const Target* target, const char* name,
849 const char* version, Output_segment* os,
850 uint64_t value, uint64_t symsize,
851 elfcpp::STT type, elfcpp::STB binding,
852 elfcpp::STV visibility,
853 unsigned char nonvis,
854 Symbol::Segment_offset_base offset_base,
855 bool only_if_ref)
857 gold_assert(target->get_size() == this->size_);
858 if (this->size_ == 32)
860 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
861 return this->do_define_in_output_segment<32>(target, name, version, os,
862 value, symsize, type,
863 binding, visibility, nonvis,
864 offset_base, only_if_ref);
865 #else
866 gold_unreachable();
867 #endif
869 else if (this->size_ == 64)
871 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
872 return this->do_define_in_output_segment<64>(target, name, version, os,
873 value, symsize, type,
874 binding, visibility, nonvis,
875 offset_base, only_if_ref);
876 #else
877 gold_unreachable();
878 #endif
880 else
881 gold_unreachable();
884 // Define a symbol in an Output_segment, sized version.
886 template<int size>
887 Sized_symbol<size>*
888 Symbol_table::do_define_in_output_segment(
889 const Target* target,
890 const char* name,
891 const char* version,
892 Output_segment* os,
893 typename elfcpp::Elf_types<size>::Elf_Addr value,
894 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
895 elfcpp::STT type,
896 elfcpp::STB binding,
897 elfcpp::STV visibility,
898 unsigned char nonvis,
899 Symbol::Segment_offset_base offset_base,
900 bool only_if_ref)
902 Sized_symbol<size>* sym;
903 Sized_symbol<size>* oldsym;
905 if (target->is_big_endian())
906 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
907 target, name, version, only_if_ref, &oldsym
908 SELECT_SIZE_ENDIAN(size, true));
909 else
910 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
911 target, name, version, only_if_ref, &oldsym
912 SELECT_SIZE_ENDIAN(size, false));
914 if (sym == NULL)
915 return NULL;
917 sym->init(name, os, value, symsize, type, binding, visibility, nonvis,
918 offset_base);
920 if (oldsym != NULL
921 && Symbol_table::should_override_with_special(oldsym))
922 oldsym->override_with_special(sym);
924 return sym;
927 // Define a special symbol with a constant value. It is a multiple
928 // definition error if this symbol is already defined.
930 Symbol*
931 Symbol_table::define_as_constant(const Target* target, const char* name,
932 const char* version, uint64_t value,
933 uint64_t symsize, elfcpp::STT type,
934 elfcpp::STB binding, elfcpp::STV visibility,
935 unsigned char nonvis, bool only_if_ref)
937 gold_assert(target->get_size() == this->size_);
938 if (this->size_ == 32)
940 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
941 return this->do_define_as_constant<32>(target, name, version, value,
942 symsize, type, binding,
943 visibility, nonvis, only_if_ref);
944 #else
945 gold_unreachable();
946 #endif
948 else if (this->size_ == 64)
950 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
951 return this->do_define_as_constant<64>(target, name, version, value,
952 symsize, type, binding,
953 visibility, nonvis, only_if_ref);
954 #else
955 gold_unreachable();
956 #endif
958 else
959 gold_unreachable();
962 // Define a symbol as a constant, sized version.
964 template<int size>
965 Sized_symbol<size>*
966 Symbol_table::do_define_as_constant(
967 const Target* target,
968 const char* name,
969 const char* version,
970 typename elfcpp::Elf_types<size>::Elf_Addr value,
971 typename elfcpp::Elf_types<size>::Elf_WXword symsize,
972 elfcpp::STT type,
973 elfcpp::STB binding,
974 elfcpp::STV visibility,
975 unsigned char nonvis,
976 bool only_if_ref)
978 Sized_symbol<size>* sym;
979 Sized_symbol<size>* oldsym;
981 if (target->is_big_endian())
982 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
983 target, name, version, only_if_ref, &oldsym
984 SELECT_SIZE_ENDIAN(size, true));
985 else
986 sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
987 target, name, version, only_if_ref, &oldsym
988 SELECT_SIZE_ENDIAN(size, false));
990 if (sym == NULL)
991 return NULL;
993 sym->init(name, value, symsize, type, binding, visibility, nonvis);
995 if (oldsym != NULL
996 && Symbol_table::should_override_with_special(oldsym))
997 oldsym->override_with_special(sym);
999 return sym;
1002 // Define a set of symbols in output sections.
1004 void
1005 Symbol_table::define_symbols(const Layout* layout, const Target* target,
1006 int count, const Define_symbol_in_section* p)
1008 for (int i = 0; i < count; ++i, ++p)
1010 Output_section* os = layout->find_output_section(p->output_section);
1011 if (os != NULL)
1012 this->define_in_output_data(target, p->name, NULL, os, p->value,
1013 p->size, p->type, p->binding,
1014 p->visibility, p->nonvis,
1015 p->offset_is_from_end, p->only_if_ref);
1016 else
1017 this->define_as_constant(target, p->name, NULL, 0, p->size, p->type,
1018 p->binding, p->visibility, p->nonvis,
1019 p->only_if_ref);
1023 // Define a set of symbols in output segments.
1025 void
1026 Symbol_table::define_symbols(const Layout* layout, const Target* target,
1027 int count, const Define_symbol_in_segment* p)
1029 for (int i = 0; i < count; ++i, ++p)
1031 Output_segment* os = layout->find_output_segment(p->segment_type,
1032 p->segment_flags_set,
1033 p->segment_flags_clear);
1034 if (os != NULL)
1035 this->define_in_output_segment(target, p->name, NULL, os, p->value,
1036 p->size, p->type, p->binding,
1037 p->visibility, p->nonvis,
1038 p->offset_base, p->only_if_ref);
1039 else
1040 this->define_as_constant(target, p->name, NULL, 0, p->size, p->type,
1041 p->binding, p->visibility, p->nonvis,
1042 p->only_if_ref);
1046 // Set the dynamic symbol indexes. INDEX is the index of the first
1047 // global dynamic symbol. Pointers to the symbols are stored into the
1048 // vector SYMS. The names are added to DYNPOOL. This returns an
1049 // updated dynamic symbol index.
1051 unsigned int
1052 Symbol_table::set_dynsym_indexes(const General_options* options,
1053 const Target* target,
1054 unsigned int index,
1055 std::vector<Symbol*>* syms,
1056 Stringpool* dynpool,
1057 Versions* versions)
1059 for (Symbol_table_type::iterator p = this->table_.begin();
1060 p != this->table_.end();
1061 ++p)
1063 Symbol* sym = p->second;
1065 // Note that SYM may already have a dynamic symbol index, since
1066 // some symbols appear more than once in the symbol table, with
1067 // and without a version.
1069 if (!sym->needs_dynsym_entry()
1070 && (!options->export_dynamic()
1071 || !sym->in_reg()
1072 || !sym->is_externally_visible()))
1073 sym->set_dynsym_index(-1U);
1074 else if (!sym->has_dynsym_index())
1076 sym->set_dynsym_index(index);
1077 ++index;
1078 syms->push_back(sym);
1079 dynpool->add(sym->name(), NULL);
1081 // Record any version information.
1082 if (sym->version() != NULL)
1083 versions->record_version(options, dynpool, sym);
1087 // Finish up the versions. In some cases this may add new dynamic
1088 // symbols.
1089 index = versions->finalize(target, this, index, syms);
1091 return index;
1094 // Set the final values for all the symbols. The index of the first
1095 // global symbol in the output file is INDEX. Record the file offset
1096 // OFF. Add their names to POOL. Return the new file offset.
1098 off_t
1099 Symbol_table::finalize(unsigned int index, off_t off, off_t dynoff,
1100 size_t dyn_global_index, size_t dyncount,
1101 Stringpool* pool)
1103 off_t ret;
1105 gold_assert(index != 0);
1106 this->first_global_index_ = index;
1108 this->dynamic_offset_ = dynoff;
1109 this->first_dynamic_global_index_ = dyn_global_index;
1110 this->dynamic_count_ = dyncount;
1112 if (this->size_ == 32)
1113 ret = this->sized_finalize<32>(index, off, pool);
1114 else if (this->size_ == 64)
1115 ret = this->sized_finalize<64>(index, off, pool);
1116 else
1117 gold_unreachable();
1119 // Now that we have the final symbol table, we can reliably note
1120 // which symbols should get warnings.
1121 this->warnings_.note_warnings(this);
1123 return ret;
1126 // Set the final value for all the symbols. This is called after
1127 // Layout::finalize, so all the output sections have their final
1128 // address.
1130 template<int size>
1131 off_t
1132 Symbol_table::sized_finalize(unsigned index, off_t off, Stringpool* pool)
1134 off = align_address(off, size >> 3);
1135 this->offset_ = off;
1137 size_t orig_index = index;
1139 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1140 for (Symbol_table_type::iterator p = this->table_.begin();
1141 p != this->table_.end();
1142 ++p)
1144 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
1146 // FIXME: Here we need to decide which symbols should go into
1147 // the output file, based on --strip.
1149 // The default version of a symbol may appear twice in the
1150 // symbol table. We only need to finalize it once.
1151 if (sym->has_symtab_index())
1152 continue;
1154 if (!sym->in_reg())
1156 gold_assert(!sym->has_symtab_index());
1157 sym->set_symtab_index(-1U);
1158 gold_assert(sym->dynsym_index() == -1U);
1159 continue;
1162 typename Sized_symbol<size>::Value_type value;
1164 switch (sym->source())
1166 case Symbol::FROM_OBJECT:
1168 unsigned int shndx = sym->shndx();
1170 // FIXME: We need some target specific support here.
1171 if (shndx >= elfcpp::SHN_LORESERVE
1172 && shndx != elfcpp::SHN_ABS)
1174 fprintf(stderr, _("%s: %s: unsupported symbol section 0x%x\n"),
1175 program_name, sym->name(), shndx);
1176 gold_exit(false);
1179 Object* symobj = sym->object();
1180 if (symobj->is_dynamic())
1182 value = 0;
1183 shndx = elfcpp::SHN_UNDEF;
1185 else if (shndx == elfcpp::SHN_UNDEF)
1186 value = 0;
1187 else if (shndx == elfcpp::SHN_ABS)
1188 value = sym->value();
1189 else
1191 Relobj* relobj = static_cast<Relobj*>(symobj);
1192 off_t secoff;
1193 Output_section* os = relobj->output_section(shndx, &secoff);
1195 if (os == NULL)
1197 sym->set_symtab_index(-1U);
1198 gold_assert(sym->dynsym_index() == -1U);
1199 continue;
1202 value = sym->value() + os->address() + secoff;
1205 break;
1207 case Symbol::IN_OUTPUT_DATA:
1209 Output_data* od = sym->output_data();
1210 value = sym->value() + od->address();
1211 if (sym->offset_is_from_end())
1212 value += od->data_size();
1214 break;
1216 case Symbol::IN_OUTPUT_SEGMENT:
1218 Output_segment* os = sym->output_segment();
1219 value = sym->value() + os->vaddr();
1220 switch (sym->offset_base())
1222 case Symbol::SEGMENT_START:
1223 break;
1224 case Symbol::SEGMENT_END:
1225 value += os->memsz();
1226 break;
1227 case Symbol::SEGMENT_BSS:
1228 value += os->filesz();
1229 break;
1230 default:
1231 gold_unreachable();
1234 break;
1236 case Symbol::CONSTANT:
1237 value = sym->value();
1238 break;
1240 default:
1241 gold_unreachable();
1244 sym->set_value(value);
1245 sym->set_symtab_index(index);
1246 pool->add(sym->name(), NULL);
1247 ++index;
1248 off += sym_size;
1251 this->output_count_ = index - orig_index;
1253 return off;
1256 // Write out the global symbols.
1258 void
1259 Symbol_table::write_globals(const Target* target, const Stringpool* sympool,
1260 const Stringpool* dynpool, Output_file* of) const
1262 if (this->size_ == 32)
1264 if (target->is_big_endian())
1265 this->sized_write_globals<32, true>(target, sympool, dynpool, of);
1266 else
1267 this->sized_write_globals<32, false>(target, sympool, dynpool, of);
1269 else if (this->size_ == 64)
1271 if (target->is_big_endian())
1272 this->sized_write_globals<64, true>(target, sympool, dynpool, of);
1273 else
1274 this->sized_write_globals<64, false>(target, sympool, dynpool, of);
1276 else
1277 gold_unreachable();
1280 // Write out the global symbols.
1282 template<int size, bool big_endian>
1283 void
1284 Symbol_table::sized_write_globals(const Target*,
1285 const Stringpool* sympool,
1286 const Stringpool* dynpool,
1287 Output_file* of) const
1289 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1290 unsigned int index = this->first_global_index_;
1291 const off_t oview_size = this->output_count_ * sym_size;
1292 unsigned char* const psyms = of->get_output_view(this->offset_, oview_size);
1294 unsigned int dynamic_count = this->dynamic_count_;
1295 off_t dynamic_size = dynamic_count * sym_size;
1296 unsigned int first_dynamic_global_index = this->first_dynamic_global_index_;
1297 unsigned char* dynamic_view;
1298 if (this->dynamic_offset_ == 0)
1299 dynamic_view = NULL;
1300 else
1301 dynamic_view = of->get_output_view(this->dynamic_offset_, dynamic_size);
1303 unsigned char* ps = psyms;
1304 for (Symbol_table_type::const_iterator p = this->table_.begin();
1305 p != this->table_.end();
1306 ++p)
1308 Sized_symbol<size>* sym = static_cast<Sized_symbol<size>*>(p->second);
1310 unsigned int sym_index = sym->symtab_index();
1311 unsigned int dynsym_index;
1312 if (dynamic_view == NULL)
1313 dynsym_index = -1U;
1314 else
1315 dynsym_index = sym->dynsym_index();
1317 if (sym_index == -1U && dynsym_index == -1U)
1319 // This symbol is not included in the output file.
1320 continue;
1323 if (sym_index == index)
1324 ++index;
1325 else if (sym_index != -1U)
1327 // We have already seen this symbol, because it has a
1328 // default version.
1329 gold_assert(sym_index < index);
1330 if (dynsym_index == -1U)
1331 continue;
1332 sym_index = -1U;
1335 unsigned int shndx;
1336 switch (sym->source())
1338 case Symbol::FROM_OBJECT:
1340 unsigned int in_shndx = sym->shndx();
1342 // FIXME: We need some target specific support here.
1343 if (in_shndx >= elfcpp::SHN_LORESERVE
1344 && in_shndx != elfcpp::SHN_ABS)
1346 fprintf(stderr, _("%s: %s: unsupported symbol section 0x%x\n"),
1347 program_name, sym->name(), in_shndx);
1348 gold_exit(false);
1351 Object* symobj = sym->object();
1352 if (symobj->is_dynamic())
1354 // FIXME.
1355 shndx = elfcpp::SHN_UNDEF;
1357 else if (in_shndx == elfcpp::SHN_UNDEF
1358 || in_shndx == elfcpp::SHN_ABS)
1359 shndx = in_shndx;
1360 else
1362 Relobj* relobj = static_cast<Relobj*>(symobj);
1363 off_t secoff;
1364 Output_section* os = relobj->output_section(in_shndx, &secoff);
1365 gold_assert(os != NULL);
1366 shndx = os->out_shndx();
1369 break;
1371 case Symbol::IN_OUTPUT_DATA:
1372 shndx = sym->output_data()->out_shndx();
1373 break;
1375 case Symbol::IN_OUTPUT_SEGMENT:
1376 shndx = elfcpp::SHN_ABS;
1377 break;
1379 case Symbol::CONSTANT:
1380 shndx = elfcpp::SHN_ABS;
1381 break;
1383 default:
1384 gold_unreachable();
1387 if (sym_index != -1U)
1389 this->sized_write_symbol SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
1390 sym, shndx, sympool, ps
1391 SELECT_SIZE_ENDIAN(size, big_endian));
1392 ps += sym_size;
1395 if (dynsym_index != -1U)
1397 dynsym_index -= first_dynamic_global_index;
1398 gold_assert(dynsym_index < dynamic_count);
1399 unsigned char* pd = dynamic_view + (dynsym_index * sym_size);
1400 this->sized_write_symbol SELECT_SIZE_ENDIAN_NAME(size, big_endian) (
1401 sym, shndx, dynpool, pd
1402 SELECT_SIZE_ENDIAN(size, big_endian));
1406 gold_assert(ps - psyms == oview_size);
1408 of->write_output_view(this->offset_, oview_size, psyms);
1409 if (dynamic_view != NULL)
1410 of->write_output_view(this->dynamic_offset_, dynamic_size, dynamic_view);
1413 // Write out the symbol SYM, in section SHNDX, to P. POOL is the
1414 // strtab holding the name.
1416 template<int size, bool big_endian>
1417 void
1418 Symbol_table::sized_write_symbol(Sized_symbol<size>* sym,
1419 unsigned int shndx,
1420 const Stringpool* pool,
1421 unsigned char* p
1422 ACCEPT_SIZE_ENDIAN) const
1424 elfcpp::Sym_write<size, big_endian> osym(p);
1425 osym.put_st_name(pool->get_offset(sym->name()));
1426 osym.put_st_value(sym->value());
1427 osym.put_st_size(sym->symsize());
1428 osym.put_st_info(elfcpp::elf_st_info(sym->binding(), sym->type()));
1429 osym.put_st_other(elfcpp::elf_st_other(sym->visibility(), sym->nonvis()));
1430 osym.put_st_shndx(shndx);
1433 // Write out a section symbol. Return the update offset.
1435 void
1436 Symbol_table::write_section_symbol(const Target* target,
1437 const Output_section *os,
1438 Output_file* of,
1439 off_t offset) const
1441 if (this->size_ == 32)
1443 if (target->is_big_endian())
1444 this->sized_write_section_symbol<32, true>(os, of, offset);
1445 else
1446 this->sized_write_section_symbol<32, false>(os, of, offset);
1448 else if (this->size_ == 64)
1450 if (target->is_big_endian())
1451 this->sized_write_section_symbol<64, true>(os, of, offset);
1452 else
1453 this->sized_write_section_symbol<64, false>(os, of, offset);
1455 else
1456 gold_unreachable();
1459 // Write out a section symbol, specialized for size and endianness.
1461 template<int size, bool big_endian>
1462 void
1463 Symbol_table::sized_write_section_symbol(const Output_section* os,
1464 Output_file* of,
1465 off_t offset) const
1467 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
1469 unsigned char* pov = of->get_output_view(offset, sym_size);
1471 elfcpp::Sym_write<size, big_endian> osym(pov);
1472 osym.put_st_name(0);
1473 osym.put_st_value(os->address());
1474 osym.put_st_size(0);
1475 osym.put_st_info(elfcpp::elf_st_info(elfcpp::STB_LOCAL,
1476 elfcpp::STT_SECTION));
1477 osym.put_st_other(elfcpp::elf_st_other(elfcpp::STV_DEFAULT, 0));
1478 osym.put_st_shndx(os->out_shndx());
1480 of->write_output_view(offset, sym_size, pov);
1483 // Warnings functions.
1485 // Add a new warning.
1487 void
1488 Warnings::add_warning(Symbol_table* symtab, const char* name, Object* obj,
1489 unsigned int shndx)
1491 name = symtab->canonicalize_name(name);
1492 this->warnings_[name].set(obj, shndx);
1495 // Look through the warnings and mark the symbols for which we should
1496 // warn. This is called during Layout::finalize when we know the
1497 // sources for all the symbols.
1499 void
1500 Warnings::note_warnings(Symbol_table* symtab)
1502 for (Warning_table::iterator p = this->warnings_.begin();
1503 p != this->warnings_.end();
1504 ++p)
1506 Symbol* sym = symtab->lookup(p->first, NULL);
1507 if (sym != NULL
1508 && sym->source() == Symbol::FROM_OBJECT
1509 && sym->object() == p->second.object)
1511 sym->set_has_warning();
1513 // Read the section contents to get the warning text. It
1514 // would be nicer if we only did this if we have to actually
1515 // issue a warning. Unfortunately, warnings are issued as
1516 // we relocate sections. That means that we can not lock
1517 // the object then, as we might try to issue the same
1518 // warning multiple times simultaneously.
1520 Task_locker_obj<Object> tl(*p->second.object);
1521 const unsigned char* c;
1522 off_t len;
1523 c = p->second.object->section_contents(p->second.shndx, &len);
1524 p->second.set_text(reinterpret_cast<const char*>(c), len);
1530 // Issue a warning. This is called when we see a relocation against a
1531 // symbol for which has a warning.
1533 void
1534 Warnings::issue_warning(const Symbol* sym, const std::string& location) const
1536 gold_assert(sym->has_warning());
1537 Warning_table::const_iterator p = this->warnings_.find(sym->name());
1538 gold_assert(p != this->warnings_.end());
1539 fprintf(stderr, _("%s: %s: warning: %s\n"), program_name, location.c_str(),
1540 p->second.text.c_str());
1543 // Instantiate the templates we need. We could use the configure
1544 // script to restrict this to only the ones needed for implemented
1545 // targets.
1547 #ifdef HAVE_TARGET_32_LITTLE
1548 template
1549 void
1550 Symbol_table::add_from_relobj<32, false>(
1551 Sized_relobj<32, false>* relobj,
1552 const unsigned char* syms,
1553 size_t count,
1554 const char* sym_names,
1555 size_t sym_name_size,
1556 Symbol** sympointers);
1557 #endif
1559 #ifdef HAVE_TARGET_32_BIG
1560 template
1561 void
1562 Symbol_table::add_from_relobj<32, true>(
1563 Sized_relobj<32, true>* relobj,
1564 const unsigned char* syms,
1565 size_t count,
1566 const char* sym_names,
1567 size_t sym_name_size,
1568 Symbol** sympointers);
1569 #endif
1571 #ifdef HAVE_TARGET_64_LITTLE
1572 template
1573 void
1574 Symbol_table::add_from_relobj<64, false>(
1575 Sized_relobj<64, false>* relobj,
1576 const unsigned char* syms,
1577 size_t count,
1578 const char* sym_names,
1579 size_t sym_name_size,
1580 Symbol** sympointers);
1581 #endif
1583 #ifdef HAVE_TARGET_64_BIG
1584 template
1585 void
1586 Symbol_table::add_from_relobj<64, true>(
1587 Sized_relobj<64, true>* relobj,
1588 const unsigned char* syms,
1589 size_t count,
1590 const char* sym_names,
1591 size_t sym_name_size,
1592 Symbol** sympointers);
1593 #endif
1595 #ifdef HAVE_TARGET_32_LITTLE
1596 template
1597 void
1598 Symbol_table::add_from_dynobj<32, false>(
1599 Sized_dynobj<32, false>* dynobj,
1600 const unsigned char* syms,
1601 size_t count,
1602 const char* sym_names,
1603 size_t sym_name_size,
1604 const unsigned char* versym,
1605 size_t versym_size,
1606 const std::vector<const char*>* version_map);
1607 #endif
1609 #ifdef HAVE_TARGET_32_BIG
1610 template
1611 void
1612 Symbol_table::add_from_dynobj<32, true>(
1613 Sized_dynobj<32, true>* dynobj,
1614 const unsigned char* syms,
1615 size_t count,
1616 const char* sym_names,
1617 size_t sym_name_size,
1618 const unsigned char* versym,
1619 size_t versym_size,
1620 const std::vector<const char*>* version_map);
1621 #endif
1623 #ifdef HAVE_TARGET_64_LITTLE
1624 template
1625 void
1626 Symbol_table::add_from_dynobj<64, false>(
1627 Sized_dynobj<64, false>* dynobj,
1628 const unsigned char* syms,
1629 size_t count,
1630 const char* sym_names,
1631 size_t sym_name_size,
1632 const unsigned char* versym,
1633 size_t versym_size,
1634 const std::vector<const char*>* version_map);
1635 #endif
1637 #ifdef HAVE_TARGET_64_BIG
1638 template
1639 void
1640 Symbol_table::add_from_dynobj<64, true>(
1641 Sized_dynobj<64, true>* dynobj,
1642 const unsigned char* syms,
1643 size_t count,
1644 const char* sym_names,
1645 size_t sym_name_size,
1646 const unsigned char* versym,
1647 size_t versym_size,
1648 const std::vector<const char*>* version_map);
1649 #endif
1651 } // End namespace gold.