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::FROM_OBJECT
)
285 tobits
= symbol_to_bits(to
->binding(), false, elfcpp::SHN_ABS
, false,
290 unsigned int shndx
= to
->shndx(&is_ordinary
);
291 tobits
= symbol_to_bits(to
->binding(),
292 to
->object()->is_dynamic(),
298 // FIXME: Warn if either but not both of TO and SYM are STT_TLS.
300 // We use a giant switch table for symbol resolution. This code is
301 // unwieldy, but: 1) it is efficient; 2) we definitely handle all
302 // cases; 3) it is easy to change the handling of a particular case.
303 // The alternative would be a series of conditionals, but it is easy
304 // to get the ordering wrong. This could also be done as a table,
305 // but that is no easier to understand than this large switch
308 // These are the values generated by the bit codes.
311 DEF
= global_flag
| regular_flag
| def_flag
,
312 WEAK_DEF
= weak_flag
| regular_flag
| def_flag
,
313 DYN_DEF
= global_flag
| dynamic_flag
| def_flag
,
314 DYN_WEAK_DEF
= weak_flag
| dynamic_flag
| def_flag
,
315 UNDEF
= global_flag
| regular_flag
| undef_flag
,
316 WEAK_UNDEF
= weak_flag
| regular_flag
| undef_flag
,
317 DYN_UNDEF
= global_flag
| dynamic_flag
| undef_flag
,
318 DYN_WEAK_UNDEF
= weak_flag
| dynamic_flag
| undef_flag
,
319 COMMON
= global_flag
| regular_flag
| common_flag
,
320 WEAK_COMMON
= weak_flag
| regular_flag
| common_flag
,
321 DYN_COMMON
= global_flag
| dynamic_flag
| common_flag
,
322 DYN_WEAK_COMMON
= weak_flag
| dynamic_flag
| common_flag
325 switch (tobits
* 16 + frombits
)
328 // Two definitions of the same symbol.
330 // If either symbol is defined by an object included using
331 // --just-symbols, then don't warn. This is for compatibility
332 // with the GNU linker. FIXME: This is a hack.
333 if ((to
->source() == Symbol::FROM_OBJECT
&& to
->object()->just_symbols())
334 || object
->just_symbols())
337 // FIXME: Do a better job of reporting locations.
338 gold_error(_("%s: multiple definition of %s"),
339 object
!= NULL
? object
->name().c_str() : _("command line"),
340 to
->demangled_name().c_str());
341 gold_error(_("%s: previous definition here"),
342 (to
->source() == Symbol::FROM_OBJECT
343 ? to
->object()->name().c_str()
344 : _("command line")));
347 case WEAK_DEF
* 16 + DEF
:
348 // We've seen a weak definition, and now we see a strong
349 // definition. In the original SVR4 linker, this was treated as
350 // a multiple definition error. In the Solaris linker and the
351 // GNU linker, a weak definition followed by a regular
352 // definition causes the weak definition to be overridden. We
353 // are currently compatible with the GNU linker. In the future
354 // we should add a target specific option to change this.
358 case DYN_DEF
* 16 + DEF
:
359 case DYN_WEAK_DEF
* 16 + DEF
:
360 // We've seen a definition in a dynamic object, and now we see a
361 // definition in a regular object. The definition in the
362 // regular object overrides the definition in the dynamic
366 case UNDEF
* 16 + DEF
:
367 case WEAK_UNDEF
* 16 + DEF
:
368 case DYN_UNDEF
* 16 + DEF
:
369 case DYN_WEAK_UNDEF
* 16 + DEF
:
370 // We've seen an undefined reference, and now we see a
371 // definition. We use the definition.
374 case COMMON
* 16 + DEF
:
375 case WEAK_COMMON
* 16 + DEF
:
376 case DYN_COMMON
* 16 + DEF
:
377 case DYN_WEAK_COMMON
* 16 + DEF
:
378 // We've seen a common symbol and now we see a definition. The
379 // definition overrides. FIXME: We should optionally issue, version a
383 case DEF
* 16 + WEAK_DEF
:
384 case WEAK_DEF
* 16 + WEAK_DEF
:
385 // We've seen a definition and now we see a weak definition. We
386 // ignore the new weak definition.
389 case DYN_DEF
* 16 + WEAK_DEF
:
390 case DYN_WEAK_DEF
* 16 + WEAK_DEF
:
391 // We've seen a dynamic definition and now we see a regular weak
392 // definition. The regular weak definition overrides.
395 case UNDEF
* 16 + WEAK_DEF
:
396 case WEAK_UNDEF
* 16 + WEAK_DEF
:
397 case DYN_UNDEF
* 16 + WEAK_DEF
:
398 case DYN_WEAK_UNDEF
* 16 + WEAK_DEF
:
399 // A weak definition of a currently undefined symbol.
402 case COMMON
* 16 + WEAK_DEF
:
403 case WEAK_COMMON
* 16 + WEAK_DEF
:
404 // A weak definition does not override a common definition.
407 case DYN_COMMON
* 16 + WEAK_DEF
:
408 case DYN_WEAK_COMMON
* 16 + WEAK_DEF
:
409 // A weak definition does override a definition in a dynamic
410 // object. FIXME: We should optionally issue a warning.
413 case DEF
* 16 + DYN_DEF
:
414 case WEAK_DEF
* 16 + DYN_DEF
:
415 case DYN_DEF
* 16 + DYN_DEF
:
416 case DYN_WEAK_DEF
* 16 + DYN_DEF
:
417 // Ignore a dynamic definition if we already have a definition.
420 case UNDEF
* 16 + DYN_DEF
:
421 case WEAK_UNDEF
* 16 + DYN_DEF
:
422 case DYN_UNDEF
* 16 + DYN_DEF
:
423 case DYN_WEAK_UNDEF
* 16 + DYN_DEF
:
424 // Use a dynamic definition if we have a reference.
427 case COMMON
* 16 + DYN_DEF
:
428 case WEAK_COMMON
* 16 + DYN_DEF
:
429 case DYN_COMMON
* 16 + DYN_DEF
:
430 case DYN_WEAK_COMMON
* 16 + DYN_DEF
:
431 // Ignore a dynamic definition if we already have a common
435 case DEF
* 16 + DYN_WEAK_DEF
:
436 case WEAK_DEF
* 16 + DYN_WEAK_DEF
:
437 case DYN_DEF
* 16 + DYN_WEAK_DEF
:
438 case DYN_WEAK_DEF
* 16 + DYN_WEAK_DEF
:
439 // Ignore a weak dynamic definition if we already have a
443 case UNDEF
* 16 + DYN_WEAK_DEF
:
444 case WEAK_UNDEF
* 16 + DYN_WEAK_DEF
:
445 case DYN_UNDEF
* 16 + DYN_WEAK_DEF
:
446 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_DEF
:
447 // Use a weak dynamic definition if we have a reference.
450 case COMMON
* 16 + DYN_WEAK_DEF
:
451 case WEAK_COMMON
* 16 + DYN_WEAK_DEF
:
452 case DYN_COMMON
* 16 + DYN_WEAK_DEF
:
453 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_DEF
:
454 // Ignore a weak dynamic definition if we already have a common
458 case DEF
* 16 + UNDEF
:
459 case WEAK_DEF
* 16 + UNDEF
:
460 case DYN_DEF
* 16 + UNDEF
:
461 case DYN_WEAK_DEF
* 16 + UNDEF
:
462 case UNDEF
* 16 + UNDEF
:
463 // A new undefined reference tells us nothing.
466 case WEAK_UNDEF
* 16 + UNDEF
:
467 case DYN_UNDEF
* 16 + UNDEF
:
468 case DYN_WEAK_UNDEF
* 16 + UNDEF
:
469 // A strong undef overrides a dynamic or weak undef.
472 case COMMON
* 16 + UNDEF
:
473 case WEAK_COMMON
* 16 + UNDEF
:
474 case DYN_COMMON
* 16 + UNDEF
:
475 case DYN_WEAK_COMMON
* 16 + UNDEF
:
476 // A new undefined reference tells us nothing.
479 case DEF
* 16 + WEAK_UNDEF
:
480 case WEAK_DEF
* 16 + WEAK_UNDEF
:
481 case DYN_DEF
* 16 + WEAK_UNDEF
:
482 case DYN_WEAK_DEF
* 16 + WEAK_UNDEF
:
483 case UNDEF
* 16 + WEAK_UNDEF
:
484 case WEAK_UNDEF
* 16 + WEAK_UNDEF
:
485 case DYN_UNDEF
* 16 + WEAK_UNDEF
:
486 case DYN_WEAK_UNDEF
* 16 + WEAK_UNDEF
:
487 case COMMON
* 16 + WEAK_UNDEF
:
488 case WEAK_COMMON
* 16 + WEAK_UNDEF
:
489 case DYN_COMMON
* 16 + WEAK_UNDEF
:
490 case DYN_WEAK_COMMON
* 16 + WEAK_UNDEF
:
491 // A new weak undefined reference tells us nothing.
494 case DEF
* 16 + DYN_UNDEF
:
495 case WEAK_DEF
* 16 + DYN_UNDEF
:
496 case DYN_DEF
* 16 + DYN_UNDEF
:
497 case DYN_WEAK_DEF
* 16 + DYN_UNDEF
:
498 case UNDEF
* 16 + DYN_UNDEF
:
499 case WEAK_UNDEF
* 16 + DYN_UNDEF
:
500 case DYN_UNDEF
* 16 + DYN_UNDEF
:
501 case DYN_WEAK_UNDEF
* 16 + DYN_UNDEF
:
502 case COMMON
* 16 + DYN_UNDEF
:
503 case WEAK_COMMON
* 16 + DYN_UNDEF
:
504 case DYN_COMMON
* 16 + DYN_UNDEF
:
505 case DYN_WEAK_COMMON
* 16 + DYN_UNDEF
:
506 // A new dynamic undefined reference tells us nothing.
509 case DEF
* 16 + DYN_WEAK_UNDEF
:
510 case WEAK_DEF
* 16 + DYN_WEAK_UNDEF
:
511 case DYN_DEF
* 16 + DYN_WEAK_UNDEF
:
512 case DYN_WEAK_DEF
* 16 + DYN_WEAK_UNDEF
:
513 case UNDEF
* 16 + DYN_WEAK_UNDEF
:
514 case WEAK_UNDEF
* 16 + DYN_WEAK_UNDEF
:
515 case DYN_UNDEF
* 16 + DYN_WEAK_UNDEF
:
516 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_UNDEF
:
517 case COMMON
* 16 + DYN_WEAK_UNDEF
:
518 case WEAK_COMMON
* 16 + DYN_WEAK_UNDEF
:
519 case DYN_COMMON
* 16 + DYN_WEAK_UNDEF
:
520 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_UNDEF
:
521 // A new weak dynamic undefined reference tells us nothing.
524 case DEF
* 16 + COMMON
:
525 // A common symbol does not override a definition.
528 case WEAK_DEF
* 16 + COMMON
:
529 case DYN_DEF
* 16 + COMMON
:
530 case DYN_WEAK_DEF
* 16 + COMMON
:
531 // A common symbol does override a weak definition or a dynamic
535 case UNDEF
* 16 + COMMON
:
536 case WEAK_UNDEF
* 16 + COMMON
:
537 case DYN_UNDEF
* 16 + COMMON
:
538 case DYN_WEAK_UNDEF
* 16 + COMMON
:
539 // A common symbol is a definition for a reference.
542 case COMMON
* 16 + COMMON
:
543 // Set the size to the maximum.
544 *adjust_common_sizes
= true;
547 case WEAK_COMMON
* 16 + COMMON
:
548 // I'm not sure just what a weak common symbol means, but
549 // presumably it can be overridden by a regular common symbol.
552 case DYN_COMMON
* 16 + COMMON
:
553 case DYN_WEAK_COMMON
* 16 + COMMON
:
554 // Use the real common symbol, but adjust the size if necessary.
555 *adjust_common_sizes
= true;
558 case DEF
* 16 + WEAK_COMMON
:
559 case WEAK_DEF
* 16 + WEAK_COMMON
:
560 case DYN_DEF
* 16 + WEAK_COMMON
:
561 case DYN_WEAK_DEF
* 16 + WEAK_COMMON
:
562 // Whatever a weak common symbol is, it won't override a
566 case UNDEF
* 16 + WEAK_COMMON
:
567 case WEAK_UNDEF
* 16 + WEAK_COMMON
:
568 case DYN_UNDEF
* 16 + WEAK_COMMON
:
569 case DYN_WEAK_UNDEF
* 16 + WEAK_COMMON
:
570 // A weak common symbol is better than an undefined symbol.
573 case COMMON
* 16 + WEAK_COMMON
:
574 case WEAK_COMMON
* 16 + WEAK_COMMON
:
575 case DYN_COMMON
* 16 + WEAK_COMMON
:
576 case DYN_WEAK_COMMON
* 16 + WEAK_COMMON
:
577 // Ignore a weak common symbol in the presence of a real common
581 case DEF
* 16 + DYN_COMMON
:
582 case WEAK_DEF
* 16 + DYN_COMMON
:
583 case DYN_DEF
* 16 + DYN_COMMON
:
584 case DYN_WEAK_DEF
* 16 + DYN_COMMON
:
585 // Ignore a dynamic common symbol in the presence of a
589 case UNDEF
* 16 + DYN_COMMON
:
590 case WEAK_UNDEF
* 16 + DYN_COMMON
:
591 case DYN_UNDEF
* 16 + DYN_COMMON
:
592 case DYN_WEAK_UNDEF
* 16 + DYN_COMMON
:
593 // A dynamic common symbol is a definition of sorts.
596 case COMMON
* 16 + DYN_COMMON
:
597 case WEAK_COMMON
* 16 + DYN_COMMON
:
598 case DYN_COMMON
* 16 + DYN_COMMON
:
599 case DYN_WEAK_COMMON
* 16 + DYN_COMMON
:
600 // Set the size to the maximum.
601 *adjust_common_sizes
= true;
604 case DEF
* 16 + DYN_WEAK_COMMON
:
605 case WEAK_DEF
* 16 + DYN_WEAK_COMMON
:
606 case DYN_DEF
* 16 + DYN_WEAK_COMMON
:
607 case DYN_WEAK_DEF
* 16 + DYN_WEAK_COMMON
:
608 // A common symbol is ignored in the face of a definition.
611 case UNDEF
* 16 + DYN_WEAK_COMMON
:
612 case WEAK_UNDEF
* 16 + DYN_WEAK_COMMON
:
613 case DYN_UNDEF
* 16 + DYN_WEAK_COMMON
:
614 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_COMMON
:
615 // I guess a weak common symbol is better than a definition.
618 case COMMON
* 16 + DYN_WEAK_COMMON
:
619 case WEAK_COMMON
* 16 + DYN_WEAK_COMMON
:
620 case DYN_COMMON
* 16 + DYN_WEAK_COMMON
:
621 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_COMMON
:
622 // Set the size to the maximum.
623 *adjust_common_sizes
= true;
631 // A special case of should_override which is only called for a strong
632 // defined symbol from a regular object file. This is used when
633 // defining special symbols.
636 Symbol_table::should_override_with_special(const Symbol
* to
)
638 bool adjust_common_sizes
;
639 unsigned int frombits
= global_flag
| regular_flag
| def_flag
;
640 bool ret
= Symbol_table::should_override(to
, frombits
, NULL
,
641 &adjust_common_sizes
);
642 gold_assert(!adjust_common_sizes
);
646 // Override symbol base with a special symbol.
649 Symbol::override_base_with_special(const Symbol
* from
)
651 gold_assert(this->name_
== from
->name_
|| this->has_alias());
653 this->source_
= from
->source_
;
654 switch (from
->source_
)
657 this->u_
.from_object
= from
->u_
.from_object
;
660 this->u_
.in_output_data
= from
->u_
.in_output_data
;
662 case IN_OUTPUT_SEGMENT
:
663 this->u_
.in_output_segment
= from
->u_
.in_output_segment
;
672 if (from
->version_
!= NULL
&& this->version_
!= from
->version_
)
674 gold_assert(this->version_
== NULL
);
675 this->version_
= from
->version_
;
678 this->type_
= from
->type_
;
679 this->binding_
= from
->binding_
;
680 this->visibility_
= from
->visibility_
;
681 this->nonvis_
= from
->nonvis_
;
683 // Special symbols are always considered to be regular symbols.
684 this->in_reg_
= true;
686 if (from
->needs_dynsym_entry_
)
687 this->needs_dynsym_entry_
= true;
688 if (from
->needs_dynsym_value_
)
689 this->needs_dynsym_value_
= true;
691 // We shouldn't see these flags. If we do, we need to handle them
693 gold_assert(!from
->is_target_special_
|| this->is_target_special_
);
694 gold_assert(!from
->is_forwarder_
);
695 gold_assert(!from
->has_plt_offset_
);
696 gold_assert(!from
->has_warning_
);
697 gold_assert(!from
->is_copied_from_dynobj_
);
698 gold_assert(!from
->is_forced_local_
);
701 // Override a symbol with a special symbol.
705 Sized_symbol
<size
>::override_with_special(const Sized_symbol
<size
>* from
)
707 this->override_base_with_special(from
);
708 this->value_
= from
->value_
;
709 this->symsize_
= from
->symsize_
;
712 // Override TOSYM with the special symbol FROMSYM. This handles all
717 Symbol_table::override_with_special(Sized_symbol
<size
>* tosym
,
718 const Sized_symbol
<size
>* fromsym
)
720 tosym
->override_with_special(fromsym
);
721 if (tosym
->has_alias())
723 Symbol
* sym
= this->weak_aliases_
[tosym
];
724 gold_assert(sym
!= NULL
);
725 Sized_symbol
<size
>* ssym
= this->get_sized_symbol
<size
>(sym
);
728 ssym
->override_with_special(fromsym
);
729 sym
= this->weak_aliases_
[ssym
];
730 gold_assert(sym
!= NULL
);
731 ssym
= this->get_sized_symbol
<size
>(sym
);
733 while (ssym
!= tosym
);
735 if (tosym
->binding() == elfcpp::STB_LOCAL
)
736 this->force_local(tosym
);
739 // Instantiate the templates we need. We could use the configure
740 // script to restrict this to only the ones needed for implemented
743 #ifdef HAVE_TARGET_32_LITTLE
746 Symbol_table::resolve
<32, false>(
747 Sized_symbol
<32>* to
,
748 const elfcpp::Sym
<32, false>& sym
,
749 unsigned int st_shndx
,
751 unsigned int orig_st_shndx
,
753 const char* version
);
756 #ifdef HAVE_TARGET_32_BIG
759 Symbol_table::resolve
<32, true>(
760 Sized_symbol
<32>* to
,
761 const elfcpp::Sym
<32, true>& sym
,
762 unsigned int st_shndx
,
764 unsigned int orig_st_shndx
,
766 const char* version
);
769 #ifdef HAVE_TARGET_64_LITTLE
772 Symbol_table::resolve
<64, false>(
773 Sized_symbol
<64>* to
,
774 const elfcpp::Sym
<64, false>& sym
,
775 unsigned int st_shndx
,
777 unsigned int orig_st_shndx
,
779 const char* version
);
782 #ifdef HAVE_TARGET_64_BIG
785 Symbol_table::resolve
<64, true>(
786 Sized_symbol
<64>* to
,
787 const elfcpp::Sym
<64, true>& sym
,
788 unsigned int st_shndx
,
790 unsigned int orig_st_shndx
,
792 const char* version
);
795 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
798 Symbol_table::override_with_special
<32>(Sized_symbol
<32>*,
799 const Sized_symbol
<32>*);
802 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
805 Symbol_table::override_with_special
<64>(Sized_symbol
<64>*,
806 const Sized_symbol
<64>*);
809 } // End namespace gold.