1 // resolve.cc -- symbol resolution for gold
3 // Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
33 // Symbol methods used in this file.
35 // Override the fields in Symbol.
37 template<int size, bool big_endian>
39 Symbol::override_base(const elfcpp::Sym<size, big_endian>& sym,
40 unsigned int st_shndx, bool is_ordinary,
41 Object* object, const char* version)
43 gold_assert(this->source_ == FROM_OBJECT);
44 this->u_.from_object.object = object;
45 if (version != NULL && this->version() != version)
47 gold_assert(this->version() == NULL);
48 this->version_ = version;
50 this->u_.from_object.shndx = st_shndx;
51 this->is_ordinary_shndx_ = is_ordinary;
52 this->type_ = sym.get_st_type();
53 this->binding_ = sym.get_st_bind();
54 this->visibility_ = sym.get_st_visibility();
55 this->nonvis_ = sym.get_st_nonvis();
56 if (object->is_dynamic())
62 // Override the fields in Sized_symbol.
65 template<bool big_endian>
67 Sized_symbol<size>::override(const elfcpp::Sym<size, big_endian>& sym,
68 unsigned st_shndx, bool is_ordinary,
69 Object* object, const char* version)
71 this->override_base(sym, st_shndx, is_ordinary, object, version);
72 this->value_ = sym.get_st_value();
73 this->symsize_ = sym.get_st_size();
76 // Override TOSYM with symbol FROMSYM, defined in OBJECT, with version
77 // VERSION. This handles all aliases of TOSYM.
79 template<int size, bool big_endian>
81 Symbol_table::override(Sized_symbol<size>* tosym,
82 const elfcpp::Sym<size, big_endian>& fromsym,
83 unsigned int st_shndx, bool is_ordinary,
84 Object* object, const char* version)
86 tosym->override(fromsym, st_shndx, is_ordinary, object, version);
87 if (tosym->has_alias())
89 Symbol* sym = this->weak_aliases_[tosym];
90 gold_assert(sym != NULL);
91 Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
94 ssym->override(fromsym, st_shndx, is_ordinary, object, version);
95 sym = this->weak_aliases_[ssym];
96 gold_assert(sym != NULL);
97 ssym = this->get_sized_symbol<size>(sym);
99 while (ssym != tosym);
103 // The resolve functions build a little code for each symbol.
104 // Bit 0: 0 for global, 1 for weak.
105 // Bit 1: 0 for regular object, 1 for shared object
106 // Bits 2-3: 0 for normal, 1 for undefined, 2 for common
107 // This gives us values from 0 to 11.
109 static const int global_or_weak_shift = 0;
110 static const unsigned int global_flag = 0 << global_or_weak_shift;
111 static const unsigned int weak_flag = 1 << global_or_weak_shift;
113 static const int regular_or_dynamic_shift = 1;
114 static const unsigned int regular_flag = 0 << regular_or_dynamic_shift;
115 static const unsigned int dynamic_flag = 1 << regular_or_dynamic_shift;
117 static const int def_undef_or_common_shift = 2;
118 static const unsigned int def_flag = 0 << def_undef_or_common_shift;
119 static const unsigned int undef_flag = 1 << def_undef_or_common_shift;
120 static const unsigned int common_flag = 2 << def_undef_or_common_shift;
122 // This convenience function combines all the flags based on facts
126 symbol_to_bits(elfcpp::STB binding, bool is_dynamic,
127 unsigned int shndx, bool is_ordinary, elfcpp::STT type)
133 case elfcpp::STB_GLOBAL:
137 case elfcpp::STB_WEAK:
141 case elfcpp::STB_LOCAL:
142 // We should only see externally visible symbols in the symbol
144 gold_error(_("invalid STB_LOCAL symbol in external symbols"));
148 // Any target which wants to handle STB_LOOS, etc., needs to
149 // define a resolve method.
150 gold_error(_("unsupported symbol binding"));
155 bits |= dynamic_flag;
157 bits |= regular_flag;
161 case elfcpp::SHN_UNDEF:
165 case elfcpp::SHN_COMMON:
171 if (type == elfcpp::STT_COMMON)
181 // Resolve a symbol. This is called the second and subsequent times
182 // we see a symbol. TO is the pre-existing symbol. ST_SHNDX is the
183 // section index for SYM, possibly adjusted for many sections.
184 // IS_ORDINARY is whether ST_SHNDX is a normal section index rather
185 // than a special code. ORIG_ST_SHNDX is the original section index,
186 // before any munging because of discarded sections, except that all
187 // non-ordinary section indexes are mapped to SHN_UNDEF. VERSION of
188 // the version of SYM.
190 template<int size, bool big_endian>
192 Symbol_table::resolve(Sized_symbol<size>* to,
193 const elfcpp::Sym<size, big_endian>& sym,
194 unsigned int st_shndx, bool is_ordinary,
195 unsigned int orig_st_shndx,
196 Object* object, const char* version)
198 if (object->target()->has_resolve())
200 Sized_target<size, big_endian>* sized_target;
201 sized_target = object->sized_target<size, big_endian>();
202 sized_target->resolve(to, sym, object, version);
206 if (!object->is_dynamic())
208 // Record that we've seen this symbol in a regular object.
213 // Record that we've seen this symbol in a dynamic object.
217 unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
218 object->is_dynamic(),
219 st_shndx, is_ordinary,
222 bool adjust_common_sizes;
223 if (Symbol_table::should_override(to, frombits, object,
224 &adjust_common_sizes))
226 typename Sized_symbol<size>::Size_type tosize = to->symsize();
228 this->override(to, sym, st_shndx, is_ordinary, object, version);
230 if (adjust_common_sizes && tosize > to->symsize())
231 to->set_symsize(tosize);
235 if (adjust_common_sizes && sym.get_st_size() > to->symsize())
236 to->set_symsize(sym.get_st_size());
239 // A new weak undefined reference, merging with an old weak
240 // reference, could be a One Definition Rule (ODR) violation --
241 // especially if the types or sizes of the references differ. We'll
242 // store such pairs and look them up later to make sure they
243 // actually refer to the same lines of code. (Note: not all ODR
244 // violations can be found this way, and not everything this finds
245 // is an ODR violation. But it's helpful to warn about.)
247 if (parameters->options().detect_odr_violations()
248 && sym.get_st_bind() == elfcpp::STB_WEAK
249 && to->binding() == elfcpp::STB_WEAK
250 && orig_st_shndx != elfcpp::SHN_UNDEF
251 && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
253 && sym.get_st_size() != 0 // Ignore weird 0-sized symbols.
254 && to->symsize() != 0
255 && (sym.get_st_type() != to->type()
256 || sym.get_st_size() != to->symsize())
257 // C does not have a concept of ODR, so we only need to do this
258 // on C++ symbols. These have (mangled) names starting with _Z.
259 && to->name()[0] == '_' && to->name()[1] == 'Z')
261 Symbol_location fromloc
262 = { object, orig_st_shndx, sym.get_st_value() };
263 Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
265 this->candidate_odr_violations_[to->name()].insert(fromloc);
266 this->candidate_odr_violations_[to->name()].insert(toloc);
270 // Handle the core of symbol resolution. This is called with the
271 // existing symbol, TO, and a bitflag describing the new symbol. This
272 // returns true if we should override the existing symbol with the new
273 // one, and returns false otherwise. It sets *ADJUST_COMMON_SIZES to
274 // true if we should set the symbol size to the maximum of the TO and
275 // FROM sizes. It handles error conditions.
278 Symbol_table::should_override(const Symbol* to, unsigned int frombits,
279 Object* object, bool* adjust_common_sizes)
281 *adjust_common_sizes = false;
284 if (to->source() == Symbol::IS_UNDEFINED)
285 tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_UNDEF, true,
287 else if (to->source() != Symbol::FROM_OBJECT)
288 tobits = symbol_to_bits(to->binding(), false, elfcpp::SHN_ABS, false,
293 unsigned int shndx = to->shndx(&is_ordinary);
294 tobits = symbol_to_bits(to->binding(),
295 to->object()->is_dynamic(),
301 // FIXME: Warn if either but not both of TO and SYM are STT_TLS.
303 // We use a giant switch table for symbol resolution. This code is
304 // unwieldy, but: 1) it is efficient; 2) we definitely handle all
305 // cases; 3) it is easy to change the handling of a particular case.
306 // The alternative would be a series of conditionals, but it is easy
307 // to get the ordering wrong. This could also be done as a table,
308 // but that is no easier to understand than this large switch
311 // These are the values generated by the bit codes.
314 DEF = global_flag | regular_flag | def_flag,
315 WEAK_DEF = weak_flag | regular_flag | def_flag,
316 DYN_DEF = global_flag | dynamic_flag | def_flag,
317 DYN_WEAK_DEF = weak_flag | dynamic_flag | def_flag,
318 UNDEF = global_flag | regular_flag | undef_flag,
319 WEAK_UNDEF = weak_flag | regular_flag | undef_flag,
320 DYN_UNDEF = global_flag | dynamic_flag | undef_flag,
321 DYN_WEAK_UNDEF = weak_flag | dynamic_flag | undef_flag,
322 COMMON = global_flag | regular_flag | common_flag,
323 WEAK_COMMON = weak_flag | regular_flag | common_flag,
324 DYN_COMMON = global_flag | dynamic_flag | common_flag,
325 DYN_WEAK_COMMON = weak_flag | dynamic_flag | common_flag
328 switch (tobits * 16 + frombits)
331 // Two definitions of the same symbol.
333 // If either symbol is defined by an object included using
334 // --just-symbols, then don't warn. This is for compatibility
335 // with the GNU linker. FIXME: This is a hack.
336 if ((to->source() == Symbol::FROM_OBJECT && to->object()->just_symbols())
337 || object->just_symbols())
340 // FIXME: Do a better job of reporting locations.
341 gold_error(_("%s: multiple definition of %s"),
342 object != NULL ? object->name().c_str() : _("command line"),
343 to->demangled_name().c_str());
344 gold_error(_("%s: previous definition here"),
345 (to->source() == Symbol::FROM_OBJECT
346 ? to->object()->name().c_str()
347 : _("command line")));
350 case WEAK_DEF * 16 + DEF:
351 // We've seen a weak definition, and now we see a strong
352 // definition. In the original SVR4 linker, this was treated as
353 // a multiple definition error. In the Solaris linker and the
354 // GNU linker, a weak definition followed by a regular
355 // definition causes the weak definition to be overridden. We
356 // are currently compatible with the GNU linker. In the future
357 // we should add a target specific option to change this.
361 case DYN_DEF * 16 + DEF:
362 case DYN_WEAK_DEF * 16 + DEF:
363 // We've seen a definition in a dynamic object, and now we see a
364 // definition in a regular object. The definition in the
365 // regular object overrides the definition in the dynamic
369 case UNDEF * 16 + DEF:
370 case WEAK_UNDEF * 16 + DEF:
371 case DYN_UNDEF * 16 + DEF:
372 case DYN_WEAK_UNDEF * 16 + DEF:
373 // We've seen an undefined reference, and now we see a
374 // definition. We use the definition.
377 case COMMON * 16 + DEF:
378 case WEAK_COMMON * 16 + DEF:
379 case DYN_COMMON * 16 + DEF:
380 case DYN_WEAK_COMMON * 16 + DEF:
381 // We've seen a common symbol and now we see a definition. The
382 // definition overrides. FIXME: We should optionally issue, version a
386 case DEF * 16 + WEAK_DEF:
387 case WEAK_DEF * 16 + WEAK_DEF:
388 // We've seen a definition and now we see a weak definition. We
389 // ignore the new weak definition.
392 case DYN_DEF * 16 + WEAK_DEF:
393 case DYN_WEAK_DEF * 16 + WEAK_DEF:
394 // We've seen a dynamic definition and now we see a regular weak
395 // definition. The regular weak definition overrides.
398 case UNDEF * 16 + WEAK_DEF:
399 case WEAK_UNDEF * 16 + WEAK_DEF:
400 case DYN_UNDEF * 16 + WEAK_DEF:
401 case DYN_WEAK_UNDEF * 16 + WEAK_DEF:
402 // A weak definition of a currently undefined symbol.
405 case COMMON * 16 + WEAK_DEF:
406 case WEAK_COMMON * 16 + WEAK_DEF:
407 // A weak definition does not override a common definition.
410 case DYN_COMMON * 16 + WEAK_DEF:
411 case DYN_WEAK_COMMON * 16 + WEAK_DEF:
412 // A weak definition does override a definition in a dynamic
413 // object. FIXME: We should optionally issue a warning.
416 case DEF * 16 + DYN_DEF:
417 case WEAK_DEF * 16 + DYN_DEF:
418 case DYN_DEF * 16 + DYN_DEF:
419 case DYN_WEAK_DEF * 16 + DYN_DEF:
420 // Ignore a dynamic definition if we already have a definition.
423 case UNDEF * 16 + DYN_DEF:
424 case WEAK_UNDEF * 16 + DYN_DEF:
425 case DYN_UNDEF * 16 + DYN_DEF:
426 case DYN_WEAK_UNDEF * 16 + DYN_DEF:
427 // Use a dynamic definition if we have a reference.
430 case COMMON * 16 + DYN_DEF:
431 case WEAK_COMMON * 16 + DYN_DEF:
432 case DYN_COMMON * 16 + DYN_DEF:
433 case DYN_WEAK_COMMON * 16 + DYN_DEF:
434 // Ignore a dynamic definition if we already have a common
438 case DEF * 16 + DYN_WEAK_DEF:
439 case WEAK_DEF * 16 + DYN_WEAK_DEF:
440 case DYN_DEF * 16 + DYN_WEAK_DEF:
441 case DYN_WEAK_DEF * 16 + DYN_WEAK_DEF:
442 // Ignore a weak dynamic definition if we already have a
446 case UNDEF * 16 + DYN_WEAK_DEF:
447 case WEAK_UNDEF * 16 + DYN_WEAK_DEF:
448 case DYN_UNDEF * 16 + DYN_WEAK_DEF:
449 case DYN_WEAK_UNDEF * 16 + DYN_WEAK_DEF:
450 // Use a weak dynamic definition if we have a reference.
453 case COMMON * 16 + DYN_WEAK_DEF:
454 case WEAK_COMMON * 16 + DYN_WEAK_DEF:
455 case DYN_COMMON * 16 + DYN_WEAK_DEF:
456 case DYN_WEAK_COMMON * 16 + DYN_WEAK_DEF:
457 // Ignore a weak dynamic definition if we already have a common
461 case DEF * 16 + UNDEF:
462 case WEAK_DEF * 16 + UNDEF:
463 case DYN_DEF * 16 + UNDEF:
464 case DYN_WEAK_DEF * 16 + UNDEF:
465 case UNDEF * 16 + UNDEF:
466 // A new undefined reference tells us nothing.
469 case WEAK_UNDEF * 16 + UNDEF:
470 case DYN_UNDEF * 16 + UNDEF:
471 case DYN_WEAK_UNDEF * 16 + UNDEF:
472 // A strong undef overrides a dynamic or weak undef.
475 case COMMON * 16 + UNDEF:
476 case WEAK_COMMON * 16 + UNDEF:
477 case DYN_COMMON * 16 + UNDEF:
478 case DYN_WEAK_COMMON * 16 + UNDEF:
479 // A new undefined reference tells us nothing.
482 case DEF * 16 + WEAK_UNDEF:
483 case WEAK_DEF * 16 + WEAK_UNDEF:
484 case DYN_DEF * 16 + WEAK_UNDEF:
485 case DYN_WEAK_DEF * 16 + WEAK_UNDEF:
486 case UNDEF * 16 + WEAK_UNDEF:
487 case WEAK_UNDEF * 16 + WEAK_UNDEF:
488 case DYN_UNDEF * 16 + WEAK_UNDEF:
489 case DYN_WEAK_UNDEF * 16 + WEAK_UNDEF:
490 case COMMON * 16 + WEAK_UNDEF:
491 case WEAK_COMMON * 16 + WEAK_UNDEF:
492 case DYN_COMMON * 16 + WEAK_UNDEF:
493 case DYN_WEAK_COMMON * 16 + WEAK_UNDEF:
494 // A new weak undefined reference tells us nothing.
497 case DEF * 16 + DYN_UNDEF:
498 case WEAK_DEF * 16 + DYN_UNDEF:
499 case DYN_DEF * 16 + DYN_UNDEF:
500 case DYN_WEAK_DEF * 16 + DYN_UNDEF:
501 case UNDEF * 16 + DYN_UNDEF:
502 case WEAK_UNDEF * 16 + DYN_UNDEF:
503 case DYN_UNDEF * 16 + DYN_UNDEF:
504 case DYN_WEAK_UNDEF * 16 + DYN_UNDEF:
505 case COMMON * 16 + DYN_UNDEF:
506 case WEAK_COMMON * 16 + DYN_UNDEF:
507 case DYN_COMMON * 16 + DYN_UNDEF:
508 case DYN_WEAK_COMMON * 16 + DYN_UNDEF:
509 // A new dynamic undefined reference tells us nothing.
512 case DEF * 16 + DYN_WEAK_UNDEF:
513 case WEAK_DEF * 16 + DYN_WEAK_UNDEF:
514 case DYN_DEF * 16 + DYN_WEAK_UNDEF:
515 case DYN_WEAK_DEF * 16 + DYN_WEAK_UNDEF:
516 case UNDEF * 16 + DYN_WEAK_UNDEF:
517 case WEAK_UNDEF * 16 + DYN_WEAK_UNDEF:
518 case DYN_UNDEF * 16 + DYN_WEAK_UNDEF:
519 case DYN_WEAK_UNDEF * 16 + DYN_WEAK_UNDEF:
520 case COMMON * 16 + DYN_WEAK_UNDEF:
521 case WEAK_COMMON * 16 + DYN_WEAK_UNDEF:
522 case DYN_COMMON * 16 + DYN_WEAK_UNDEF:
523 case DYN_WEAK_COMMON * 16 + DYN_WEAK_UNDEF:
524 // A new weak dynamic undefined reference tells us nothing.
527 case DEF * 16 + COMMON:
528 // A common symbol does not override a definition.
531 case WEAK_DEF * 16 + COMMON:
532 case DYN_DEF * 16 + COMMON:
533 case DYN_WEAK_DEF * 16 + COMMON:
534 // A common symbol does override a weak definition or a dynamic
538 case UNDEF * 16 + COMMON:
539 case WEAK_UNDEF * 16 + COMMON:
540 case DYN_UNDEF * 16 + COMMON:
541 case DYN_WEAK_UNDEF * 16 + COMMON:
542 // A common symbol is a definition for a reference.
545 case COMMON * 16 + COMMON:
546 // Set the size to the maximum.
547 *adjust_common_sizes = true;
550 case WEAK_COMMON * 16 + COMMON:
551 // I'm not sure just what a weak common symbol means, but
552 // presumably it can be overridden by a regular common symbol.
555 case DYN_COMMON * 16 + COMMON:
556 case DYN_WEAK_COMMON * 16 + COMMON:
557 // Use the real common symbol, but adjust the size if necessary.
558 *adjust_common_sizes = true;
561 case DEF * 16 + WEAK_COMMON:
562 case WEAK_DEF * 16 + WEAK_COMMON:
563 case DYN_DEF * 16 + WEAK_COMMON:
564 case DYN_WEAK_DEF * 16 + WEAK_COMMON:
565 // Whatever a weak common symbol is, it won't override a
569 case UNDEF * 16 + WEAK_COMMON:
570 case WEAK_UNDEF * 16 + WEAK_COMMON:
571 case DYN_UNDEF * 16 + WEAK_COMMON:
572 case DYN_WEAK_UNDEF * 16 + WEAK_COMMON:
573 // A weak common symbol is better than an undefined symbol.
576 case COMMON * 16 + WEAK_COMMON:
577 case WEAK_COMMON * 16 + WEAK_COMMON:
578 case DYN_COMMON * 16 + WEAK_COMMON:
579 case DYN_WEAK_COMMON * 16 + WEAK_COMMON:
580 // Ignore a weak common symbol in the presence of a real common
584 case DEF * 16 + DYN_COMMON:
585 case WEAK_DEF * 16 + DYN_COMMON:
586 case DYN_DEF * 16 + DYN_COMMON:
587 case DYN_WEAK_DEF * 16 + DYN_COMMON:
588 // Ignore a dynamic common symbol in the presence of a
592 case UNDEF * 16 + DYN_COMMON:
593 case WEAK_UNDEF * 16 + DYN_COMMON:
594 case DYN_UNDEF * 16 + DYN_COMMON:
595 case DYN_WEAK_UNDEF * 16 + DYN_COMMON:
596 // A dynamic common symbol is a definition of sorts.
599 case COMMON * 16 + DYN_COMMON:
600 case WEAK_COMMON * 16 + DYN_COMMON:
601 case DYN_COMMON * 16 + DYN_COMMON:
602 case DYN_WEAK_COMMON * 16 + DYN_COMMON:
603 // Set the size to the maximum.
604 *adjust_common_sizes = true;
607 case DEF * 16 + DYN_WEAK_COMMON:
608 case WEAK_DEF * 16 + DYN_WEAK_COMMON:
609 case DYN_DEF * 16 + DYN_WEAK_COMMON:
610 case DYN_WEAK_DEF * 16 + DYN_WEAK_COMMON:
611 // A common symbol is ignored in the face of a definition.
614 case UNDEF * 16 + DYN_WEAK_COMMON:
615 case WEAK_UNDEF * 16 + DYN_WEAK_COMMON:
616 case DYN_UNDEF * 16 + DYN_WEAK_COMMON:
617 case DYN_WEAK_UNDEF * 16 + DYN_WEAK_COMMON:
618 // I guess a weak common symbol is better than a definition.
621 case COMMON * 16 + DYN_WEAK_COMMON:
622 case WEAK_COMMON * 16 + DYN_WEAK_COMMON:
623 case DYN_COMMON * 16 + DYN_WEAK_COMMON:
624 case DYN_WEAK_COMMON * 16 + DYN_WEAK_COMMON:
625 // Set the size to the maximum.
626 *adjust_common_sizes = true;
634 // A special case of should_override which is only called for a strong
635 // defined symbol from a regular object file. This is used when
636 // defining special symbols.
639 Symbol_table::should_override_with_special(const Symbol* to)
641 bool adjust_common_sizes;
642 unsigned int frombits = global_flag | regular_flag | def_flag;
643 bool ret = Symbol_table::should_override(to, frombits, NULL,
644 &adjust_common_sizes);
645 gold_assert(!adjust_common_sizes);
649 // Override symbol base with a special symbol.
652 Symbol::override_base_with_special(const Symbol* from)
654 gold_assert(this->name_ == from->name_ || this->has_alias());
656 this->source_ = from->source_;
657 switch (from->source_)
660 this->u_.from_object = from->u_.from_object;
663 this->u_.in_output_data = from->u_.in_output_data;
665 case IN_OUTPUT_SEGMENT:
666 this->u_.in_output_segment = from->u_.in_output_segment;
676 if (from->version_ != NULL && this->version_ != from->version_)
678 gold_assert(this->version_ == NULL);
679 this->version_ = from->version_;
682 this->type_ = from->type_;
683 this->binding_ = from->binding_;
684 this->visibility_ = from->visibility_;
685 this->nonvis_ = from->nonvis_;
687 // Special symbols are always considered to be regular symbols.
688 this->in_reg_ = true;
690 if (from->needs_dynsym_entry_)
691 this->needs_dynsym_entry_ = true;
692 if (from->needs_dynsym_value_)
693 this->needs_dynsym_value_ = true;
695 // We shouldn't see these flags. If we do, we need to handle them
697 gold_assert(!from->is_target_special_ || this->is_target_special_);
698 gold_assert(!from->is_forwarder_);
699 gold_assert(!from->has_plt_offset_);
700 gold_assert(!from->has_warning_);
701 gold_assert(!from->is_copied_from_dynobj_);
702 gold_assert(!from->is_forced_local_);
705 // Override a symbol with a special symbol.
709 Sized_symbol<size>::override_with_special(const Sized_symbol<size>* from)
711 this->override_base_with_special(from);
712 this->value_ = from->value_;
713 this->symsize_ = from->symsize_;
716 // Override TOSYM with the special symbol FROMSYM. This handles all
721 Symbol_table::override_with_special(Sized_symbol<size>* tosym,
722 const Sized_symbol<size>* fromsym)
724 tosym->override_with_special(fromsym);
725 if (tosym->has_alias())
727 Symbol* sym = this->weak_aliases_[tosym];
728 gold_assert(sym != NULL);
729 Sized_symbol<size>* ssym = this->get_sized_symbol<size>(sym);
732 ssym->override_with_special(fromsym);
733 sym = this->weak_aliases_[ssym];
734 gold_assert(sym != NULL);
735 ssym = this->get_sized_symbol<size>(sym);
737 while (ssym != tosym);
739 if (tosym->binding() == elfcpp::STB_LOCAL)
740 this->force_local(tosym);
743 // Instantiate the templates we need. We could use the configure
744 // script to restrict this to only the ones needed for implemented
747 #ifdef HAVE_TARGET_32_LITTLE
750 Symbol_table::resolve<32, false>(
751 Sized_symbol<32>* to,
752 const elfcpp::Sym<32, false>& sym,
753 unsigned int st_shndx,
755 unsigned int orig_st_shndx,
757 const char* version);
760 #ifdef HAVE_TARGET_32_BIG
763 Symbol_table::resolve<32, true>(
764 Sized_symbol<32>* to,
765 const elfcpp::Sym<32, true>& sym,
766 unsigned int st_shndx,
768 unsigned int orig_st_shndx,
770 const char* version);
773 #ifdef HAVE_TARGET_64_LITTLE
776 Symbol_table::resolve<64, false>(
777 Sized_symbol<64>* to,
778 const elfcpp::Sym<64, false>& sym,
779 unsigned int st_shndx,
781 unsigned int orig_st_shndx,
783 const char* version);
786 #ifdef HAVE_TARGET_64_BIG
789 Symbol_table::resolve<64, true>(
790 Sized_symbol<64>* to,
791 const elfcpp::Sym<64, true>& sym,
792 unsigned int st_shndx,
794 unsigned int orig_st_shndx,
796 const char* version);
799 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
802 Symbol_table::override_with_special<32>(Sized_symbol<32>*,
803 const Sized_symbol<32>*);
806 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
809 Symbol_table::override_with_special<64>(Sized_symbol<64>*,
810 const Sized_symbol<64>*);
813 } // End namespace gold.