Fully implement the SECTIONS clause.
[external/binutils.git] / gold / symtab.h
1 // symtab.h -- the gold symbol table   -*- C++ -*-
2
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
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.
12
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.
17
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.
22
23 // Symbol_table
24 //   The symbol table.
25
26 #include <string>
27 #include <utility>
28 #include <vector>
29
30 #include "elfcpp.h"
31 #include "parameters.h"
32 #include "stringpool.h"
33 #include "object.h"
34
35 #ifndef GOLD_SYMTAB_H
36 #define GOLD_SYMTAB_H
37
38 namespace gold
39 {
40
41 class Object;
42 class Relobj;
43 template<int size, bool big_endian>
44 class Sized_relobj;
45 class Dynobj;
46 template<int size, bool big_endian>
47 class Sized_dynobj;
48 class Versions;
49 class Version_script_info;
50 class Input_objects;
51 class Output_data;
52 class Output_section;
53 class Output_segment;
54 class Output_file;
55
56 // The base class of an entry in the symbol table.  The symbol table
57 // can have a lot of entries, so we don't want this class to big.
58 // Size dependent fields can be found in the template class
59 // Sized_symbol.  Targets may support their own derived classes.
60
61 class Symbol
62 {
63  public:
64   // Because we want the class to be small, we don't use any virtual
65   // functions.  But because symbols can be defined in different
66   // places, we need to classify them.  This enum is the different
67   // sources of symbols we support.
68   enum Source
69   {
70     // Symbol defined in a relocatable or dynamic input file--this is
71     // the most common case.
72     FROM_OBJECT,
73     // Symbol defined in an Output_data, a special section created by
74     // the target.
75     IN_OUTPUT_DATA,
76     // Symbol defined in an Output_segment, with no associated
77     // section.
78     IN_OUTPUT_SEGMENT,
79     // Symbol value is constant.
80     CONSTANT
81   };
82
83   // When the source is IN_OUTPUT_SEGMENT, we need to describe what
84   // the offset means.
85   enum Segment_offset_base
86   {
87     // From the start of the segment.
88     SEGMENT_START,
89     // From the end of the segment.
90     SEGMENT_END,
91     // From the filesz of the segment--i.e., after the loaded bytes
92     // but before the bytes which are allocated but zeroed.
93     SEGMENT_BSS
94   };
95
96   // Return the symbol name.
97   const char*
98   name() const
99   { return this->name_; }
100
101   // Return the (ANSI) demangled version of the name, if
102   // parameters.demangle() is true.  Otherwise, return the name.  This
103   // is intended to be used only for logging errors, so it's not
104   // super-efficient.
105   std::string
106   demangled_name() const;
107
108   // Return the symbol version.  This will return NULL for an
109   // unversioned symbol.
110   const char*
111   version() const
112   { return this->version_; }
113
114   // Return whether this version is the default for this symbol name
115   // (eg, "foo@@V2" is a default version; "foo@V1" is not).  Only
116   // meaningful for versioned symbols.
117   bool
118   is_default() const
119   {
120     gold_assert(this->version_ != NULL);
121     return this->is_def_;
122   }
123
124   // Set whether this version is the default for this symbol name.
125   void
126   set_is_default(bool def)
127   { this->is_def_ = def; }
128
129   // Return the symbol source.
130   Source
131   source() const
132   { return this->source_; }
133
134   // Return the object with which this symbol is associated.
135   Object*
136   object() const
137   {
138     gold_assert(this->source_ == FROM_OBJECT);
139     return this->u_.from_object.object;
140   }
141
142   // Return the index of the section in the input relocatable or
143   // dynamic object file.
144   unsigned int
145   shndx() const
146   {
147     gold_assert(this->source_ == FROM_OBJECT);
148     return this->u_.from_object.shndx;
149   }
150
151   // Return the output data section with which this symbol is
152   // associated, if the symbol was specially defined with respect to
153   // an output data section.
154   Output_data*
155   output_data() const
156   {
157     gold_assert(this->source_ == IN_OUTPUT_DATA);
158     return this->u_.in_output_data.output_data;
159   }
160
161   // If this symbol was defined with respect to an output data
162   // section, return whether the value is an offset from end.
163   bool
164   offset_is_from_end() const
165   {
166     gold_assert(this->source_ == IN_OUTPUT_DATA);
167     return this->u_.in_output_data.offset_is_from_end;
168   }
169
170   // Return the output segment with which this symbol is associated,
171   // if the symbol was specially defined with respect to an output
172   // segment.
173   Output_segment*
174   output_segment() const
175   {
176     gold_assert(this->source_ == IN_OUTPUT_SEGMENT);
177     return this->u_.in_output_segment.output_segment;
178   }
179
180   // If this symbol was defined with respect to an output segment,
181   // return the offset base.
182   Segment_offset_base
183   offset_base() const
184   {
185     gold_assert(this->source_ == IN_OUTPUT_SEGMENT);
186     return this->u_.in_output_segment.offset_base;
187   }
188
189   // Return the symbol binding.
190   elfcpp::STB
191   binding() const
192   { return this->binding_; }
193
194   // Return the symbol type.
195   elfcpp::STT
196   type() const
197   { return this->type_; }
198
199   // Return the symbol visibility.
200   elfcpp::STV
201   visibility() const
202   { return this->visibility_; }
203
204   // Return the non-visibility part of the st_other field.
205   unsigned char
206   nonvis() const
207   { return this->nonvis_; }
208
209   // Return whether this symbol is a forwarder.  This will never be
210   // true of a symbol found in the hash table, but may be true of
211   // symbol pointers attached to object files.
212   bool
213   is_forwarder() const
214   { return this->is_forwarder_; }
215
216   // Mark this symbol as a forwarder.
217   void
218   set_forwarder()
219   { this->is_forwarder_ = true; }
220
221   // Return whether this symbol has an alias in the weak aliases table
222   // in Symbol_table.
223   bool
224   has_alias() const
225   { return this->has_alias_; }
226
227   // Mark this symbol as having an alias.
228   void
229   set_has_alias()
230   { this->has_alias_ = true; }
231
232   // Return whether this symbol needs an entry in the dynamic symbol
233   // table.
234   bool
235   needs_dynsym_entry() const
236   {
237     return (this->needs_dynsym_entry_
238             || (this->in_reg() && this->in_dyn()));
239   }
240
241   // Mark this symbol as needing an entry in the dynamic symbol table.
242   void
243   set_needs_dynsym_entry()
244   { this->needs_dynsym_entry_ = true; }
245
246   // Return whether this symbol should be added to the dynamic symbol
247   // table.
248   bool
249   should_add_dynsym_entry() const;
250
251   // Return whether this symbol has been seen in a regular object.
252   bool
253   in_reg() const
254   { return this->in_reg_; }
255
256   // Mark this symbol as having been seen in a regular object.
257   void
258   set_in_reg()
259   { this->in_reg_ = true; }
260
261   // Return whether this symbol has been seen in a dynamic object.
262   bool
263   in_dyn() const
264   { return this->in_dyn_; }
265
266   // Mark this symbol as having been seen in a dynamic object.
267   void
268   set_in_dyn()
269   { this->in_dyn_ = true; }
270
271   // Return the index of this symbol in the output file symbol table.
272   // A value of -1U means that this symbol is not going into the
273   // output file.  This starts out as zero, and is set to a non-zero
274   // value by Symbol_table::finalize.  It is an error to ask for the
275   // symbol table index before it has been set.
276   unsigned int
277   symtab_index() const
278   {
279     gold_assert(this->symtab_index_ != 0);
280     return this->symtab_index_;
281   }
282
283   // Set the index of the symbol in the output file symbol table.
284   void
285   set_symtab_index(unsigned int index)
286   {
287     gold_assert(index != 0);
288     this->symtab_index_ = index;
289   }
290
291   // Return whether this symbol already has an index in the output
292   // file symbol table.
293   bool
294   has_symtab_index() const
295   { return this->symtab_index_ != 0; }
296
297   // Return the index of this symbol in the dynamic symbol table.  A
298   // value of -1U means that this symbol is not going into the dynamic
299   // symbol table.  This starts out as zero, and is set to a non-zero
300   // during Layout::finalize.  It is an error to ask for the dynamic
301   // symbol table index before it has been set.
302   unsigned int
303   dynsym_index() const
304   {
305     gold_assert(this->dynsym_index_ != 0);
306     return this->dynsym_index_;
307   }
308
309   // Set the index of the symbol in the dynamic symbol table.
310   void
311   set_dynsym_index(unsigned int index)
312   {
313     gold_assert(index != 0);
314     this->dynsym_index_ = index;
315   }
316
317   // Return whether this symbol already has an index in the dynamic
318   // symbol table.
319   bool
320   has_dynsym_index() const
321   { return this->dynsym_index_ != 0; }
322
323   // Return whether this symbol has an entry in the GOT section.
324   // For a TLS symbol, this GOT entry will hold its tp-relative offset.
325   bool
326   has_got_offset() const
327   { return this->has_got_offset_; }
328
329   // Return the offset into the GOT section of this symbol.
330   unsigned int
331   got_offset() const
332   {
333     gold_assert(this->has_got_offset());
334     return this->got_offset_;
335   }
336
337   // Set the GOT offset of this symbol.
338   void
339   set_got_offset(unsigned int got_offset)
340   {
341     this->has_got_offset_ = true;
342     this->got_offset_ = got_offset;
343   }
344
345   // Return whether this TLS symbol has an entry in the GOT section for
346   // its module index or, if NEED_PAIR is true, has a pair of entries
347   // for its module index and dtv-relative offset.
348   bool
349   has_tls_got_offset(bool need_pair) const
350   {
351     return (this->has_tls_mod_got_offset_
352             && (!need_pair || this->has_tls_pair_got_offset_));
353   }
354
355   // Return the offset into the GOT section for this symbol's TLS module
356   // index or, if NEED_PAIR is true, for the pair of entries for the
357   // module index and dtv-relative offset.
358   unsigned int
359   tls_got_offset(bool need_pair) const
360   {
361     gold_assert(this->has_tls_got_offset(need_pair));
362     return this->tls_mod_got_offset_;
363   }
364
365   // Set the GOT offset of this symbol.
366   void
367   set_tls_got_offset(unsigned int got_offset, bool have_pair)
368   {
369     this->has_tls_mod_got_offset_ = true;
370     this->has_tls_pair_got_offset_ = have_pair;
371     this->tls_mod_got_offset_ = got_offset;
372   }
373
374   // Return whether this symbol has an entry in the PLT section.
375   bool
376   has_plt_offset() const
377   { return this->has_plt_offset_; }
378
379   // Return the offset into the PLT section of this symbol.
380   unsigned int
381   plt_offset() const
382   {
383     gold_assert(this->has_plt_offset());
384     return this->plt_offset_;
385   }
386
387   // Set the PLT offset of this symbol.
388   void
389   set_plt_offset(unsigned int plt_offset)
390   {
391     this->has_plt_offset_ = true;
392     this->plt_offset_ = plt_offset;
393   }
394
395   // Return whether this dynamic symbol needs a special value in the
396   // dynamic symbol table.
397   bool
398   needs_dynsym_value() const
399   { return this->needs_dynsym_value_; }
400
401   // Set that this dynamic symbol needs a special value in the dynamic
402   // symbol table.
403   void
404   set_needs_dynsym_value()
405   {
406     gold_assert(this->object()->is_dynamic());
407     this->needs_dynsym_value_ = true;
408   }
409
410   // Return true if the final value of this symbol is known at link
411   // time.
412   bool
413   final_value_is_known() const;
414
415   // Return whether this is a defined symbol (not undefined or
416   // common).
417   bool
418   is_defined() const
419   {
420     return (this->source_ != FROM_OBJECT
421             || (this->shndx() != elfcpp::SHN_UNDEF
422                 && this->shndx() != elfcpp::SHN_COMMON));
423   }
424
425   // Return true if this symbol is from a dynamic object.
426   bool
427   is_from_dynobj() const
428   {
429     return this->source_ == FROM_OBJECT && this->object()->is_dynamic();
430   }
431
432   // Return whether this is an undefined symbol.
433   bool
434   is_undefined() const
435   {
436     return this->source_ == FROM_OBJECT && this->shndx() == elfcpp::SHN_UNDEF;
437   }
438
439   // Return whether this is a common symbol.
440   bool
441   is_common() const
442   {
443     return (this->source_ == FROM_OBJECT
444             && (this->shndx() == elfcpp::SHN_COMMON
445                 || this->type_ == elfcpp::STT_COMMON));
446   }
447
448   // Return whether this symbol can be seen outside this object.
449   bool
450   is_externally_visible() const
451   {
452     return (this->visibility_ == elfcpp::STV_DEFAULT
453             || this->visibility_ == elfcpp::STV_PROTECTED);
454   }
455
456   // Return true if this symbol can be preempted by a definition in
457   // another link unit.
458   bool
459   is_preemptible() const
460   {
461     // It doesn't make sense to ask whether a symbol defined in
462     // another object is preemptible.
463     gold_assert(!this->is_from_dynobj());
464
465     return (this->visibility_ != elfcpp::STV_INTERNAL
466             && this->visibility_ != elfcpp::STV_HIDDEN
467             && this->visibility_ != elfcpp::STV_PROTECTED
468             && !this->is_forced_local_
469             && parameters->output_is_shared()
470             && !parameters->symbolic());
471   }
472
473   // Return true if this symbol is a function that needs a PLT entry.
474   // If the symbol is defined in a dynamic object or if it is subject
475   // to pre-emption, we need to make a PLT entry.
476   bool
477   needs_plt_entry() const
478   {
479     return (this->type() == elfcpp::STT_FUNC
480             && (this->is_from_dynobj() || this->is_preemptible()));
481   }
482
483   // When determining whether a reference to a symbol needs a dynamic
484   // relocation, we need to know several things about the reference.
485   // These flags may be or'ed together.
486   enum Reference_flags
487   {
488     // Reference to the symbol's absolute address.
489     ABSOLUTE_REF = 1,
490     // A non-PIC reference.
491     NON_PIC_REF = 2,
492     // A function call.
493     FUNCTION_CALL = 4
494   };
495
496   // Given a direct absolute or pc-relative static relocation against
497   // the global symbol, this function returns whether a dynamic relocation
498   // is needed.
499
500   bool
501   needs_dynamic_reloc(int flags) const
502   {
503     // An absolute reference within a position-independent output file
504     // will need a dynamic relocation.
505     if ((flags & ABSOLUTE_REF)
506         && parameters->output_is_position_independent())
507       return true;
508
509     // A function call that can branch to a local PLT entry does not need
510     // a dynamic relocation.  A non-pic pc-relative function call in a
511     // shared library cannot use a PLT entry.
512     if ((flags & FUNCTION_CALL)
513         && this->has_plt_offset()
514         && !((flags & NON_PIC_REF) && parameters->output_is_shared()))
515       return false;
516
517     // A reference to any PLT entry in a non-position-independent executable
518     // does not need a dynamic relocation.
519     if (!parameters->output_is_position_independent()
520         && this->has_plt_offset())
521       return false;
522
523     // A reference to a symbol defined in a dynamic object or to a
524     // symbol that is preemptible will need a dynamic relocation.
525     if (this->is_from_dynobj() || this->is_preemptible())
526       return true;
527
528     // For all other cases, return FALSE.
529     return false;
530   }
531
532   // Given a direct absolute static relocation against
533   // the global symbol, where a dynamic relocation is needed, this
534   // function returns whether a relative dynamic relocation can be used.
535   // The caller must determine separately whether the static relocation
536   // is compatible with a relative relocation.
537
538   bool
539   can_use_relative_reloc(bool is_function_call) const
540   {
541     // A function call that can branch to a local PLT entry can
542     // use a RELATIVE relocation.
543     if (is_function_call && this->has_plt_offset())
544       return true;
545
546     // A reference to a symbol defined in a dynamic object or to a
547     // symbol that is preemptible can not use a RELATIVE relocaiton.
548     if (this->is_from_dynobj() || this->is_preemptible())
549       return false;
550
551     // For all other cases, return TRUE.
552     return true;
553   }
554
555   // Return whether this symbol currently has an absolute value.
556   bool
557   value_is_absolute() const;
558
559   // Return whether there should be a warning for references to this
560   // symbol.
561   bool
562   has_warning() const
563   { return this->has_warning_; }
564
565   // Mark this symbol as having a warning.
566   void
567   set_has_warning()
568   { this->has_warning_ = true; }
569
570   // Return whether this symbol is defined by a COPY reloc from a
571   // dynamic object.
572   bool
573   is_copied_from_dynobj() const
574   { return this->is_copied_from_dynobj_; }
575
576   // Mark this symbol as defined by a COPY reloc.
577   void
578   set_is_copied_from_dynobj()
579   { this->is_copied_from_dynobj_ = true; }
580
581   // Return whether this symbol is forced to visibility STB_LOCAL
582   // by a "local:" entry in a version script.
583   bool
584   is_forced_local() const
585   { return this->is_forced_local_; }
586
587   // Mark this symbol as forced to STB_LOCAL visibility.
588   void
589   set_is_forced_local()
590   { this->is_forced_local_ = true; }
591
592  protected:
593   // Instances of this class should always be created at a specific
594   // size.
595   Symbol()
596   { memset(this, 0, sizeof *this); }
597
598   // Initialize the general fields.
599   void
600   init_fields(const char* name, const char* version,
601               elfcpp::STT type, elfcpp::STB binding,
602               elfcpp::STV visibility, unsigned char nonvis);
603
604   // Initialize fields from an ELF symbol in OBJECT.
605   template<int size, bool big_endian>
606   void
607   init_base(const char *name, const char* version, Object* object,
608             const elfcpp::Sym<size, big_endian>&);
609
610   // Initialize fields for an Output_data.
611   void
612   init_base(const char* name, Output_data*, elfcpp::STT, elfcpp::STB,
613             elfcpp::STV, unsigned char nonvis, bool offset_is_from_end);
614
615   // Initialize fields for an Output_segment.
616   void
617   init_base(const char* name, Output_segment* os, elfcpp::STT type,
618             elfcpp::STB binding, elfcpp::STV visibility,
619             unsigned char nonvis, Segment_offset_base offset_base);
620
621   // Initialize fields for a constant.
622   void
623   init_base(const char* name, elfcpp::STT type, elfcpp::STB binding,
624             elfcpp::STV visibility, unsigned char nonvis);
625
626   // Override existing symbol.
627   template<int size, bool big_endian>
628   void
629   override_base(const elfcpp::Sym<size, big_endian>&, Object* object,
630                 const char* version);
631
632   // Override existing symbol with a special symbol.
633   void
634   override_base_with_special(const Symbol* from);
635
636   // Allocate a common symbol by giving it a location in the output
637   // file.
638   void
639   allocate_base_common(Output_data*);
640
641  private:
642   Symbol(const Symbol&);
643   Symbol& operator=(const Symbol&);
644
645   // Symbol name (expected to point into a Stringpool).
646   const char* name_;
647   // Symbol version (expected to point into a Stringpool).  This may
648   // be NULL.
649   const char* version_;
650
651   union
652   {
653     // This struct is used if SOURCE_ == FROM_OBJECT.
654     struct
655     {
656       // Object in which symbol is defined, or in which it was first
657       // seen.
658       Object* object;
659       // Section number in object_ in which symbol is defined.
660       unsigned int shndx;
661     } from_object;
662
663     // This struct is used if SOURCE_ == IN_OUTPUT_DATA.
664     struct
665     {
666       // Output_data in which symbol is defined.  Before
667       // Layout::finalize the symbol's value is an offset within the
668       // Output_data.
669       Output_data* output_data;
670       // True if the offset is from the end, false if the offset is
671       // from the beginning.
672       bool offset_is_from_end;
673     } in_output_data;
674
675     // This struct is used if SOURCE_ == IN_OUTPUT_SEGMENT.
676     struct
677     {
678       // Output_segment in which the symbol is defined.  Before
679       // Layout::finalize the symbol's value is an offset.
680       Output_segment* output_segment;
681       // The base to use for the offset before Layout::finalize.
682       Segment_offset_base offset_base;
683     } in_output_segment;
684   } u_;
685
686   // The index of this symbol in the output file.  If the symbol is
687   // not going into the output file, this value is -1U.  This field
688   // starts as always holding zero.  It is set to a non-zero value by
689   // Symbol_table::finalize.
690   unsigned int symtab_index_;
691
692   // The index of this symbol in the dynamic symbol table.  If the
693   // symbol is not going into the dynamic symbol table, this value is
694   // -1U.  This field starts as always holding zero.  It is set to a
695   // non-zero value during Layout::finalize.
696   unsigned int dynsym_index_;
697
698   // If this symbol has an entry in the GOT section (has_got_offset_
699   // is true), this is the offset from the start of the GOT section.
700   // For a TLS symbol, if has_tls_tpoff_got_offset_ is true, this
701   // serves as the GOT offset for the GOT entry that holds its
702   // TP-relative offset.
703   unsigned int got_offset_;
704
705   // If this is a TLS symbol and has an entry in the GOT section
706   // for a module index or a pair of entries (module index,
707   // dtv-relative offset), these are the offsets from the start
708   // of the GOT section.
709   unsigned int tls_mod_got_offset_;
710   unsigned int tls_pair_got_offset_;
711
712   // If this symbol has an entry in the PLT section (has_plt_offset_
713   // is true), then this is the offset from the start of the PLT
714   // section.
715   unsigned int plt_offset_;
716
717   // Symbol type.
718   elfcpp::STT type_ : 4;
719   // Symbol binding.
720   elfcpp::STB binding_ : 4;
721   // Symbol visibility.
722   elfcpp::STV visibility_ : 2;
723   // Rest of symbol st_other field.
724   unsigned int nonvis_ : 6;
725   // The type of symbol.
726   Source source_ : 3;
727   // True if this symbol always requires special target-specific
728   // handling.
729   bool is_target_special_ : 1;
730   // True if this is the default version of the symbol.
731   bool is_def_ : 1;
732   // True if this symbol really forwards to another symbol.  This is
733   // used when we discover after the fact that two different entries
734   // in the hash table really refer to the same symbol.  This will
735   // never be set for a symbol found in the hash table, but may be set
736   // for a symbol found in the list of symbols attached to an Object.
737   // It forwards to the symbol found in the forwarders_ map of
738   // Symbol_table.
739   bool is_forwarder_ : 1;
740   // True if the symbol has an alias in the weak_aliases table in
741   // Symbol_table.
742   bool has_alias_ : 1;
743   // True if this symbol needs to be in the dynamic symbol table.
744   bool needs_dynsym_entry_ : 1;
745   // True if we've seen this symbol in a regular object.
746   bool in_reg_ : 1;
747   // True if we've seen this symbol in a dynamic object.
748   bool in_dyn_ : 1;
749   // True if the symbol has an entry in the GOT section.
750   // For a TLS symbol, this GOT entry will hold its tp-relative offset.
751   bool has_got_offset_ : 1;
752   // True if the symbol has an entry in the GOT section for its
753   // module index.
754   bool has_tls_mod_got_offset_ : 1;
755   // True if the symbol has a pair of entries in the GOT section for its
756   // module index and dtv-relative offset.
757   bool has_tls_pair_got_offset_ : 1;
758   // True if the symbol has an entry in the PLT section.
759   bool has_plt_offset_ : 1;
760   // True if this is a dynamic symbol which needs a special value in
761   // the dynamic symbol table.
762   bool needs_dynsym_value_ : 1;
763   // True if there is a warning for this symbol.
764   bool has_warning_ : 1;
765   // True if we are using a COPY reloc for this symbol, so that the
766   // real definition lives in a dynamic object.
767   bool is_copied_from_dynobj_ : 1;
768   // True if this symbol was forced to local visibility by a version
769   // script.
770   bool is_forced_local_ : 1;
771 };
772
773 // The parts of a symbol which are size specific.  Using a template
774 // derived class like this helps us use less space on a 32-bit system.
775
776 template<int size>
777 class Sized_symbol : public Symbol
778 {
779  public:
780   typedef typename elfcpp::Elf_types<size>::Elf_Addr Value_type;
781   typedef typename elfcpp::Elf_types<size>::Elf_WXword Size_type;
782
783   Sized_symbol()
784   { }
785
786   // Initialize fields from an ELF symbol in OBJECT.
787   template<bool big_endian>
788   void
789   init(const char *name, const char* version, Object* object,
790        const elfcpp::Sym<size, big_endian>&);
791
792   // Initialize fields for an Output_data.
793   void
794   init(const char* name, Output_data*, Value_type value, Size_type symsize,
795        elfcpp::STT, elfcpp::STB, elfcpp::STV, unsigned char nonvis,
796        bool offset_is_from_end);
797
798   // Initialize fields for an Output_segment.
799   void
800   init(const char* name, Output_segment*, Value_type value, Size_type symsize,
801        elfcpp::STT, elfcpp::STB, elfcpp::STV, unsigned char nonvis,
802        Segment_offset_base offset_base);
803
804   // Initialize fields for a constant.
805   void
806   init(const char* name, Value_type value, Size_type symsize,
807        elfcpp::STT, elfcpp::STB, elfcpp::STV, unsigned char nonvis);
808
809   // Override existing symbol.
810   template<bool big_endian>
811   void
812   override(const elfcpp::Sym<size, big_endian>&, Object* object,
813            const char* version);
814
815   // Override existing symbol with a special symbol.
816   void
817   override_with_special(const Sized_symbol<size>*);
818
819   // Return the symbol's value.
820   Value_type
821   value() const
822   { return this->value_; }
823
824   // Return the symbol's size (we can't call this 'size' because that
825   // is a template parameter).
826   Size_type
827   symsize() const
828   { return this->symsize_; }
829
830   // Set the symbol size.  This is used when resolving common symbols.
831   void
832   set_symsize(Size_type symsize)
833   { this->symsize_ = symsize; }
834
835   // Set the symbol value.  This is called when we store the final
836   // values of the symbols into the symbol table.
837   void
838   set_value(Value_type value)
839   { this->value_ = value; }
840
841   // Allocate a common symbol by giving it a location in the output
842   // file.
843   void
844   allocate_common(Output_data*, Value_type value);
845
846  private:
847   Sized_symbol(const Sized_symbol&);
848   Sized_symbol& operator=(const Sized_symbol&);
849
850   // Symbol value.  Before Layout::finalize this is the offset in the
851   // input section.  This is set to the final value during
852   // Layout::finalize.
853   Value_type value_;
854   // Symbol size.
855   Size_type symsize_;
856 };
857
858 // A struct describing a symbol defined by the linker, where the value
859 // of the symbol is defined based on an output section.  This is used
860 // for symbols defined by the linker, like "_init_array_start".
861
862 struct Define_symbol_in_section
863 {
864   // The symbol name.
865   const char* name;
866   // The name of the output section with which this symbol should be
867   // associated.  If there is no output section with that name, the
868   // symbol will be defined as zero.
869   const char* output_section;
870   // The offset of the symbol within the output section.  This is an
871   // offset from the start of the output section, unless start_at_end
872   // is true, in which case this is an offset from the end of the
873   // output section.
874   uint64_t value;
875   // The size of the symbol.
876   uint64_t size;
877   // The symbol type.
878   elfcpp::STT type;
879   // The symbol binding.
880   elfcpp::STB binding;
881   // The symbol visibility.
882   elfcpp::STV visibility;
883   // The rest of the st_other field.
884   unsigned char nonvis;
885   // If true, the value field is an offset from the end of the output
886   // section.
887   bool offset_is_from_end;
888   // If true, this symbol is defined only if we see a reference to it.
889   bool only_if_ref;
890 };
891
892 // A struct describing a symbol defined by the linker, where the value
893 // of the symbol is defined based on a segment.  This is used for
894 // symbols defined by the linker, like "_end".  We describe the
895 // segment with which the symbol should be associated by its
896 // characteristics.  If no segment meets these characteristics, the
897 // symbol will be defined as zero.  If there is more than one segment
898 // which meets these characteristics, we will use the first one.
899
900 struct Define_symbol_in_segment
901 {
902   // The symbol name.
903   const char* name;
904   // The segment type where the symbol should be defined, typically
905   // PT_LOAD.
906   elfcpp::PT segment_type;
907   // Bitmask of segment flags which must be set.
908   elfcpp::PF segment_flags_set;
909   // Bitmask of segment flags which must be clear.
910   elfcpp::PF segment_flags_clear;
911   // The offset of the symbol within the segment.  The offset is
912   // calculated from the position set by offset_base.
913   uint64_t value;
914   // The size of the symbol.
915   uint64_t size;
916   // The symbol type.
917   elfcpp::STT type;
918   // The symbol binding.
919   elfcpp::STB binding;
920   // The symbol visibility.
921   elfcpp::STV visibility;
922   // The rest of the st_other field.
923   unsigned char nonvis;
924   // The base from which we compute the offset.
925   Symbol::Segment_offset_base offset_base;
926   // If true, this symbol is defined only if we see a reference to it.
927   bool only_if_ref;
928 };
929
930 // This class manages warnings.  Warnings are a GNU extension.  When
931 // we see a section named .gnu.warning.SYM in an object file, and if
932 // we wind using the definition of SYM from that object file, then we
933 // will issue a warning for any relocation against SYM from a
934 // different object file.  The text of the warning is the contents of
935 // the section.  This is not precisely the definition used by the old
936 // GNU linker; the old GNU linker treated an occurrence of
937 // .gnu.warning.SYM as defining a warning symbol.  A warning symbol
938 // would trigger a warning on any reference.  However, it was
939 // inconsistent in that a warning in a dynamic object only triggered
940 // if there was no definition in a regular object.  This linker is
941 // different in that we only issue a warning if we use the symbol
942 // definition from the same object file as the warning section.
943
944 class Warnings
945 {
946  public:
947   Warnings()
948     : warnings_()
949   { }
950
951   // Add a warning for symbol NAME in object OBJ.  WARNING is the text
952   // of the warning.
953   void
954   add_warning(Symbol_table* symtab, const char* name, Object* obj,
955               const std::string& warning);
956
957   // For each symbol for which we should give a warning, make a note
958   // on the symbol.
959   void
960   note_warnings(Symbol_table* symtab);
961
962   // Issue a warning for a reference to SYM at RELINFO's location.
963   template<int size, bool big_endian>
964   void
965   issue_warning(const Symbol* sym, const Relocate_info<size, big_endian>*,
966                 size_t relnum, off_t reloffset) const;
967
968  private:
969   Warnings(const Warnings&);
970   Warnings& operator=(const Warnings&);
971
972   // What we need to know to get the warning text.
973   struct Warning_location
974   {
975     // The object the warning is in.
976     Object* object;
977     // The warning text.
978     std::string text;
979
980     Warning_location()
981       : object(NULL), text()
982     { }
983
984     void
985     set(Object* o, const std::string& t)
986     {
987       this->object = o;
988       this->text = t;
989     }
990   };
991
992   // A mapping from warning symbol names (canonicalized in
993   // Symbol_table's namepool_ field) to warning information.
994   typedef Unordered_map<const char*, Warning_location> Warning_table;
995
996   Warning_table warnings_;
997 };
998
999 // The main linker symbol table.
1000
1001 class Symbol_table
1002 {
1003  public:
1004   // COUNT is an estimate of how many symbosl will be inserted in the
1005   // symbol table.  It's ok to put 0 if you don't know; a correct
1006   // guess will just save some CPU by reducing hashtable resizes.
1007   Symbol_table(unsigned int count, const Version_script_info& version_script);
1008
1009   ~Symbol_table();
1010
1011   // Add COUNT external symbols from the relocatable object RELOBJ to
1012   // the symbol table.  SYMS is the symbols, SYM_NAMES is their names,
1013   // SYM_NAME_SIZE is the size of SYM_NAMES.  This sets SYMPOINTERS to
1014   // point to the symbols in the symbol table.
1015   template<int size, bool big_endian>
1016   void
1017   add_from_relobj(Sized_relobj<size, big_endian>* relobj,
1018                   const unsigned char* syms, size_t count,
1019                   const char* sym_names, size_t sym_name_size,
1020                   typename Sized_relobj<size, big_endian>::Symbols*);
1021
1022   // Add COUNT dynamic symbols from the dynamic object DYNOBJ to the
1023   // symbol table.  SYMS is the symbols.  SYM_NAMES is their names.
1024   // SYM_NAME_SIZE is the size of SYM_NAMES.  The other parameters are
1025   // symbol version data.
1026   template<int size, bool big_endian>
1027   void
1028   add_from_dynobj(Sized_dynobj<size, big_endian>* dynobj,
1029                   const unsigned char* syms, size_t count,
1030                   const char* sym_names, size_t sym_name_size,
1031                   const unsigned char* versym, size_t versym_size,
1032                   const std::vector<const char*>*);
1033
1034   // Define a special symbol based on an Output_data.  It is a
1035   // multiple definition error if this symbol is already defined.
1036   Symbol*
1037   define_in_output_data(const char* name, const char* version,
1038                         Output_data*, uint64_t value, uint64_t symsize,
1039                         elfcpp::STT type, elfcpp::STB binding,
1040                         elfcpp::STV visibility, unsigned char nonvis,
1041                         bool offset_is_from_end, bool only_if_ref);
1042
1043   // Define a special symbol based on an Output_segment.  It is a
1044   // multiple definition error if this symbol is already defined.
1045   Symbol*
1046   define_in_output_segment(const char* name, const char* version,
1047                            Output_segment*, uint64_t value, uint64_t symsize,
1048                            elfcpp::STT type, elfcpp::STB binding,
1049                            elfcpp::STV visibility, unsigned char nonvis,
1050                            Symbol::Segment_offset_base, bool only_if_ref);
1051
1052   // Define a special symbol with a constant value.  It is a multiple
1053   // definition error if this symbol is already defined.
1054   Symbol*
1055   define_as_constant(const char* name, const char* version,
1056                      uint64_t value, uint64_t symsize, elfcpp::STT type,
1057                      elfcpp::STB binding, elfcpp::STV visibility,
1058                      unsigned char nonvis, bool only_if_ref);
1059
1060   // Define a set of symbols in output sections.  If ONLY_IF_REF is
1061   // true, only define them if they are referenced.
1062   void
1063   define_symbols(const Layout*, int count, const Define_symbol_in_section*,
1064                  bool only_if_ref);
1065
1066   // Define a set of symbols in output segments.  If ONLY_IF_REF is
1067   // true, only defined them if they are referenced.
1068   void
1069   define_symbols(const Layout*, int count, const Define_symbol_in_segment*,
1070                  bool only_if_ref);
1071
1072   // Define SYM using a COPY reloc.  POSD is the Output_data where the
1073   // symbol should be defined--typically a .dyn.bss section.  VALUE is
1074   // the offset within POSD.
1075   template<int size>
1076   void
1077   define_with_copy_reloc(Sized_symbol<size>* sym, Output_data* posd,
1078                          typename elfcpp::Elf_types<size>::Elf_Addr);
1079
1080   // Look up a symbol.
1081   Symbol*
1082   lookup(const char*, const char* version = NULL) const;
1083
1084   // Return the real symbol associated with the forwarder symbol FROM.
1085   Symbol*
1086   resolve_forwards(const Symbol* from) const;
1087
1088   // Return the sized version of a symbol in this table.
1089   template<int size>
1090   Sized_symbol<size>*
1091   get_sized_symbol(Symbol* ACCEPT_SIZE) const;
1092
1093   template<int size>
1094   const Sized_symbol<size>*
1095   get_sized_symbol(const Symbol* ACCEPT_SIZE) const;
1096
1097   // Return the count of undefined symbols seen.
1098   int
1099   saw_undefined() const
1100   { return this->saw_undefined_; }
1101
1102   // Allocate the common symbols
1103   void
1104   allocate_commons(const General_options&, Layout*);
1105
1106   // Add a warning for symbol NAME in object OBJ.  WARNING is the text
1107   // of the warning.
1108   void
1109   add_warning(const char* name, Object* obj, const std::string& warning)
1110   { this->warnings_.add_warning(this, name, obj, warning); }
1111
1112   // Canonicalize a symbol name for use in the hash table.
1113   const char*
1114   canonicalize_name(const char* name)
1115   { return this->namepool_.add(name, true, NULL); }
1116
1117   // Possibly issue a warning for a reference to SYM at LOCATION which
1118   // is in OBJ.
1119   template<int size, bool big_endian>
1120   void
1121   issue_warning(const Symbol* sym,
1122                 const Relocate_info<size, big_endian>* relinfo,
1123                 size_t relnum, off_t reloffset) const
1124   { this->warnings_.issue_warning(sym, relinfo, relnum, reloffset); }
1125
1126   // Check candidate_odr_violations_ to find symbols with the same name
1127   // but apparently different definitions (different source-file/line-no).
1128   void
1129   detect_odr_violations(const Task*, const char* output_file_name) const;
1130
1131   // SYM is defined using a COPY reloc.  Return the dynamic object
1132   // where the original definition was found.
1133   Dynobj*
1134   get_copy_source(const Symbol* sym) const;
1135
1136   // Set the dynamic symbol indexes.  INDEX is the index of the first
1137   // global dynamic symbol.  Pointers to the symbols are stored into
1138   // the vector.  The names are stored into the Stringpool.  This
1139   // returns an updated dynamic symbol index.
1140   unsigned int
1141   set_dynsym_indexes(unsigned int index, std::vector<Symbol*>*,
1142                      Stringpool*, Versions*);
1143
1144   // Finalize the symbol table after we have set the final addresses
1145   // of all the input sections.  This sets the final symbol indexes,
1146   // values and adds the names to *POOL.  *PLOCAL_SYMCOUNT is the
1147   // index of the first global symbol.  OFF is the file offset of the
1148   // global symbol table, DYNOFF is the offset of the globals in the
1149   // dynamic symbol table, DYN_GLOBAL_INDEX is the index of the first
1150   // global dynamic symbol, and DYNCOUNT is the number of global
1151   // dynamic symbols.  This records the parameters, and returns the
1152   // new file offset.  It updates *PLOCAL_SYMCOUNT if it created any
1153   // local symbols.
1154   off_t
1155   finalize(off_t off, off_t dynoff, size_t dyn_global_index, size_t dyncount,
1156            Stringpool* pool, unsigned int *plocal_symcount);
1157
1158   // Write out the global symbols.
1159   void
1160   write_globals(const Input_objects*, const Stringpool*, const Stringpool*,
1161                 Output_file*) const;
1162
1163   // Write out a section symbol.  Return the updated offset.
1164   void
1165   write_section_symbol(const Output_section*, Output_file*, off_t) const;
1166
1167   // Dump statistical information to stderr.
1168   void
1169   print_stats() const;
1170
1171   // Return the version script information.
1172   const Version_script_info&
1173   version_script() const
1174   { return version_script_; }
1175
1176  private:
1177   Symbol_table(const Symbol_table&);
1178   Symbol_table& operator=(const Symbol_table&);
1179
1180   // Make FROM a forwarder symbol to TO.
1181   void
1182   make_forwarder(Symbol* from, Symbol* to);
1183
1184   // Add a symbol.
1185   template<int size, bool big_endian>
1186   Sized_symbol<size>*
1187   add_from_object(Object*, const char *name, Stringpool::Key name_key,
1188                   const char *version, Stringpool::Key version_key,
1189                   bool def, const elfcpp::Sym<size, big_endian>& sym,
1190                   const elfcpp::Sym<size, big_endian>& orig_sym);
1191
1192   // Resolve symbols.
1193   template<int size, bool big_endian>
1194   void
1195   resolve(Sized_symbol<size>* to,
1196           const elfcpp::Sym<size, big_endian>& sym,
1197           const elfcpp::Sym<size, big_endian>& orig_sym,
1198           Object*, const char* version);
1199
1200   template<int size, bool big_endian>
1201   void
1202   resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
1203           const char* version ACCEPT_SIZE_ENDIAN);
1204
1205   // Record that a symbol is forced to be local by a version script.
1206   void
1207   force_local(Symbol*);
1208
1209   // Whether we should override a symbol, based on flags in
1210   // resolve.cc.
1211   static bool
1212   should_override(const Symbol*, unsigned int, Object*, bool*);
1213
1214   // Override a symbol.
1215   template<int size, bool big_endian>
1216   void
1217   override(Sized_symbol<size>* tosym,
1218            const elfcpp::Sym<size, big_endian>& fromsym,
1219            Object* object, const char* version);
1220
1221   // Whether we should override a symbol with a special symbol which
1222   // is automatically defined by the linker.
1223   static bool
1224   should_override_with_special(const Symbol*);
1225
1226   // Override a symbol with a special symbol.
1227   template<int size>
1228   void
1229   override_with_special(Sized_symbol<size>* tosym,
1230                         const Sized_symbol<size>* fromsym);
1231
1232   // Record all weak alias sets for a dynamic object.
1233   template<int size>
1234   void
1235   record_weak_aliases(std::vector<Sized_symbol<size>*>*);
1236
1237   // Define a special symbol.
1238   template<int size, bool big_endian>
1239   Sized_symbol<size>*
1240   define_special_symbol(const char** pname, const char** pversion,
1241                         bool only_if_ref, Sized_symbol<size>** poldsym
1242                         ACCEPT_SIZE_ENDIAN);
1243
1244   // Define a symbol in an Output_data, sized version.
1245   template<int size>
1246   Sized_symbol<size>*
1247   do_define_in_output_data(const char* name, const char* version, Output_data*,
1248                            typename elfcpp::Elf_types<size>::Elf_Addr value,
1249                            typename elfcpp::Elf_types<size>::Elf_WXword ssize,
1250                            elfcpp::STT type, elfcpp::STB binding,
1251                            elfcpp::STV visibility, unsigned char nonvis,
1252                            bool offset_is_from_end, bool only_if_ref);
1253
1254   // Define a symbol in an Output_segment, sized version.
1255   template<int size>
1256   Sized_symbol<size>*
1257   do_define_in_output_segment(
1258     const char* name, const char* version, Output_segment* os,
1259     typename elfcpp::Elf_types<size>::Elf_Addr value,
1260     typename elfcpp::Elf_types<size>::Elf_WXword ssize,
1261     elfcpp::STT type, elfcpp::STB binding,
1262     elfcpp::STV visibility, unsigned char nonvis,
1263     Symbol::Segment_offset_base offset_base, bool only_if_ref);
1264
1265   // Define a symbol as a constant, sized version.
1266   template<int size>
1267   Sized_symbol<size>*
1268   do_define_as_constant(
1269     const char* name, const char* version,
1270     typename elfcpp::Elf_types<size>::Elf_Addr value,
1271     typename elfcpp::Elf_types<size>::Elf_WXword ssize,
1272     elfcpp::STT type, elfcpp::STB binding,
1273     elfcpp::STV visibility, unsigned char nonvis,
1274     bool only_if_ref);
1275
1276   // Allocate the common symbols, sized version.
1277   template<int size>
1278   void
1279   do_allocate_commons(const General_options&, Layout*);
1280
1281   // Implement detect_odr_violations.
1282   template<int size, bool big_endian>
1283   void
1284   sized_detect_odr_violations() const;
1285
1286   // Finalize symbols specialized for size.
1287   template<int size>
1288   off_t
1289   sized_finalize(off_t, Stringpool*, unsigned int*);
1290
1291   // Finalize a symbol.  Return whether it should be added to the
1292   // symbol table.
1293   template<int size>
1294   bool
1295   sized_finalize_symbol(Symbol*);
1296
1297   // Add a symbol the final symtab by setting its index.
1298   template<int size>
1299   void
1300   add_to_final_symtab(Symbol*, Stringpool*, unsigned int* pindex, off_t* poff);
1301
1302   // Write globals specialized for size and endianness.
1303   template<int size, bool big_endian>
1304   void
1305   sized_write_globals(const Input_objects*, const Stringpool*,
1306                       const Stringpool*, Output_file*) const;
1307
1308   // Write out a symbol to P.
1309   template<int size, bool big_endian>
1310   void
1311   sized_write_symbol(Sized_symbol<size>*,
1312                      typename elfcpp::Elf_types<size>::Elf_Addr value,
1313                      unsigned int shndx,
1314                      const Stringpool*, unsigned char* p
1315                      ACCEPT_SIZE_ENDIAN) const;
1316
1317   // Possibly warn about an undefined symbol from a dynamic object.
1318   void
1319   warn_about_undefined_dynobj_symbol(const Input_objects*, Symbol*) const;
1320
1321   // Write out a section symbol, specialized for size and endianness.
1322   template<int size, bool big_endian>
1323   void
1324   sized_write_section_symbol(const Output_section*, Output_file*, off_t) const;
1325
1326   // The type of the symbol hash table.
1327
1328   typedef std::pair<Stringpool::Key, Stringpool::Key> Symbol_table_key;
1329
1330   struct Symbol_table_hash
1331   {
1332     size_t
1333     operator()(const Symbol_table_key&) const;
1334   };
1335
1336   struct Symbol_table_eq
1337   {
1338     bool
1339     operator()(const Symbol_table_key&, const Symbol_table_key&) const;
1340   };
1341
1342   typedef Unordered_map<Symbol_table_key, Symbol*, Symbol_table_hash,
1343                         Symbol_table_eq> Symbol_table_type;
1344
1345   // The type of the list of common symbols.
1346   typedef std::vector<Symbol*> Commons_type;
1347
1348   // The type of the list of symbols which have been forced local.
1349   typedef std::vector<Symbol*> Forced_locals;
1350
1351   // A map from symbols with COPY relocs to the dynamic objects where
1352   // they are defined.
1353   typedef Unordered_map<const Symbol*, Dynobj*> Copied_symbol_dynobjs;
1354
1355   // A map from symbol name (as a pointer into the namepool) to all
1356   // the locations the symbols is (weakly) defined (and certain other
1357   // conditions are met).  This map will be used later to detect
1358   // possible One Definition Rule (ODR) violations.
1359   struct Symbol_location
1360   {
1361     Object* object;         // Object where the symbol is defined.
1362     unsigned int shndx;     // Section-in-object where the symbol is defined.
1363     off_t offset;           // Offset-in-section where the symbol is defined.
1364     bool operator==(const Symbol_location& that) const
1365     {
1366       return (this->object == that.object
1367               && this->shndx == that.shndx
1368               && this->offset == that.offset);
1369     }
1370   };
1371
1372   struct Symbol_location_hash
1373   {
1374     size_t operator()(const Symbol_location& loc) const
1375     { return reinterpret_cast<uintptr_t>(loc.object) ^ loc.offset ^ loc.shndx; }
1376   };
1377
1378   typedef Unordered_map<const char*,
1379                         Unordered_set<Symbol_location, Symbol_location_hash> >
1380   Odr_map;
1381
1382   // We increment this every time we see a new undefined symbol, for
1383   // use in archive groups.
1384   int saw_undefined_;
1385   // The index of the first global symbol in the output file.
1386   unsigned int first_global_index_;
1387   // The file offset within the output symtab section where we should
1388   // write the table.
1389   off_t offset_;
1390   // The number of global symbols we want to write out.
1391   unsigned int output_count_;
1392   // The file offset of the global dynamic symbols, or 0 if none.
1393   off_t dynamic_offset_;
1394   // The index of the first global dynamic symbol.
1395   unsigned int first_dynamic_global_index_;
1396   // The number of global dynamic symbols, or 0 if none.
1397   unsigned int dynamic_count_;
1398   // The symbol hash table.
1399   Symbol_table_type table_;
1400   // A pool of symbol names.  This is used for all global symbols.
1401   // Entries in the hash table point into this pool.
1402   Stringpool namepool_;
1403   // Forwarding symbols.
1404   Unordered_map<const Symbol*, Symbol*> forwarders_;
1405   // Weak aliases.  A symbol in this list points to the next alias.
1406   // The aliases point to each other in a circular list.
1407   Unordered_map<Symbol*, Symbol*> weak_aliases_;
1408   // We don't expect there to be very many common symbols, so we keep
1409   // a list of them.  When we find a common symbol we add it to this
1410   // list.  It is possible that by the time we process the list the
1411   // symbol is no longer a common symbol.  It may also have become a
1412   // forwarder.
1413   Commons_type commons_;
1414   // A list of symbols which have been forced to be local.  We don't
1415   // expect there to be very many of them, so we keep a list of them
1416   // rather than walking the whole table to find them.
1417   Forced_locals forced_locals_;
1418   // Manage symbol warnings.
1419   Warnings warnings_;
1420   // Manage potential One Definition Rule (ODR) violations.
1421   Odr_map candidate_odr_violations_;
1422
1423   // When we emit a COPY reloc for a symbol, we define it in an
1424   // Output_data.  When it's time to emit version information for it,
1425   // we need to know the dynamic object in which we found the original
1426   // definition.  This maps symbols with COPY relocs to the dynamic
1427   // object where they were defined.
1428   Copied_symbol_dynobjs copied_symbol_dynobjs_;
1429   // Information parsed from the version script, if any.
1430   const Version_script_info& version_script_;
1431 };
1432
1433 // We inline get_sized_symbol for efficiency.
1434
1435 template<int size>
1436 Sized_symbol<size>*
1437 Symbol_table::get_sized_symbol(Symbol* sym ACCEPT_SIZE) const
1438 {
1439   gold_assert(size == parameters->get_size());
1440   return static_cast<Sized_symbol<size>*>(sym);
1441 }
1442
1443 template<int size>
1444 const Sized_symbol<size>*
1445 Symbol_table::get_sized_symbol(const Symbol* sym ACCEPT_SIZE) const
1446 {
1447   gold_assert(size == parameters->get_size());
1448   return static_cast<const Sized_symbol<size>*>(sym);
1449 }
1450
1451 } // End namespace gold.
1452
1453 #endif // !defined(GOLD_SYMTAB_H)