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