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 Object
* object
, const char* version
)
42 gold_assert(this->source_
== FROM_OBJECT
);
43 this->u_
.from_object
.object
= object
;
44 if (version
!= NULL
&& this->version() != version
)
46 gold_assert(this->version() == NULL
);
47 this->version_
= version
;
49 // FIXME: Handle SHN_XINDEX.
50 this->u_
.from_object
.shndx
= sym
.get_st_shndx();
51 this->type_
= sym
.get_st_type();
52 this->binding_
= sym
.get_st_bind();
53 this->visibility_
= sym
.get_st_visibility();
54 this->nonvis_
= sym
.get_st_nonvis();
55 if (object
->is_dynamic())
61 // Override the fields in Sized_symbol.
64 template<bool big_endian
>
66 Sized_symbol
<size
>::override(const elfcpp::Sym
<size
, big_endian
>& sym
,
67 Object
* object
, const char* version
)
69 this->override_base(sym
, object
, version
);
70 this->value_
= sym
.get_st_value();
71 this->symsize_
= sym
.get_st_size();
74 // Override TOSYM with symbol FROMSYM, defined in OBJECT, with version
75 // VERSION. This handles all aliases of TOSYM.
77 template<int size
, bool big_endian
>
79 Symbol_table::override(Sized_symbol
<size
>* tosym
,
80 const elfcpp::Sym
<size
, big_endian
>& fromsym
,
81 Object
* object
, const char* version
)
83 tosym
->override(fromsym
, object
, version
);
84 if (tosym
->has_alias())
86 Symbol
* sym
= this->weak_aliases_
[tosym
];
87 gold_assert(sym
!= NULL
);
88 Sized_symbol
<size
>* ssym
;
89 ssym
= this->get_sized_symbol
SELECT_SIZE_NAME(size
) (sym
93 ssym
->override(fromsym
, object
, version
);
94 sym
= this->weak_aliases_
[ssym
];
95 gold_assert(sym
!= NULL
);
96 ssym
= this->get_sized_symbol
SELECT_SIZE_NAME(size
) (
97 sym
SELECT_SIZE(size
));
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
, 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
:
170 if (type
== elfcpp::STT_COMMON
)
180 // Resolve a symbol. This is called the second and subsequent times
181 // we see a symbol. TO is the pre-existing symbol. ORIG_SYM is the
182 // new symbol, seen in OBJECT. SYM is almost always identical to
183 // ORIG_SYM, but may be munged (for instance, if we determine the
184 // symbol is in a to-be-discarded section, we'll set sym's shndx to
185 // UNDEFINED). VERSION of the version of SYM.
187 template<int size
, bool big_endian
>
189 Symbol_table::resolve(Sized_symbol
<size
>* to
,
190 const elfcpp::Sym
<size
, big_endian
>& sym
,
191 const elfcpp::Sym
<size
, big_endian
>& orig_sym
,
192 Object
* object
, const char* version
)
194 if (object
->target()->has_resolve())
196 Sized_target
<size
, big_endian
>* sized_target
;
197 sized_target
= object
->sized_target
198 SELECT_SIZE_ENDIAN_NAME(size
, big_endian
) (
199 SELECT_SIZE_ENDIAN_ONLY(size
, big_endian
));
200 sized_target
->resolve(to
, sym
, object
, version
);
204 if (!object
->is_dynamic())
206 // Record that we've seen this symbol in a regular object.
211 // Record that we've seen this symbol in a dynamic object.
215 unsigned int frombits
= symbol_to_bits(sym
.get_st_bind(),
216 object
->is_dynamic(),
220 bool adjust_common_sizes
;
221 if (Symbol_table::should_override(to
, frombits
, object
,
222 &adjust_common_sizes
))
224 typename Sized_symbol
<size
>::Size_type tosize
= to
->symsize();
226 this->override(to
, sym
, object
, version
);
228 if (adjust_common_sizes
&& tosize
> to
->symsize())
229 to
->set_symsize(tosize
);
233 if (adjust_common_sizes
&& sym
.get_st_size() > to
->symsize())
234 to
->set_symsize(sym
.get_st_size());
237 // A new weak undefined reference, merging with an old weak
238 // reference, could be a One Definition Rule (ODR) violation --
239 // especially if the types or sizes of the references differ. We'll
240 // store such pairs and look them up later to make sure they
241 // actually refer to the same lines of code. (Note: not all ODR
242 // violations can be found this way, and not everything this finds
243 // is an ODR violation. But it's helpful to warn about.)
244 // We use orig_sym here because we want the symbol exactly as it
245 // appears in the object file, not munged via our future processing.
246 if (parameters
->detect_odr_violations()
247 && orig_sym
.get_st_bind() == elfcpp::STB_WEAK
248 && to
->binding() == elfcpp::STB_WEAK
249 && orig_sym
.get_st_shndx() != elfcpp::SHN_UNDEF
250 && to
->shndx() != elfcpp::SHN_UNDEF
251 && orig_sym
.get_st_size() != 0 // Ignore weird 0-sized symbols.
252 && to
->symsize() != 0
253 && (orig_sym
.get_st_type() != to
->type()
254 || orig_sym
.get_st_size() != to
->symsize())
255 // C does not have a concept of ODR, so we only need to do this
256 // on C++ symbols. These have (mangled) names starting with _Z.
257 && to
->name()[0] == '_' && to
->name()[1] == 'Z')
259 Symbol_location fromloc
260 = { object
, orig_sym
.get_st_shndx(), orig_sym
.get_st_value() };
261 Symbol_location toloc
= { to
->object(), to
->shndx(), to
->value() };
262 this->candidate_odr_violations_
[to
->name()].insert(fromloc
);
263 this->candidate_odr_violations_
[to
->name()].insert(toloc
);
267 // Handle the core of symbol resolution. This is called with the
268 // existing symbol, TO, and a bitflag describing the new symbol. This
269 // returns true if we should override the existing symbol with the new
270 // one, and returns false otherwise. It sets *ADJUST_COMMON_SIZES to
271 // true if we should set the symbol size to the maximum of the TO and
272 // FROM sizes. It handles error conditions.
275 Symbol_table::should_override(const Symbol
* to
, unsigned int frombits
,
276 Object
* object
, bool* adjust_common_sizes
)
278 *adjust_common_sizes
= false;
281 if (to
->source() == Symbol::FROM_OBJECT
)
282 tobits
= symbol_to_bits(to
->binding(),
283 to
->object()->is_dynamic(),
287 tobits
= symbol_to_bits(to
->binding(), false, elfcpp::SHN_ABS
,
290 // FIXME: Warn if either but not both of TO and SYM are STT_TLS.
292 // We use a giant switch table for symbol resolution. This code is
293 // unwieldy, but: 1) it is efficient; 2) we definitely handle all
294 // cases; 3) it is easy to change the handling of a particular case.
295 // The alternative would be a series of conditionals, but it is easy
296 // to get the ordering wrong. This could also be done as a table,
297 // but that is no easier to understand than this large switch
300 // These are the values generated by the bit codes.
303 DEF
= global_flag
| regular_flag
| def_flag
,
304 WEAK_DEF
= weak_flag
| regular_flag
| def_flag
,
305 DYN_DEF
= global_flag
| dynamic_flag
| def_flag
,
306 DYN_WEAK_DEF
= weak_flag
| dynamic_flag
| def_flag
,
307 UNDEF
= global_flag
| regular_flag
| undef_flag
,
308 WEAK_UNDEF
= weak_flag
| regular_flag
| undef_flag
,
309 DYN_UNDEF
= global_flag
| dynamic_flag
| undef_flag
,
310 DYN_WEAK_UNDEF
= weak_flag
| dynamic_flag
| undef_flag
,
311 COMMON
= global_flag
| regular_flag
| common_flag
,
312 WEAK_COMMON
= weak_flag
| regular_flag
| common_flag
,
313 DYN_COMMON
= global_flag
| dynamic_flag
| common_flag
,
314 DYN_WEAK_COMMON
= weak_flag
| dynamic_flag
| common_flag
317 switch (tobits
* 16 + frombits
)
320 // Two definitions of the same symbol.
321 // FIXME: Do a better job of reporting locations.
322 gold_error(_("%s: multiple definition of %s"),
323 object
!= NULL
? object
->name().c_str() : _("command line"),
324 to
->demangled_name().c_str());
325 gold_error(_("%s: previous definition here"),
326 (to
->source() == Symbol::FROM_OBJECT
327 ? to
->object()->name().c_str()
328 : _("command line")));
331 case WEAK_DEF
* 16 + DEF
:
332 // We've seen a weak definition, and now we see a strong
333 // definition. In the original SVR4 linker, this was treated as
334 // a multiple definition error. In the Solaris linker and the
335 // GNU linker, a weak definition followed by a regular
336 // definition causes the weak definition to be overridden. We
337 // are currently compatible with the GNU linker. In the future
338 // we should add a target specific option to change this.
342 case DYN_DEF
* 16 + DEF
:
343 case DYN_WEAK_DEF
* 16 + DEF
:
344 // We've seen a definition in a dynamic object, and now we see a
345 // definition in a regular object. The definition in the
346 // regular object overrides the definition in the dynamic
350 case UNDEF
* 16 + DEF
:
351 case WEAK_UNDEF
* 16 + DEF
:
352 case DYN_UNDEF
* 16 + DEF
:
353 case DYN_WEAK_UNDEF
* 16 + DEF
:
354 // We've seen an undefined reference, and now we see a
355 // definition. We use the definition.
358 case COMMON
* 16 + DEF
:
359 case WEAK_COMMON
* 16 + DEF
:
360 case DYN_COMMON
* 16 + DEF
:
361 case DYN_WEAK_COMMON
* 16 + DEF
:
362 // We've seen a common symbol and now we see a definition. The
363 // definition overrides. FIXME: We should optionally issue, version a
367 case DEF
* 16 + WEAK_DEF
:
368 case WEAK_DEF
* 16 + WEAK_DEF
:
369 // We've seen a definition and now we see a weak definition. We
370 // ignore the new weak definition.
373 case DYN_DEF
* 16 + WEAK_DEF
:
374 case DYN_WEAK_DEF
* 16 + WEAK_DEF
:
375 // We've seen a dynamic definition and now we see a regular weak
376 // definition. The regular weak definition overrides.
379 case UNDEF
* 16 + WEAK_DEF
:
380 case WEAK_UNDEF
* 16 + WEAK_DEF
:
381 case DYN_UNDEF
* 16 + WEAK_DEF
:
382 case DYN_WEAK_UNDEF
* 16 + WEAK_DEF
:
383 // A weak definition of a currently undefined symbol.
386 case COMMON
* 16 + WEAK_DEF
:
387 case WEAK_COMMON
* 16 + WEAK_DEF
:
388 // A weak definition does not override a common definition.
391 case DYN_COMMON
* 16 + WEAK_DEF
:
392 case DYN_WEAK_COMMON
* 16 + WEAK_DEF
:
393 // A weak definition does override a definition in a dynamic
394 // object. FIXME: We should optionally issue a warning.
397 case DEF
* 16 + DYN_DEF
:
398 case WEAK_DEF
* 16 + DYN_DEF
:
399 case DYN_DEF
* 16 + DYN_DEF
:
400 case DYN_WEAK_DEF
* 16 + DYN_DEF
:
401 // Ignore a dynamic definition if we already have a definition.
404 case UNDEF
* 16 + DYN_DEF
:
405 case WEAK_UNDEF
* 16 + DYN_DEF
:
406 case DYN_UNDEF
* 16 + DYN_DEF
:
407 case DYN_WEAK_UNDEF
* 16 + DYN_DEF
:
408 // Use a dynamic definition if we have a reference.
411 case COMMON
* 16 + DYN_DEF
:
412 case WEAK_COMMON
* 16 + DYN_DEF
:
413 case DYN_COMMON
* 16 + DYN_DEF
:
414 case DYN_WEAK_COMMON
* 16 + DYN_DEF
:
415 // Ignore a dynamic definition if we already have a common
419 case DEF
* 16 + DYN_WEAK_DEF
:
420 case WEAK_DEF
* 16 + DYN_WEAK_DEF
:
421 case DYN_DEF
* 16 + DYN_WEAK_DEF
:
422 case DYN_WEAK_DEF
* 16 + DYN_WEAK_DEF
:
423 // Ignore a weak dynamic definition if we already have a
427 case UNDEF
* 16 + DYN_WEAK_DEF
:
428 case WEAK_UNDEF
* 16 + DYN_WEAK_DEF
:
429 case DYN_UNDEF
* 16 + DYN_WEAK_DEF
:
430 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_DEF
:
431 // Use a weak dynamic definition if we have a reference.
434 case COMMON
* 16 + DYN_WEAK_DEF
:
435 case WEAK_COMMON
* 16 + DYN_WEAK_DEF
:
436 case DYN_COMMON
* 16 + DYN_WEAK_DEF
:
437 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_DEF
:
438 // Ignore a weak dynamic definition if we already have a common
442 case DEF
* 16 + UNDEF
:
443 case WEAK_DEF
* 16 + UNDEF
:
444 case DYN_DEF
* 16 + UNDEF
:
445 case DYN_WEAK_DEF
* 16 + UNDEF
:
446 case UNDEF
* 16 + UNDEF
:
447 // A new undefined reference tells us nothing.
450 case WEAK_UNDEF
* 16 + UNDEF
:
451 case DYN_UNDEF
* 16 + UNDEF
:
452 case DYN_WEAK_UNDEF
* 16 + UNDEF
:
453 // A strong undef overrides a dynamic or weak undef.
456 case COMMON
* 16 + UNDEF
:
457 case WEAK_COMMON
* 16 + UNDEF
:
458 case DYN_COMMON
* 16 + UNDEF
:
459 case DYN_WEAK_COMMON
* 16 + UNDEF
:
460 // A new undefined reference tells us nothing.
463 case DEF
* 16 + WEAK_UNDEF
:
464 case WEAK_DEF
* 16 + WEAK_UNDEF
:
465 case DYN_DEF
* 16 + WEAK_UNDEF
:
466 case DYN_WEAK_DEF
* 16 + WEAK_UNDEF
:
467 case UNDEF
* 16 + WEAK_UNDEF
:
468 case WEAK_UNDEF
* 16 + WEAK_UNDEF
:
469 case DYN_UNDEF
* 16 + WEAK_UNDEF
:
470 case DYN_WEAK_UNDEF
* 16 + WEAK_UNDEF
:
471 case COMMON
* 16 + WEAK_UNDEF
:
472 case WEAK_COMMON
* 16 + WEAK_UNDEF
:
473 case DYN_COMMON
* 16 + WEAK_UNDEF
:
474 case DYN_WEAK_COMMON
* 16 + WEAK_UNDEF
:
475 // A new weak undefined reference tells us nothing.
478 case DEF
* 16 + DYN_UNDEF
:
479 case WEAK_DEF
* 16 + DYN_UNDEF
:
480 case DYN_DEF
* 16 + DYN_UNDEF
:
481 case DYN_WEAK_DEF
* 16 + DYN_UNDEF
:
482 case UNDEF
* 16 + DYN_UNDEF
:
483 case WEAK_UNDEF
* 16 + DYN_UNDEF
:
484 case DYN_UNDEF
* 16 + DYN_UNDEF
:
485 case DYN_WEAK_UNDEF
* 16 + DYN_UNDEF
:
486 case COMMON
* 16 + DYN_UNDEF
:
487 case WEAK_COMMON
* 16 + DYN_UNDEF
:
488 case DYN_COMMON
* 16 + DYN_UNDEF
:
489 case DYN_WEAK_COMMON
* 16 + DYN_UNDEF
:
490 // A new dynamic undefined reference tells us nothing.
493 case DEF
* 16 + DYN_WEAK_UNDEF
:
494 case WEAK_DEF
* 16 + DYN_WEAK_UNDEF
:
495 case DYN_DEF
* 16 + DYN_WEAK_UNDEF
:
496 case DYN_WEAK_DEF
* 16 + DYN_WEAK_UNDEF
:
497 case UNDEF
* 16 + DYN_WEAK_UNDEF
:
498 case WEAK_UNDEF
* 16 + DYN_WEAK_UNDEF
:
499 case DYN_UNDEF
* 16 + DYN_WEAK_UNDEF
:
500 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_UNDEF
:
501 case COMMON
* 16 + DYN_WEAK_UNDEF
:
502 case WEAK_COMMON
* 16 + DYN_WEAK_UNDEF
:
503 case DYN_COMMON
* 16 + DYN_WEAK_UNDEF
:
504 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_UNDEF
:
505 // A new weak dynamic undefined reference tells us nothing.
508 case DEF
* 16 + COMMON
:
509 // A common symbol does not override a definition.
512 case WEAK_DEF
* 16 + COMMON
:
513 case DYN_DEF
* 16 + COMMON
:
514 case DYN_WEAK_DEF
* 16 + COMMON
:
515 // A common symbol does override a weak definition or a dynamic
519 case UNDEF
* 16 + COMMON
:
520 case WEAK_UNDEF
* 16 + COMMON
:
521 case DYN_UNDEF
* 16 + COMMON
:
522 case DYN_WEAK_UNDEF
* 16 + COMMON
:
523 // A common symbol is a definition for a reference.
526 case COMMON
* 16 + COMMON
:
527 // Set the size to the maximum.
528 *adjust_common_sizes
= true;
531 case WEAK_COMMON
* 16 + COMMON
:
532 // I'm not sure just what a weak common symbol means, but
533 // presumably it can be overridden by a regular common symbol.
536 case DYN_COMMON
* 16 + COMMON
:
537 case DYN_WEAK_COMMON
* 16 + COMMON
:
538 // Use the real common symbol, but adjust the size if necessary.
539 *adjust_common_sizes
= true;
542 case DEF
* 16 + WEAK_COMMON
:
543 case WEAK_DEF
* 16 + WEAK_COMMON
:
544 case DYN_DEF
* 16 + WEAK_COMMON
:
545 case DYN_WEAK_DEF
* 16 + WEAK_COMMON
:
546 // Whatever a weak common symbol is, it won't override a
550 case UNDEF
* 16 + WEAK_COMMON
:
551 case WEAK_UNDEF
* 16 + WEAK_COMMON
:
552 case DYN_UNDEF
* 16 + WEAK_COMMON
:
553 case DYN_WEAK_UNDEF
* 16 + WEAK_COMMON
:
554 // A weak common symbol is better than an undefined symbol.
557 case COMMON
* 16 + WEAK_COMMON
:
558 case WEAK_COMMON
* 16 + WEAK_COMMON
:
559 case DYN_COMMON
* 16 + WEAK_COMMON
:
560 case DYN_WEAK_COMMON
* 16 + WEAK_COMMON
:
561 // Ignore a weak common symbol in the presence of a real common
565 case DEF
* 16 + DYN_COMMON
:
566 case WEAK_DEF
* 16 + DYN_COMMON
:
567 case DYN_DEF
* 16 + DYN_COMMON
:
568 case DYN_WEAK_DEF
* 16 + DYN_COMMON
:
569 // Ignore a dynamic common symbol in the presence of a
573 case UNDEF
* 16 + DYN_COMMON
:
574 case WEAK_UNDEF
* 16 + DYN_COMMON
:
575 case DYN_UNDEF
* 16 + DYN_COMMON
:
576 case DYN_WEAK_UNDEF
* 16 + DYN_COMMON
:
577 // A dynamic common symbol is a definition of sorts.
580 case COMMON
* 16 + DYN_COMMON
:
581 case WEAK_COMMON
* 16 + DYN_COMMON
:
582 case DYN_COMMON
* 16 + DYN_COMMON
:
583 case DYN_WEAK_COMMON
* 16 + DYN_COMMON
:
584 // Set the size to the maximum.
585 *adjust_common_sizes
= true;
588 case DEF
* 16 + DYN_WEAK_COMMON
:
589 case WEAK_DEF
* 16 + DYN_WEAK_COMMON
:
590 case DYN_DEF
* 16 + DYN_WEAK_COMMON
:
591 case DYN_WEAK_DEF
* 16 + DYN_WEAK_COMMON
:
592 // A common symbol is ignored in the face of a definition.
595 case UNDEF
* 16 + DYN_WEAK_COMMON
:
596 case WEAK_UNDEF
* 16 + DYN_WEAK_COMMON
:
597 case DYN_UNDEF
* 16 + DYN_WEAK_COMMON
:
598 case DYN_WEAK_UNDEF
* 16 + DYN_WEAK_COMMON
:
599 // I guess a weak common symbol is better than a definition.
602 case COMMON
* 16 + DYN_WEAK_COMMON
:
603 case WEAK_COMMON
* 16 + DYN_WEAK_COMMON
:
604 case DYN_COMMON
* 16 + DYN_WEAK_COMMON
:
605 case DYN_WEAK_COMMON
* 16 + DYN_WEAK_COMMON
:
606 // Set the size to the maximum.
607 *adjust_common_sizes
= true;
615 // A special case of should_override which is only called for a strong
616 // defined symbol from a regular object file. This is used when
617 // defining special symbols.
620 Symbol_table::should_override_with_special(const Symbol
* to
)
622 bool adjust_common_sizes
;
623 unsigned int frombits
= global_flag
| regular_flag
| def_flag
;
624 bool ret
= Symbol_table::should_override(to
, frombits
, NULL
,
625 &adjust_common_sizes
);
626 gold_assert(!adjust_common_sizes
);
630 // Override symbol base with a special symbol.
633 Symbol::override_base_with_special(const Symbol
* from
)
635 gold_assert(this->name_
== from
->name_
|| this->has_alias());
637 this->source_
= from
->source_
;
638 switch (from
->source_
)
641 this->u_
.from_object
= from
->u_
.from_object
;
644 this->u_
.in_output_data
= from
->u_
.in_output_data
;
646 case IN_OUTPUT_SEGMENT
:
647 this->u_
.in_output_segment
= from
->u_
.in_output_segment
;
656 if (from
->version_
!= NULL
&& this->version_
!= from
->version_
)
658 gold_assert(this->version_
== NULL
);
659 this->version_
= from
->version_
;
662 this->type_
= from
->type_
;
663 this->binding_
= from
->binding_
;
664 this->visibility_
= from
->visibility_
;
665 this->nonvis_
= from
->nonvis_
;
667 // Special symbols are always considered to be regular symbols.
668 this->in_reg_
= true;
670 if (from
->needs_dynsym_entry_
)
671 this->needs_dynsym_entry_
= true;
672 if (from
->needs_dynsym_value_
)
673 this->needs_dynsym_value_
= true;
675 // We shouldn't see these flags. If we do, we need to handle them
677 gold_assert(!from
->is_target_special_
|| this->is_target_special_
);
678 gold_assert(!from
->is_forwarder_
);
679 gold_assert(!from
->has_got_offset_
);
680 gold_assert(!from
->has_plt_offset_
);
681 gold_assert(!from
->has_warning_
);
682 gold_assert(!from
->is_copied_from_dynobj_
);
685 // Override a symbol with a special symbol.
689 Sized_symbol
<size
>::override_with_special(const Sized_symbol
<size
>* from
)
691 this->override_base_with_special(from
);
692 this->value_
= from
->value_
;
693 this->symsize_
= from
->symsize_
;
696 // Override TOSYM with the special symbol FROMSYM. This handles all
701 Symbol_table::override_with_special(Sized_symbol
<size
>* tosym
,
702 const Sized_symbol
<size
>* fromsym
)
704 tosym
->override_with_special(fromsym
);
705 if (tosym
->has_alias())
707 Symbol
* sym
= this->weak_aliases_
[tosym
];
708 gold_assert(sym
!= NULL
);
709 Sized_symbol
<size
>* ssym
;
710 ssym
= this->get_sized_symbol
SELECT_SIZE_NAME(size
) (sym
714 ssym
->override_with_special(fromsym
);
715 sym
= this->weak_aliases_
[ssym
];
716 gold_assert(sym
!= NULL
);
717 ssym
= this->get_sized_symbol
SELECT_SIZE_NAME(size
) (
718 sym
SELECT_SIZE(size
));
720 while (ssym
!= tosym
);
724 // Instantiate the templates we need. We could use the configure
725 // script to restrict this to only the ones needed for implemented
728 #ifdef HAVE_TARGET_32_LITTLE
731 Symbol_table::resolve
<32, false>(
732 Sized_symbol
<32>* to
,
733 const elfcpp::Sym
<32, false>& sym
,
734 const elfcpp::Sym
<32, false>& orig_sym
,
736 const char* version
);
739 #ifdef HAVE_TARGET_32_BIG
742 Symbol_table::resolve
<32, true>(
743 Sized_symbol
<32>* to
,
744 const elfcpp::Sym
<32, true>& sym
,
745 const elfcpp::Sym
<32, true>& orig_sym
,
747 const char* version
);
750 #ifdef HAVE_TARGET_64_LITTLE
753 Symbol_table::resolve
<64, false>(
754 Sized_symbol
<64>* to
,
755 const elfcpp::Sym
<64, false>& sym
,
756 const elfcpp::Sym
<64, false>& orig_sym
,
758 const char* version
);
761 #ifdef HAVE_TARGET_64_BIG
764 Symbol_table::resolve
<64, true>(
765 Sized_symbol
<64>* to
,
766 const elfcpp::Sym
<64, true>& sym
,
767 const elfcpp::Sym
<64, true>& orig_sym
,
769 const char* version
);
772 #if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
775 Symbol_table::override_with_special
<32>(Sized_symbol
<32>*,
776 const Sized_symbol
<32>*);
779 #if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
782 Symbol_table::override_with_special
<64>(Sized_symbol
<64>*,
783 const Sized_symbol
<64>*);
786 } // End namespace gold.