Commit | Line | Data |
---|---|---|
bae7f79e ILT |
1 | // object.cc -- support for an object file for linking in gold |
2 | ||
6cb15b7f ILT |
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 | ||
bae7f79e ILT |
23 | #include "gold.h" |
24 | ||
25 | #include <cerrno> | |
26 | #include <cstring> | |
645f8123 | 27 | #include <cstdarg> |
a2b1aa12 | 28 | #include "demangle.h" |
9a2d6984 | 29 | #include "libiberty.h" |
bae7f79e | 30 | |
14bfc3f5 | 31 | #include "target-select.h" |
5c2c6c95 | 32 | #include "dwarf_reader.h" |
a2fb1b05 | 33 | #include "layout.h" |
61ba1cf9 | 34 | #include "output.h" |
f6ce93d6 | 35 | #include "symtab.h" |
4c50553d | 36 | #include "reloc.h" |
f6ce93d6 ILT |
37 | #include "object.h" |
38 | #include "dynobj.h" | |
bae7f79e ILT |
39 | |
40 | namespace gold | |
41 | { | |
42 | ||
645f8123 ILT |
43 | // Class Object. |
44 | ||
dbe717ef ILT |
45 | // Set the target based on fields in the ELF file header. |
46 | ||
47 | void | |
48 | Object::set_target(int machine, int size, bool big_endian, int osabi, | |
49 | int abiversion) | |
50 | { | |
51 | Target* target = select_target(machine, size, big_endian, osabi, abiversion); | |
52 | if (target == NULL) | |
75f2446e ILT |
53 | gold_fatal(_("%s: unsupported ELF machine number %d"), |
54 | this->name().c_str(), machine); | |
dbe717ef ILT |
55 | this->target_ = target; |
56 | } | |
57 | ||
75f2446e ILT |
58 | // Report an error for this object file. This is used by the |
59 | // elfcpp::Elf_file interface, and also called by the Object code | |
60 | // itself. | |
645f8123 ILT |
61 | |
62 | void | |
75f2446e | 63 | Object::error(const char* format, ...) const |
645f8123 ILT |
64 | { |
65 | va_list args; | |
645f8123 | 66 | va_start(args, format); |
75f2446e ILT |
67 | char* buf = NULL; |
68 | if (vasprintf(&buf, format, args) < 0) | |
69 | gold_nomem(); | |
645f8123 | 70 | va_end(args); |
75f2446e ILT |
71 | gold_error(_("%s: %s"), this->name().c_str(), buf); |
72 | free(buf); | |
645f8123 ILT |
73 | } |
74 | ||
75 | // Return a view of the contents of a section. | |
76 | ||
77 | const unsigned char* | |
9eb9fa57 | 78 | Object::section_contents(unsigned int shndx, off_t* plen, bool cache) |
645f8123 ILT |
79 | { |
80 | Location loc(this->do_section_contents(shndx)); | |
81 | *plen = loc.data_size; | |
9eb9fa57 | 82 | return this->get_view(loc.file_offset, loc.data_size, cache); |
645f8123 ILT |
83 | } |
84 | ||
dbe717ef ILT |
85 | // Read the section data into SD. This is code common to Sized_relobj |
86 | // and Sized_dynobj, so we put it into Object. | |
87 | ||
88 | template<int size, bool big_endian> | |
89 | void | |
90 | Object::read_section_data(elfcpp::Elf_file<size, big_endian, Object>* elf_file, | |
91 | Read_symbols_data* sd) | |
92 | { | |
93 | const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size; | |
94 | ||
95 | // Read the section headers. | |
96 | const off_t shoff = elf_file->shoff(); | |
97 | const unsigned int shnum = this->shnum(); | |
9eb9fa57 | 98 | sd->section_headers = this->get_lasting_view(shoff, shnum * shdr_size, true); |
dbe717ef ILT |
99 | |
100 | // Read the section names. | |
101 | const unsigned char* pshdrs = sd->section_headers->data(); | |
102 | const unsigned char* pshdrnames = pshdrs + elf_file->shstrndx() * shdr_size; | |
103 | typename elfcpp::Shdr<size, big_endian> shdrnames(pshdrnames); | |
104 | ||
105 | if (shdrnames.get_sh_type() != elfcpp::SHT_STRTAB) | |
75f2446e ILT |
106 | this->error(_("section name section has wrong type: %u"), |
107 | static_cast<unsigned int>(shdrnames.get_sh_type())); | |
dbe717ef ILT |
108 | |
109 | sd->section_names_size = shdrnames.get_sh_size(); | |
110 | sd->section_names = this->get_lasting_view(shdrnames.get_sh_offset(), | |
9eb9fa57 | 111 | sd->section_names_size, false); |
dbe717ef ILT |
112 | } |
113 | ||
114 | // If NAME is the name of a special .gnu.warning section, arrange for | |
115 | // the warning to be issued. SHNDX is the section index. Return | |
116 | // whether it is a warning section. | |
117 | ||
118 | bool | |
119 | Object::handle_gnu_warning_section(const char* name, unsigned int shndx, | |
120 | Symbol_table* symtab) | |
121 | { | |
122 | const char warn_prefix[] = ".gnu.warning."; | |
123 | const int warn_prefix_len = sizeof warn_prefix - 1; | |
124 | if (strncmp(name, warn_prefix, warn_prefix_len) == 0) | |
125 | { | |
126 | symtab->add_warning(name + warn_prefix_len, this, shndx); | |
127 | return true; | |
128 | } | |
129 | return false; | |
130 | } | |
131 | ||
f6ce93d6 | 132 | // Class Sized_relobj. |
bae7f79e ILT |
133 | |
134 | template<int size, bool big_endian> | |
f6ce93d6 | 135 | Sized_relobj<size, big_endian>::Sized_relobj( |
bae7f79e ILT |
136 | const std::string& name, |
137 | Input_file* input_file, | |
138 | off_t offset, | |
139 | const elfcpp::Ehdr<size, big_endian>& ehdr) | |
f6ce93d6 | 140 | : Relobj(name, input_file, offset), |
645f8123 | 141 | elf_file_(this, ehdr), |
dbe717ef | 142 | symtab_shndx_(-1U), |
61ba1cf9 ILT |
143 | local_symbol_count_(0), |
144 | output_local_symbol_count_(0), | |
7bf1f802 | 145 | output_local_dynsym_count_(0), |
730cdc88 | 146 | symbols_(), |
61ba1cf9 | 147 | local_symbol_offset_(0), |
7bf1f802 | 148 | local_dynsym_offset_(0), |
e727fa71 | 149 | local_values_(), |
730cdc88 ILT |
150 | local_got_offsets_(), |
151 | has_eh_frame_(false) | |
bae7f79e | 152 | { |
bae7f79e ILT |
153 | } |
154 | ||
155 | template<int size, bool big_endian> | |
f6ce93d6 | 156 | Sized_relobj<size, big_endian>::~Sized_relobj() |
bae7f79e ILT |
157 | { |
158 | } | |
159 | ||
645f8123 | 160 | // Set up an object file based on the file header. This sets up the |
bae7f79e ILT |
161 | // target and reads the section information. |
162 | ||
163 | template<int size, bool big_endian> | |
164 | void | |
f6ce93d6 | 165 | Sized_relobj<size, big_endian>::setup( |
bae7f79e ILT |
166 | const elfcpp::Ehdr<size, big_endian>& ehdr) |
167 | { | |
dbe717ef ILT |
168 | this->set_target(ehdr.get_e_machine(), size, big_endian, |
169 | ehdr.get_e_ident()[elfcpp::EI_OSABI], | |
170 | ehdr.get_e_ident()[elfcpp::EI_ABIVERSION]); | |
12e14209 | 171 | |
dbe717ef | 172 | const unsigned int shnum = this->elf_file_.shnum(); |
a2fb1b05 | 173 | this->set_shnum(shnum); |
dbe717ef | 174 | } |
12e14209 | 175 | |
dbe717ef ILT |
176 | // Find the SHT_SYMTAB section, given the section headers. The ELF |
177 | // standard says that maybe in the future there can be more than one | |
178 | // SHT_SYMTAB section. Until somebody figures out how that could | |
179 | // work, we assume there is only one. | |
12e14209 | 180 | |
dbe717ef ILT |
181 | template<int size, bool big_endian> |
182 | void | |
183 | Sized_relobj<size, big_endian>::find_symtab(const unsigned char* pshdrs) | |
184 | { | |
185 | const unsigned int shnum = this->shnum(); | |
186 | this->symtab_shndx_ = 0; | |
187 | if (shnum > 0) | |
bae7f79e | 188 | { |
dbe717ef ILT |
189 | // Look through the sections in reverse order, since gas tends |
190 | // to put the symbol table at the end. | |
191 | const unsigned char* p = pshdrs + shnum * This::shdr_size; | |
192 | unsigned int i = shnum; | |
193 | while (i > 0) | |
bae7f79e | 194 | { |
dbe717ef ILT |
195 | --i; |
196 | p -= This::shdr_size; | |
197 | typename This::Shdr shdr(p); | |
198 | if (shdr.get_sh_type() == elfcpp::SHT_SYMTAB) | |
199 | { | |
200 | this->symtab_shndx_ = i; | |
201 | break; | |
202 | } | |
bae7f79e | 203 | } |
bae7f79e ILT |
204 | } |
205 | } | |
206 | ||
730cdc88 ILT |
207 | // Return whether SHDR has the right type and flags to be a GNU |
208 | // .eh_frame section. | |
209 | ||
210 | template<int size, bool big_endian> | |
211 | bool | |
212 | Sized_relobj<size, big_endian>::check_eh_frame_flags( | |
213 | const elfcpp::Shdr<size, big_endian>* shdr) const | |
214 | { | |
215 | return (shdr->get_sh_size() > 0 | |
216 | && shdr->get_sh_type() == elfcpp::SHT_PROGBITS | |
217 | && shdr->get_sh_flags() == elfcpp::SHF_ALLOC); | |
218 | } | |
219 | ||
220 | // Return whether there is a GNU .eh_frame section, given the section | |
221 | // headers and the section names. | |
222 | ||
223 | template<int size, bool big_endian> | |
224 | bool | |
225 | Sized_relobj<size, big_endian>::find_eh_frame(const unsigned char* pshdrs, | |
226 | const char* names, | |
227 | off_t names_size) const | |
228 | { | |
229 | const unsigned int shnum = this->shnum(); | |
230 | const unsigned char* p = pshdrs + This::shdr_size; | |
231 | for (unsigned int i = 1; i < shnum; ++i, p += This::shdr_size) | |
232 | { | |
233 | typename This::Shdr shdr(p); | |
234 | if (this->check_eh_frame_flags(&shdr)) | |
235 | { | |
236 | if (shdr.get_sh_name() >= names_size) | |
237 | { | |
238 | this->error(_("bad section name offset for section %u: %lu"), | |
239 | i, static_cast<unsigned long>(shdr.get_sh_name())); | |
240 | continue; | |
241 | } | |
242 | ||
243 | const char* name = names + shdr.get_sh_name(); | |
244 | if (strcmp(name, ".eh_frame") == 0) | |
245 | return true; | |
246 | } | |
247 | } | |
248 | return false; | |
249 | } | |
250 | ||
12e14209 | 251 | // Read the sections and symbols from an object file. |
bae7f79e ILT |
252 | |
253 | template<int size, bool big_endian> | |
12e14209 | 254 | void |
f6ce93d6 | 255 | Sized_relobj<size, big_endian>::do_read_symbols(Read_symbols_data* sd) |
bae7f79e | 256 | { |
dbe717ef | 257 | this->read_section_data(&this->elf_file_, sd); |
12e14209 | 258 | |
dbe717ef ILT |
259 | const unsigned char* const pshdrs = sd->section_headers->data(); |
260 | ||
261 | this->find_symtab(pshdrs); | |
12e14209 | 262 | |
730cdc88 ILT |
263 | const unsigned char* namesu = sd->section_names->data(); |
264 | const char* names = reinterpret_cast<const char*>(namesu); | |
265 | if (this->find_eh_frame(pshdrs, names, sd->section_names_size)) | |
266 | this->has_eh_frame_ = true; | |
267 | ||
75f2446e ILT |
268 | sd->symbols = NULL; |
269 | sd->symbols_size = 0; | |
730cdc88 | 270 | sd->external_symbols_offset = 0; |
75f2446e ILT |
271 | sd->symbol_names = NULL; |
272 | sd->symbol_names_size = 0; | |
273 | ||
645f8123 | 274 | if (this->symtab_shndx_ == 0) |
bae7f79e ILT |
275 | { |
276 | // No symbol table. Weird but legal. | |
12e14209 | 277 | return; |
bae7f79e ILT |
278 | } |
279 | ||
12e14209 ILT |
280 | // Get the symbol table section header. |
281 | typename This::Shdr symtabshdr(pshdrs | |
645f8123 | 282 | + this->symtab_shndx_ * This::shdr_size); |
a3ad94ed | 283 | gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB); |
bae7f79e | 284 | |
730cdc88 ILT |
285 | // If this object has a .eh_frame section, we need all the symbols. |
286 | // Otherwise we only need the external symbols. While it would be | |
287 | // simpler to just always read all the symbols, I've seen object | |
288 | // files with well over 2000 local symbols, which for a 64-bit | |
289 | // object file format is over 5 pages that we don't need to read | |
290 | // now. | |
291 | ||
75f65a3e | 292 | const int sym_size = This::sym_size; |
92e059d8 ILT |
293 | const unsigned int loccount = symtabshdr.get_sh_info(); |
294 | this->local_symbol_count_ = loccount; | |
7bf1f802 | 295 | this->local_values_.resize(loccount); |
92e059d8 | 296 | off_t locsize = loccount * sym_size; |
730cdc88 ILT |
297 | off_t dataoff = symtabshdr.get_sh_offset(); |
298 | off_t datasize = symtabshdr.get_sh_size(); | |
299 | off_t extoff = dataoff + locsize; | |
300 | off_t extsize = datasize - locsize; | |
75f65a3e | 301 | |
730cdc88 ILT |
302 | off_t readoff = this->has_eh_frame_ ? dataoff : extoff; |
303 | off_t readsize = this->has_eh_frame_ ? datasize : extsize; | |
304 | ||
305 | File_view* fvsymtab = this->get_lasting_view(readoff, readsize, false); | |
bae7f79e ILT |
306 | |
307 | // Read the section header for the symbol names. | |
dbe717ef ILT |
308 | unsigned int strtab_shndx = symtabshdr.get_sh_link(); |
309 | if (strtab_shndx >= this->shnum()) | |
bae7f79e | 310 | { |
75f2446e ILT |
311 | this->error(_("invalid symbol table name index: %u"), strtab_shndx); |
312 | return; | |
bae7f79e | 313 | } |
dbe717ef | 314 | typename This::Shdr strtabshdr(pshdrs + strtab_shndx * This::shdr_size); |
bae7f79e ILT |
315 | if (strtabshdr.get_sh_type() != elfcpp::SHT_STRTAB) |
316 | { | |
75f2446e ILT |
317 | this->error(_("symbol table name section has wrong type: %u"), |
318 | static_cast<unsigned int>(strtabshdr.get_sh_type())); | |
319 | return; | |
bae7f79e ILT |
320 | } |
321 | ||
322 | // Read the symbol names. | |
323 | File_view* fvstrtab = this->get_lasting_view(strtabshdr.get_sh_offset(), | |
9eb9fa57 | 324 | strtabshdr.get_sh_size(), true); |
bae7f79e | 325 | |
12e14209 | 326 | sd->symbols = fvsymtab; |
730cdc88 ILT |
327 | sd->symbols_size = readsize; |
328 | sd->external_symbols_offset = this->has_eh_frame_ ? locsize : 0; | |
12e14209 ILT |
329 | sd->symbol_names = fvstrtab; |
330 | sd->symbol_names_size = strtabshdr.get_sh_size(); | |
a2fb1b05 ILT |
331 | } |
332 | ||
730cdc88 ILT |
333 | // Return the section index of symbol SYM. Set *VALUE to its value in |
334 | // the object file. Note that for a symbol which is not defined in | |
335 | // this object file, this will set *VALUE to 0 and return SHN_UNDEF; | |
336 | // it will not return the final value of the symbol in the link. | |
337 | ||
338 | template<int size, bool big_endian> | |
339 | unsigned int | |
340 | Sized_relobj<size, big_endian>::symbol_section_and_value(unsigned int sym, | |
341 | Address* value) | |
342 | { | |
343 | off_t symbols_size; | |
344 | const unsigned char* symbols = this->section_contents(this->symtab_shndx_, | |
345 | &symbols_size, | |
346 | false); | |
347 | ||
348 | const size_t count = symbols_size / This::sym_size; | |
349 | gold_assert(sym < count); | |
350 | ||
351 | elfcpp::Sym<size, big_endian> elfsym(symbols + sym * This::sym_size); | |
352 | *value = elfsym.get_st_value(); | |
353 | // FIXME: Handle SHN_XINDEX. | |
354 | return elfsym.get_st_shndx(); | |
355 | } | |
356 | ||
a2fb1b05 ILT |
357 | // Return whether to include a section group in the link. LAYOUT is |
358 | // used to keep track of which section groups we have already seen. | |
359 | // INDEX is the index of the section group and SHDR is the section | |
360 | // header. If we do not want to include this group, we set bits in | |
361 | // OMIT for each section which should be discarded. | |
362 | ||
363 | template<int size, bool big_endian> | |
364 | bool | |
f6ce93d6 | 365 | Sized_relobj<size, big_endian>::include_section_group( |
a2fb1b05 ILT |
366 | Layout* layout, |
367 | unsigned int index, | |
368 | const elfcpp::Shdr<size, big_endian>& shdr, | |
369 | std::vector<bool>* omit) | |
370 | { | |
371 | // Read the section contents. | |
372 | const unsigned char* pcon = this->get_view(shdr.get_sh_offset(), | |
9eb9fa57 | 373 | shdr.get_sh_size(), false); |
a2fb1b05 ILT |
374 | const elfcpp::Elf_Word* pword = |
375 | reinterpret_cast<const elfcpp::Elf_Word*>(pcon); | |
376 | ||
377 | // The first word contains flags. We only care about COMDAT section | |
378 | // groups. Other section groups are always included in the link | |
379 | // just like ordinary sections. | |
f6ce93d6 | 380 | elfcpp::Elf_Word flags = elfcpp::Swap<32, big_endian>::readval(pword); |
a2fb1b05 ILT |
381 | if ((flags & elfcpp::GRP_COMDAT) == 0) |
382 | return true; | |
383 | ||
384 | // Look up the group signature, which is the name of a symbol. This | |
385 | // is a lot of effort to go to to read a string. Why didn't they | |
386 | // just use the name of the SHT_GROUP section as the group | |
387 | // signature? | |
388 | ||
389 | // Get the appropriate symbol table header (this will normally be | |
390 | // the single SHT_SYMTAB section, but in principle it need not be). | |
645f8123 ILT |
391 | const unsigned int link = shdr.get_sh_link(); |
392 | typename This::Shdr symshdr(this, this->elf_file_.section_header(link)); | |
a2fb1b05 ILT |
393 | |
394 | // Read the symbol table entry. | |
395 | if (shdr.get_sh_info() >= symshdr.get_sh_size() / This::sym_size) | |
396 | { | |
75f2446e ILT |
397 | this->error(_("section group %u info %u out of range"), |
398 | index, shdr.get_sh_info()); | |
399 | return false; | |
a2fb1b05 ILT |
400 | } |
401 | off_t symoff = symshdr.get_sh_offset() + shdr.get_sh_info() * This::sym_size; | |
9eb9fa57 | 402 | const unsigned char* psym = this->get_view(symoff, This::sym_size, true); |
a2fb1b05 ILT |
403 | elfcpp::Sym<size, big_endian> sym(psym); |
404 | ||
a2fb1b05 | 405 | // Read the symbol table names. |
645f8123 ILT |
406 | off_t symnamelen; |
407 | const unsigned char* psymnamesu; | |
9eb9fa57 ILT |
408 | psymnamesu = this->section_contents(symshdr.get_sh_link(), &symnamelen, |
409 | true); | |
a2fb1b05 ILT |
410 | const char* psymnames = reinterpret_cast<const char*>(psymnamesu); |
411 | ||
412 | // Get the section group signature. | |
645f8123 | 413 | if (sym.get_st_name() >= symnamelen) |
a2fb1b05 | 414 | { |
75f2446e ILT |
415 | this->error(_("symbol %u name offset %u out of range"), |
416 | shdr.get_sh_info(), sym.get_st_name()); | |
417 | return false; | |
a2fb1b05 ILT |
418 | } |
419 | ||
420 | const char* signature = psymnames + sym.get_st_name(); | |
421 | ||
ead1e424 ILT |
422 | // It seems that some versions of gas will create a section group |
423 | // associated with a section symbol, and then fail to give a name to | |
424 | // the section symbol. In such a case, use the name of the section. | |
425 | // FIXME. | |
645f8123 ILT |
426 | std::string secname; |
427 | if (signature[0] == '\0' && sym.get_st_type() == elfcpp::STT_SECTION) | |
ead1e424 | 428 | { |
645f8123 ILT |
429 | secname = this->section_name(sym.get_st_shndx()); |
430 | signature = secname.c_str(); | |
ead1e424 ILT |
431 | } |
432 | ||
a2fb1b05 ILT |
433 | // Record this section group, and see whether we've already seen one |
434 | // with the same signature. | |
435 | if (layout->add_comdat(signature, true)) | |
436 | return true; | |
437 | ||
438 | // This is a duplicate. We want to discard the sections in this | |
439 | // group. | |
440 | size_t count = shdr.get_sh_size() / sizeof(elfcpp::Elf_Word); | |
441 | for (size_t i = 1; i < count; ++i) | |
442 | { | |
f6ce93d6 ILT |
443 | elfcpp::Elf_Word secnum = |
444 | elfcpp::Swap<32, big_endian>::readval(pword + i); | |
a2fb1b05 ILT |
445 | if (secnum >= this->shnum()) |
446 | { | |
75f2446e ILT |
447 | this->error(_("section %u in section group %u out of range"), |
448 | secnum, index); | |
449 | continue; | |
a2fb1b05 ILT |
450 | } |
451 | (*omit)[secnum] = true; | |
452 | } | |
453 | ||
454 | return false; | |
455 | } | |
456 | ||
457 | // Whether to include a linkonce section in the link. NAME is the | |
458 | // name of the section and SHDR is the section header. | |
459 | ||
460 | // Linkonce sections are a GNU extension implemented in the original | |
461 | // GNU linker before section groups were defined. The semantics are | |
462 | // that we only include one linkonce section with a given name. The | |
463 | // name of a linkonce section is normally .gnu.linkonce.T.SYMNAME, | |
464 | // where T is the type of section and SYMNAME is the name of a symbol. | |
465 | // In an attempt to make linkonce sections interact well with section | |
466 | // groups, we try to identify SYMNAME and use it like a section group | |
467 | // signature. We want to block section groups with that signature, | |
468 | // but not other linkonce sections with that signature. We also use | |
469 | // the full name of the linkonce section as a normal section group | |
470 | // signature. | |
471 | ||
472 | template<int size, bool big_endian> | |
473 | bool | |
f6ce93d6 | 474 | Sized_relobj<size, big_endian>::include_linkonce_section( |
a2fb1b05 ILT |
475 | Layout* layout, |
476 | const char* name, | |
477 | const elfcpp::Shdr<size, big_endian>&) | |
478 | { | |
ad435a24 ILT |
479 | // In general the symbol name we want will be the string following |
480 | // the last '.'. However, we have to handle the case of | |
481 | // .gnu.linkonce.t.__i686.get_pc_thunk.bx, which was generated by | |
482 | // some versions of gcc. So we use a heuristic: if the name starts | |
483 | // with ".gnu.linkonce.t.", we use everything after that. Otherwise | |
484 | // we look for the last '.'. We can't always simply skip | |
485 | // ".gnu.linkonce.X", because we have to deal with cases like | |
486 | // ".gnu.linkonce.d.rel.ro.local". | |
487 | const char* const linkonce_t = ".gnu.linkonce.t."; | |
488 | const char* symname; | |
489 | if (strncmp(name, linkonce_t, strlen(linkonce_t)) == 0) | |
490 | symname = name + strlen(linkonce_t); | |
491 | else | |
492 | symname = strrchr(name, '.') + 1; | |
a783673b ILT |
493 | bool include1 = layout->add_comdat(symname, false); |
494 | bool include2 = layout->add_comdat(name, true); | |
495 | return include1 && include2; | |
a2fb1b05 ILT |
496 | } |
497 | ||
498 | // Lay out the input sections. We walk through the sections and check | |
499 | // whether they should be included in the link. If they should, we | |
500 | // pass them to the Layout object, which will return an output section | |
501 | // and an offset. | |
502 | ||
503 | template<int size, bool big_endian> | |
504 | void | |
7e1edb90 | 505 | Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, |
f6ce93d6 | 506 | Layout* layout, |
12e14209 | 507 | Read_symbols_data* sd) |
a2fb1b05 | 508 | { |
dbe717ef | 509 | const unsigned int shnum = this->shnum(); |
12e14209 ILT |
510 | if (shnum == 0) |
511 | return; | |
a2fb1b05 ILT |
512 | |
513 | // Get the section headers. | |
12e14209 | 514 | const unsigned char* pshdrs = sd->section_headers->data(); |
a2fb1b05 ILT |
515 | |
516 | // Get the section names. | |
12e14209 | 517 | const unsigned char* pnamesu = sd->section_names->data(); |
a2fb1b05 ILT |
518 | const char* pnames = reinterpret_cast<const char*>(pnamesu); |
519 | ||
730cdc88 ILT |
520 | // For each section, record the index of the reloc section if any. |
521 | // Use 0 to mean that there is no reloc section, -1U to mean that | |
522 | // there is more than one. | |
523 | std::vector<unsigned int> reloc_shndx(shnum, 0); | |
524 | std::vector<unsigned int> reloc_type(shnum, elfcpp::SHT_NULL); | |
525 | // Skip the first, dummy, section. | |
526 | pshdrs += This::shdr_size; | |
527 | for (unsigned int i = 1; i < shnum; ++i, pshdrs += This::shdr_size) | |
528 | { | |
529 | typename This::Shdr shdr(pshdrs); | |
530 | ||
531 | unsigned int sh_type = shdr.get_sh_type(); | |
532 | if (sh_type == elfcpp::SHT_REL || sh_type == elfcpp::SHT_RELA) | |
533 | { | |
534 | unsigned int target_shndx = shdr.get_sh_info(); | |
535 | if (target_shndx == 0 || target_shndx >= shnum) | |
536 | { | |
537 | this->error(_("relocation section %u has bad info %u"), | |
538 | i, target_shndx); | |
539 | continue; | |
540 | } | |
541 | ||
542 | if (reloc_shndx[target_shndx] != 0) | |
543 | reloc_shndx[target_shndx] = -1U; | |
544 | else | |
545 | { | |
546 | reloc_shndx[target_shndx] = i; | |
547 | reloc_type[target_shndx] = sh_type; | |
548 | } | |
549 | } | |
550 | } | |
551 | ||
a2fb1b05 | 552 | std::vector<Map_to_output>& map_sections(this->map_to_output()); |
61ba1cf9 | 553 | map_sections.resize(shnum); |
a2fb1b05 | 554 | |
35cdfc9a ILT |
555 | // Whether we've seen a .note.GNU-stack section. |
556 | bool seen_gnu_stack = false; | |
557 | // The flags of a .note.GNU-stack section. | |
558 | uint64_t gnu_stack_flags = 0; | |
559 | ||
a2fb1b05 ILT |
560 | // Keep track of which sections to omit. |
561 | std::vector<bool> omit(shnum, false); | |
562 | ||
730cdc88 ILT |
563 | // Keep track of .eh_frame sections. |
564 | std::vector<unsigned int> eh_frame_sections; | |
565 | ||
f6ce93d6 | 566 | // Skip the first, dummy, section. |
730cdc88 | 567 | pshdrs = sd->section_headers->data() + This::shdr_size; |
f6ce93d6 | 568 | for (unsigned int i = 1; i < shnum; ++i, pshdrs += This::shdr_size) |
a2fb1b05 | 569 | { |
75f65a3e | 570 | typename This::Shdr shdr(pshdrs); |
a2fb1b05 | 571 | |
12e14209 | 572 | if (shdr.get_sh_name() >= sd->section_names_size) |
a2fb1b05 | 573 | { |
75f2446e ILT |
574 | this->error(_("bad section name offset for section %u: %lu"), |
575 | i, static_cast<unsigned long>(shdr.get_sh_name())); | |
576 | return; | |
a2fb1b05 ILT |
577 | } |
578 | ||
579 | const char* name = pnames + shdr.get_sh_name(); | |
580 | ||
dbe717ef | 581 | if (this->handle_gnu_warning_section(name, i, symtab)) |
f6ce93d6 | 582 | { |
7e1edb90 | 583 | if (!parameters->output_is_object()) |
f6ce93d6 ILT |
584 | omit[i] = true; |
585 | } | |
586 | ||
35cdfc9a ILT |
587 | // The .note.GNU-stack section is special. It gives the |
588 | // protection flags that this object file requires for the stack | |
589 | // in memory. | |
590 | if (strcmp(name, ".note.GNU-stack") == 0) | |
591 | { | |
592 | seen_gnu_stack = true; | |
593 | gnu_stack_flags |= shdr.get_sh_flags(); | |
594 | omit[i] = true; | |
595 | } | |
596 | ||
a2fb1b05 ILT |
597 | bool discard = omit[i]; |
598 | if (!discard) | |
599 | { | |
600 | if (shdr.get_sh_type() == elfcpp::SHT_GROUP) | |
601 | { | |
602 | if (!this->include_section_group(layout, i, shdr, &omit)) | |
603 | discard = true; | |
604 | } | |
cba134d6 ILT |
605 | else if ((shdr.get_sh_flags() & elfcpp::SHF_GROUP) == 0 |
606 | && Layout::is_linkonce(name)) | |
a2fb1b05 ILT |
607 | { |
608 | if (!this->include_linkonce_section(layout, name, shdr)) | |
609 | discard = true; | |
610 | } | |
611 | } | |
612 | ||
613 | if (discard) | |
614 | { | |
615 | // Do not include this section in the link. | |
616 | map_sections[i].output_section = NULL; | |
617 | continue; | |
618 | } | |
619 | ||
730cdc88 ILT |
620 | // The .eh_frame section is special. It holds exception frame |
621 | // information that we need to read in order to generate the | |
622 | // exception frame header. We process these after all the other | |
623 | // sections so that the exception frame reader can reliably | |
624 | // determine which sections are being discarded, and discard the | |
625 | // corresponding information. | |
626 | if (!parameters->output_is_object() | |
627 | && strcmp(name, ".eh_frame") == 0 | |
628 | && this->check_eh_frame_flags(&shdr)) | |
629 | { | |
630 | eh_frame_sections.push_back(i); | |
631 | continue; | |
632 | } | |
633 | ||
a2fb1b05 | 634 | off_t offset; |
730cdc88 ILT |
635 | Output_section* os = layout->layout(this, i, name, shdr, |
636 | reloc_shndx[i], reloc_type[i], | |
637 | &offset); | |
a2fb1b05 ILT |
638 | |
639 | map_sections[i].output_section = os; | |
640 | map_sections[i].offset = offset; | |
730cdc88 ILT |
641 | |
642 | // If this section requires special handling, and if there are | |
643 | // relocs that apply to it, then we must do the special handling | |
644 | // before we apply the relocs. | |
645 | if (offset == -1 && reloc_shndx[i] != 0) | |
646 | this->set_relocs_must_follow_section_writes(); | |
12e14209 ILT |
647 | } |
648 | ||
35cdfc9a ILT |
649 | layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags); |
650 | ||
730cdc88 ILT |
651 | // Handle the .eh_frame sections at the end. |
652 | for (std::vector<unsigned int>::const_iterator p = eh_frame_sections.begin(); | |
653 | p != eh_frame_sections.end(); | |
654 | ++p) | |
655 | { | |
656 | gold_assert(this->has_eh_frame_); | |
657 | gold_assert(sd->external_symbols_offset != 0); | |
658 | ||
659 | unsigned int i = *p; | |
660 | const unsigned char *pshdr; | |
661 | pshdr = sd->section_headers->data() + i * This::shdr_size; | |
662 | typename This::Shdr shdr(pshdr); | |
663 | ||
664 | off_t offset; | |
665 | Output_section* os = layout->layout_eh_frame(this, | |
666 | sd->symbols->data(), | |
667 | sd->symbols_size, | |
668 | sd->symbol_names->data(), | |
669 | sd->symbol_names_size, | |
670 | i, shdr, | |
671 | reloc_shndx[i], | |
672 | reloc_type[i], | |
673 | &offset); | |
674 | map_sections[i].output_section = os; | |
675 | map_sections[i].offset = offset; | |
676 | ||
677 | // If this section requires special handling, and if there are | |
678 | // relocs that apply to it, then we must do the special handling | |
679 | // before we apply the relocs. | |
680 | if (offset == -1 && reloc_shndx[i] != 0) | |
681 | this->set_relocs_must_follow_section_writes(); | |
682 | } | |
683 | ||
12e14209 ILT |
684 | delete sd->section_headers; |
685 | sd->section_headers = NULL; | |
686 | delete sd->section_names; | |
687 | sd->section_names = NULL; | |
688 | } | |
689 | ||
690 | // Add the symbols to the symbol table. | |
691 | ||
692 | template<int size, bool big_endian> | |
693 | void | |
f6ce93d6 | 694 | Sized_relobj<size, big_endian>::do_add_symbols(Symbol_table* symtab, |
12e14209 ILT |
695 | Read_symbols_data* sd) |
696 | { | |
697 | if (sd->symbols == NULL) | |
698 | { | |
a3ad94ed | 699 | gold_assert(sd->symbol_names == NULL); |
12e14209 ILT |
700 | return; |
701 | } | |
a2fb1b05 | 702 | |
12e14209 | 703 | const int sym_size = This::sym_size; |
730cdc88 ILT |
704 | size_t symcount = ((sd->symbols_size - sd->external_symbols_offset) |
705 | / sym_size); | |
706 | if (static_cast<off_t>(symcount * sym_size) | |
707 | != sd->symbols_size - sd->external_symbols_offset) | |
12e14209 | 708 | { |
75f2446e ILT |
709 | this->error(_("size of symbols is not multiple of symbol size")); |
710 | return; | |
a2fb1b05 | 711 | } |
12e14209 | 712 | |
730cdc88 | 713 | this->symbols_.resize(symcount); |
12e14209 | 714 | |
12e14209 ILT |
715 | const char* sym_names = |
716 | reinterpret_cast<const char*>(sd->symbol_names->data()); | |
730cdc88 ILT |
717 | symtab->add_from_relobj(this, |
718 | sd->symbols->data() + sd->external_symbols_offset, | |
719 | symcount, sym_names, sd->symbol_names_size, | |
720 | &this->symbols_); | |
12e14209 ILT |
721 | |
722 | delete sd->symbols; | |
723 | sd->symbols = NULL; | |
724 | delete sd->symbol_names; | |
725 | sd->symbol_names = NULL; | |
bae7f79e ILT |
726 | } |
727 | ||
7bf1f802 ILT |
728 | // Finalize the local symbols. Here we add their names to *POOL and |
729 | // *DYNPOOL, and we add their values to THIS->LOCAL_VALUES_. | |
b8e6aad9 ILT |
730 | // This function is always called from the main thread. The actual |
731 | // output of the local symbols will occur in a separate task. | |
75f65a3e ILT |
732 | |
733 | template<int size, bool big_endian> | |
7bf1f802 ILT |
734 | void |
735 | Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool, | |
736 | Stringpool* dynpool) | |
75f65a3e | 737 | { |
a3ad94ed | 738 | gold_assert(this->symtab_shndx_ != -1U); |
645f8123 | 739 | if (this->symtab_shndx_ == 0) |
61ba1cf9 ILT |
740 | { |
741 | // This object has no symbols. Weird but legal. | |
7bf1f802 | 742 | return; |
61ba1cf9 ILT |
743 | } |
744 | ||
75f65a3e | 745 | // Read the symbol table section header. |
645f8123 ILT |
746 | const unsigned int symtab_shndx = this->symtab_shndx_; |
747 | typename This::Shdr symtabshdr(this, | |
748 | this->elf_file_.section_header(symtab_shndx)); | |
a3ad94ed | 749 | gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB); |
75f65a3e ILT |
750 | |
751 | // Read the local symbols. | |
75f65a3e | 752 | const int sym_size = This::sym_size; |
92e059d8 | 753 | const unsigned int loccount = this->local_symbol_count_; |
a3ad94ed | 754 | gold_assert(loccount == symtabshdr.get_sh_info()); |
75f65a3e ILT |
755 | off_t locsize = loccount * sym_size; |
756 | const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(), | |
9eb9fa57 | 757 | locsize, true); |
75f65a3e | 758 | |
75f65a3e | 759 | // Read the symbol names. |
645f8123 ILT |
760 | const unsigned int strtab_shndx = symtabshdr.get_sh_link(); |
761 | off_t strtab_size; | |
762 | const unsigned char* pnamesu = this->section_contents(strtab_shndx, | |
9eb9fa57 ILT |
763 | &strtab_size, |
764 | true); | |
75f65a3e ILT |
765 | const char* pnames = reinterpret_cast<const char*>(pnamesu); |
766 | ||
767 | // Loop over the local symbols. | |
768 | ||
c06b7b0b | 769 | const std::vector<Map_to_output>& mo(this->map_to_output()); |
75f65a3e | 770 | unsigned int shnum = this->shnum(); |
61ba1cf9 | 771 | unsigned int count = 0; |
7bf1f802 | 772 | unsigned int dyncount = 0; |
75f65a3e ILT |
773 | // Skip the first, dummy, symbol. |
774 | psyms += sym_size; | |
61ba1cf9 | 775 | for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size) |
75f65a3e ILT |
776 | { |
777 | elfcpp::Sym<size, big_endian> sym(psyms); | |
778 | ||
b8e6aad9 ILT |
779 | Symbol_value<size>& lv(this->local_values_[i]); |
780 | ||
75f65a3e | 781 | unsigned int shndx = sym.get_st_shndx(); |
b8e6aad9 | 782 | lv.set_input_shndx(shndx); |
75f65a3e | 783 | |
063f12a8 ILT |
784 | if (sym.get_st_type() == elfcpp::STT_SECTION) |
785 | lv.set_is_section_symbol(); | |
7bf1f802 ILT |
786 | else if (sym.get_st_type() == elfcpp::STT_TLS) |
787 | lv.set_is_tls_symbol(); | |
788 | ||
789 | // Save the input symbol value for use in do_finalize_local_symbols(). | |
790 | lv.set_input_value(sym.get_st_value()); | |
791 | ||
792 | // Decide whether this symbol should go into the output file. | |
063f12a8 | 793 | |
7bf1f802 ILT |
794 | if (shndx < shnum && mo[shndx].output_section == NULL) |
795 | { | |
796 | lv.set_no_output_symtab_entry(); | |
797 | continue; | |
798 | } | |
799 | ||
800 | if (sym.get_st_type() == elfcpp::STT_SECTION) | |
801 | { | |
802 | lv.set_no_output_symtab_entry(); | |
803 | continue; | |
804 | } | |
805 | ||
806 | if (sym.get_st_name() >= strtab_size) | |
807 | { | |
808 | this->error(_("local symbol %u section name out of range: %u >= %u"), | |
809 | i, sym.get_st_name(), | |
810 | static_cast<unsigned int>(strtab_size)); | |
811 | lv.set_no_output_symtab_entry(); | |
812 | continue; | |
813 | } | |
814 | ||
815 | // Add the symbol to the symbol table string pool. | |
816 | const char* name = pnames + sym.get_st_name(); | |
817 | pool->add(name, true, NULL); | |
818 | ++count; | |
819 | ||
820 | // If needed, add the symbol to the dynamic symbol table string pool. | |
821 | if (lv.needs_output_dynsym_entry()) | |
822 | { | |
823 | dynpool->add(name, true, NULL); | |
824 | ++dyncount; | |
825 | } | |
826 | } | |
827 | ||
828 | this->output_local_symbol_count_ = count; | |
829 | this->output_local_dynsym_count_ = dyncount; | |
830 | } | |
831 | ||
832 | // Finalize the local symbols. Here we add their values to | |
833 | // THIS->LOCAL_VALUES_ and set their output symbol table indexes. | |
834 | // This function is always called from the main thread. The actual | |
835 | // output of the local symbols will occur in a separate task. | |
836 | ||
837 | template<int size, bool big_endian> | |
838 | unsigned int | |
839 | Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index, | |
840 | off_t off) | |
841 | { | |
842 | gold_assert(off == static_cast<off_t>(align_address(off, size >> 3))); | |
843 | ||
844 | const unsigned int loccount = this->local_symbol_count_; | |
845 | this->local_symbol_offset_ = off; | |
846 | ||
847 | const std::vector<Map_to_output>& mo(this->map_to_output()); | |
848 | unsigned int shnum = this->shnum(); | |
849 | ||
850 | for (unsigned int i = 1; i < loccount; ++i) | |
851 | { | |
852 | Symbol_value<size>& lv(this->local_values_[i]); | |
853 | ||
854 | unsigned int shndx = lv.input_shndx(); | |
855 | ||
856 | // Set the output symbol value. | |
857 | ||
75f65a3e ILT |
858 | if (shndx >= elfcpp::SHN_LORESERVE) |
859 | { | |
61ba1cf9 | 860 | if (shndx == elfcpp::SHN_ABS) |
7bf1f802 | 861 | lv.set_output_value(lv.input_value()); |
61ba1cf9 | 862 | else |
75f65a3e | 863 | { |
61ba1cf9 | 864 | // FIXME: Handle SHN_XINDEX. |
75f2446e ILT |
865 | this->error(_("unknown section index %u for local symbol %u"), |
866 | shndx, i); | |
867 | lv.set_output_value(0); | |
75f65a3e | 868 | } |
75f65a3e ILT |
869 | } |
870 | else | |
871 | { | |
872 | if (shndx >= shnum) | |
873 | { | |
75f2446e ILT |
874 | this->error(_("local symbol %u section index %u out of range"), |
875 | i, shndx); | |
876 | shndx = 0; | |
75f65a3e ILT |
877 | } |
878 | ||
b8e6aad9 ILT |
879 | Output_section* os = mo[shndx].output_section; |
880 | ||
881 | if (os == NULL) | |
61ba1cf9 | 882 | { |
b8e6aad9 | 883 | lv.set_output_value(0); |
61ba1cf9 ILT |
884 | continue; |
885 | } | |
7bf1f802 ILT |
886 | else if (mo[shndx].offset == -1) |
887 | { | |
888 | // Leave the input value in place for SHF_MERGE sections. | |
889 | } | |
890 | else if (lv.is_tls_symbol()) | |
891 | lv.set_output_value(mo[shndx].output_section->tls_offset() | |
892 | + mo[shndx].offset | |
893 | + lv.input_value()); | |
b8e6aad9 ILT |
894 | else |
895 | lv.set_output_value(mo[shndx].output_section->address() | |
896 | + mo[shndx].offset | |
7bf1f802 | 897 | + lv.input_value()); |
75f65a3e ILT |
898 | } |
899 | ||
7bf1f802 ILT |
900 | if (lv.needs_output_symtab_entry()) |
901 | { | |
902 | lv.set_output_symtab_index(index); | |
903 | ++index; | |
904 | } | |
905 | } | |
906 | return index; | |
907 | } | |
645f8123 | 908 | |
7bf1f802 | 909 | // Set the output dynamic symbol table indexes for the local variables. |
c06b7b0b | 910 | |
7bf1f802 ILT |
911 | template<int size, bool big_endian> |
912 | unsigned int | |
913 | Sized_relobj<size, big_endian>::do_set_local_dynsym_indexes(unsigned int index) | |
914 | { | |
915 | const unsigned int loccount = this->local_symbol_count_; | |
916 | for (unsigned int i = 1; i < loccount; ++i) | |
917 | { | |
918 | Symbol_value<size>& lv(this->local_values_[i]); | |
919 | if (lv.needs_output_dynsym_entry()) | |
920 | { | |
921 | lv.set_output_dynsym_index(index); | |
922 | ++index; | |
923 | } | |
75f65a3e | 924 | } |
7bf1f802 ILT |
925 | return index; |
926 | } | |
75f65a3e | 927 | |
7bf1f802 ILT |
928 | // Set the offset where local dynamic symbol information will be stored. |
929 | // Returns the count of local symbols contributed to the symbol table by | |
930 | // this object. | |
61ba1cf9 | 931 | |
7bf1f802 ILT |
932 | template<int size, bool big_endian> |
933 | unsigned int | |
934 | Sized_relobj<size, big_endian>::do_set_local_dynsym_offset(off_t off) | |
935 | { | |
936 | gold_assert(off == static_cast<off_t>(align_address(off, size >> 3))); | |
937 | this->local_dynsym_offset_ = off; | |
938 | return this->output_local_dynsym_count_; | |
75f65a3e ILT |
939 | } |
940 | ||
e727fa71 ILT |
941 | // Return the value of the local symbol symndx. |
942 | template<int size, bool big_endian> | |
943 | typename elfcpp::Elf_types<size>::Elf_Addr | |
944 | Sized_relobj<size, big_endian>::local_symbol_value(unsigned int symndx) const | |
945 | { | |
946 | gold_assert(symndx < this->local_symbol_count_); | |
947 | gold_assert(symndx < this->local_values_.size()); | |
948 | const Symbol_value<size>& lv(this->local_values_[symndx]); | |
949 | return lv.value(this, 0); | |
950 | } | |
951 | ||
b8e6aad9 | 952 | // Return the value of a local symbol defined in input section SHNDX, |
063f12a8 ILT |
953 | // with value VALUE, adding addend ADDEND. IS_SECTION_SYMBOL |
954 | // indicates whether the symbol is a section symbol. This handles | |
955 | // SHF_MERGE sections. | |
b8e6aad9 ILT |
956 | template<int size, bool big_endian> |
957 | typename elfcpp::Elf_types<size>::Elf_Addr | |
958 | Sized_relobj<size, big_endian>::local_value(unsigned int shndx, | |
959 | Address value, | |
063f12a8 | 960 | bool is_section_symbol, |
b8e6aad9 ILT |
961 | Address addend) const |
962 | { | |
963 | const std::vector<Map_to_output>& mo(this->map_to_output()); | |
964 | Output_section* os = mo[shndx].output_section; | |
965 | if (os == NULL) | |
966 | return addend; | |
967 | gold_assert(mo[shndx].offset == -1); | |
063f12a8 ILT |
968 | |
969 | // Do the mapping required by the output section. If this is not a | |
970 | // section symbol, then we want to map the symbol value, and then | |
971 | // include the addend. If this is a section symbol, then we need to | |
972 | // include the addend to figure out where in the section we are, | |
973 | // before we do the mapping. This will do the right thing provided | |
974 | // the assembler is careful to only convert a relocation in a merged | |
975 | // section to a section symbol if there is a zero addend. If the | |
976 | // assembler does not do this, then in general we can't know what to | |
977 | // do, because we can't distinguish the addend for the instruction | |
978 | // format from the addend for the section offset. | |
979 | ||
980 | if (is_section_symbol) | |
981 | return os->output_address(this, shndx, value + addend); | |
982 | else | |
983 | return addend + os->output_address(this, shndx, value); | |
b8e6aad9 ILT |
984 | } |
985 | ||
61ba1cf9 ILT |
986 | // Write out the local symbols. |
987 | ||
988 | template<int size, bool big_endian> | |
989 | void | |
f6ce93d6 | 990 | Sized_relobj<size, big_endian>::write_local_symbols(Output_file* of, |
7bf1f802 ILT |
991 | const Stringpool* sympool, |
992 | const Stringpool* dynpool) | |
61ba1cf9 | 993 | { |
7bf1f802 | 994 | if (parameters->strip_all() && this->output_local_dynsym_count_ == 0) |
9e2dcb77 ILT |
995 | return; |
996 | ||
a3ad94ed | 997 | gold_assert(this->symtab_shndx_ != -1U); |
645f8123 | 998 | if (this->symtab_shndx_ == 0) |
61ba1cf9 ILT |
999 | { |
1000 | // This object has no symbols. Weird but legal. | |
1001 | return; | |
1002 | } | |
1003 | ||
1004 | // Read the symbol table section header. | |
645f8123 ILT |
1005 | const unsigned int symtab_shndx = this->symtab_shndx_; |
1006 | typename This::Shdr symtabshdr(this, | |
1007 | this->elf_file_.section_header(symtab_shndx)); | |
a3ad94ed | 1008 | gold_assert(symtabshdr.get_sh_type() == elfcpp::SHT_SYMTAB); |
92e059d8 | 1009 | const unsigned int loccount = this->local_symbol_count_; |
a3ad94ed | 1010 | gold_assert(loccount == symtabshdr.get_sh_info()); |
61ba1cf9 ILT |
1011 | |
1012 | // Read the local symbols. | |
1013 | const int sym_size = This::sym_size; | |
92e059d8 | 1014 | off_t locsize = loccount * sym_size; |
61ba1cf9 | 1015 | const unsigned char* psyms = this->get_view(symtabshdr.get_sh_offset(), |
9eb9fa57 | 1016 | locsize, false); |
61ba1cf9 | 1017 | |
61ba1cf9 | 1018 | // Read the symbol names. |
645f8123 ILT |
1019 | const unsigned int strtab_shndx = symtabshdr.get_sh_link(); |
1020 | off_t strtab_size; | |
1021 | const unsigned char* pnamesu = this->section_contents(strtab_shndx, | |
9eb9fa57 ILT |
1022 | &strtab_size, |
1023 | true); | |
61ba1cf9 ILT |
1024 | const char* pnames = reinterpret_cast<const char*>(pnamesu); |
1025 | ||
7bf1f802 ILT |
1026 | // Get views into the output file for the portions of the symbol table |
1027 | // and the dynamic symbol table that we will be writing. | |
61ba1cf9 | 1028 | off_t output_size = this->output_local_symbol_count_ * sym_size; |
f2619d6c | 1029 | unsigned char* oview = NULL; |
7bf1f802 ILT |
1030 | if (output_size > 0) |
1031 | oview = of->get_output_view(this->local_symbol_offset_, output_size); | |
1032 | ||
1033 | off_t dyn_output_size = this->output_local_dynsym_count_ * sym_size; | |
1034 | unsigned char* dyn_oview = NULL; | |
1035 | if (dyn_output_size > 0) | |
1036 | dyn_oview = of->get_output_view(this->local_dynsym_offset_, | |
1037 | dyn_output_size); | |
61ba1cf9 | 1038 | |
c06b7b0b ILT |
1039 | const std::vector<Map_to_output>& mo(this->map_to_output()); |
1040 | ||
a3ad94ed | 1041 | gold_assert(this->local_values_.size() == loccount); |
61ba1cf9 | 1042 | |
61ba1cf9 | 1043 | unsigned char* ov = oview; |
7bf1f802 | 1044 | unsigned char* dyn_ov = dyn_oview; |
c06b7b0b | 1045 | psyms += sym_size; |
92e059d8 | 1046 | for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size) |
61ba1cf9 ILT |
1047 | { |
1048 | elfcpp::Sym<size, big_endian> isym(psyms); | |
f6ce93d6 | 1049 | |
61ba1cf9 ILT |
1050 | unsigned int st_shndx = isym.get_st_shndx(); |
1051 | if (st_shndx < elfcpp::SHN_LORESERVE) | |
1052 | { | |
a3ad94ed | 1053 | gold_assert(st_shndx < mo.size()); |
61ba1cf9 ILT |
1054 | if (mo[st_shndx].output_section == NULL) |
1055 | continue; | |
ead1e424 | 1056 | st_shndx = mo[st_shndx].output_section->out_shndx(); |
61ba1cf9 ILT |
1057 | } |
1058 | ||
7bf1f802 ILT |
1059 | // Write the symbol to the output symbol table. |
1060 | if (!parameters->strip_all() | |
1061 | && this->local_values_[i].needs_output_symtab_entry()) | |
1062 | { | |
1063 | elfcpp::Sym_write<size, big_endian> osym(ov); | |
1064 | ||
1065 | gold_assert(isym.get_st_name() < strtab_size); | |
1066 | const char* name = pnames + isym.get_st_name(); | |
1067 | osym.put_st_name(sympool->get_offset(name)); | |
1068 | osym.put_st_value(this->local_values_[i].value(this, 0)); | |
1069 | osym.put_st_size(isym.get_st_size()); | |
1070 | osym.put_st_info(isym.get_st_info()); | |
1071 | osym.put_st_other(isym.get_st_other()); | |
1072 | osym.put_st_shndx(st_shndx); | |
1073 | ||
1074 | ov += sym_size; | |
1075 | } | |
1076 | ||
1077 | // Write the symbol to the output dynamic symbol table. | |
1078 | if (this->local_values_[i].needs_output_dynsym_entry()) | |
1079 | { | |
1080 | gold_assert(dyn_ov < dyn_oview + dyn_output_size); | |
1081 | elfcpp::Sym_write<size, big_endian> osym(dyn_ov); | |
1082 | ||
1083 | gold_assert(isym.get_st_name() < strtab_size); | |
1084 | const char* name = pnames + isym.get_st_name(); | |
1085 | osym.put_st_name(dynpool->get_offset(name)); | |
1086 | osym.put_st_value(this->local_values_[i].value(this, 0)); | |
1087 | osym.put_st_size(isym.get_st_size()); | |
1088 | osym.put_st_info(isym.get_st_info()); | |
1089 | osym.put_st_other(isym.get_st_other()); | |
1090 | osym.put_st_shndx(st_shndx); | |
1091 | ||
1092 | dyn_ov += sym_size; | |
1093 | } | |
1094 | } | |
f6ce93d6 | 1095 | |
61ba1cf9 | 1096 | |
7bf1f802 ILT |
1097 | if (output_size > 0) |
1098 | { | |
1099 | gold_assert(ov - oview == output_size); | |
1100 | of->write_output_view(this->local_symbol_offset_, output_size, oview); | |
61ba1cf9 ILT |
1101 | } |
1102 | ||
7bf1f802 ILT |
1103 | if (dyn_output_size > 0) |
1104 | { | |
1105 | gold_assert(dyn_ov - dyn_oview == dyn_output_size); | |
1106 | of->write_output_view(this->local_dynsym_offset_, dyn_output_size, | |
1107 | dyn_oview); | |
1108 | } | |
61ba1cf9 ILT |
1109 | } |
1110 | ||
f7e2ee48 ILT |
1111 | // Set *INFO to symbolic information about the offset OFFSET in the |
1112 | // section SHNDX. Return true if we found something, false if we | |
1113 | // found nothing. | |
1114 | ||
1115 | template<int size, bool big_endian> | |
1116 | bool | |
1117 | Sized_relobj<size, big_endian>::get_symbol_location_info( | |
1118 | unsigned int shndx, | |
1119 | off_t offset, | |
1120 | Symbol_location_info* info) | |
1121 | { | |
1122 | if (this->symtab_shndx_ == 0) | |
1123 | return false; | |
1124 | ||
1125 | off_t symbols_size; | |
1126 | const unsigned char* symbols = this->section_contents(this->symtab_shndx_, | |
1127 | &symbols_size, | |
1128 | false); | |
1129 | ||
1130 | unsigned int symbol_names_shndx = this->section_link(this->symtab_shndx_); | |
1131 | off_t names_size; | |
1132 | const unsigned char* symbol_names_u = | |
1133 | this->section_contents(symbol_names_shndx, &names_size, false); | |
1134 | const char* symbol_names = reinterpret_cast<const char*>(symbol_names_u); | |
1135 | ||
1136 | const int sym_size = This::sym_size; | |
1137 | const size_t count = symbols_size / sym_size; | |
1138 | ||
1139 | const unsigned char* p = symbols; | |
1140 | for (size_t i = 0; i < count; ++i, p += sym_size) | |
1141 | { | |
1142 | elfcpp::Sym<size, big_endian> sym(p); | |
1143 | ||
1144 | if (sym.get_st_type() == elfcpp::STT_FILE) | |
1145 | { | |
1146 | if (sym.get_st_name() >= names_size) | |
1147 | info->source_file = "(invalid)"; | |
1148 | else | |
1149 | info->source_file = symbol_names + sym.get_st_name(); | |
1150 | } | |
1151 | else if (sym.get_st_shndx() == shndx | |
1152 | && static_cast<off_t>(sym.get_st_value()) <= offset | |
1153 | && (static_cast<off_t>(sym.get_st_value() + sym.get_st_size()) | |
5c2c6c95 | 1154 | > offset)) |
f7e2ee48 ILT |
1155 | { |
1156 | if (sym.get_st_name() > names_size) | |
1157 | info->enclosing_symbol_name = "(invalid)"; | |
1158 | else | |
a2b1aa12 ILT |
1159 | { |
1160 | info->enclosing_symbol_name = symbol_names + sym.get_st_name(); | |
1161 | if (parameters->demangle()) | |
1162 | { | |
1163 | char* demangled_name = cplus_demangle( | |
1164 | info->enclosing_symbol_name.c_str(), | |
1165 | DMGL_ANSI | DMGL_PARAMS); | |
1166 | if (demangled_name != NULL) | |
1167 | { | |
1168 | info->enclosing_symbol_name.assign(demangled_name); | |
1169 | free(demangled_name); | |
1170 | } | |
1171 | } | |
1172 | } | |
f7e2ee48 ILT |
1173 | return true; |
1174 | } | |
1175 | } | |
1176 | ||
1177 | return false; | |
1178 | } | |
1179 | ||
54dc6425 ILT |
1180 | // Input_objects methods. |
1181 | ||
008db82e ILT |
1182 | // Add a regular relocatable object to the list. Return false if this |
1183 | // object should be ignored. | |
f6ce93d6 | 1184 | |
008db82e | 1185 | bool |
54dc6425 ILT |
1186 | Input_objects::add_object(Object* obj) |
1187 | { | |
019cdb1a ILT |
1188 | Target* target = obj->target(); |
1189 | if (this->target_ == NULL) | |
1190 | this->target_ = target; | |
1191 | else if (this->target_ != target) | |
1192 | { | |
1193 | gold_error(_("%s: incompatible target"), obj->name().c_str()); | |
1194 | return false; | |
1195 | } | |
1196 | ||
008db82e | 1197 | if (!obj->is_dynamic()) |
f6ce93d6 | 1198 | this->relobj_list_.push_back(static_cast<Relobj*>(obj)); |
008db82e ILT |
1199 | else |
1200 | { | |
1201 | // See if this is a duplicate SONAME. | |
1202 | Dynobj* dynobj = static_cast<Dynobj*>(obj); | |
9a2d6984 | 1203 | const char* soname = dynobj->soname(); |
008db82e ILT |
1204 | |
1205 | std::pair<Unordered_set<std::string>::iterator, bool> ins = | |
9a2d6984 | 1206 | this->sonames_.insert(soname); |
008db82e ILT |
1207 | if (!ins.second) |
1208 | { | |
1209 | // We have already seen a dynamic object with this soname. | |
1210 | return false; | |
1211 | } | |
1212 | ||
1213 | this->dynobj_list_.push_back(dynobj); | |
9a2d6984 ILT |
1214 | |
1215 | // If this is -lc, remember the directory in which we found it. | |
1216 | // We use this when issuing warnings about undefined symbols: as | |
1217 | // a heuristic, we don't warn about system libraries found in | |
1218 | // the same directory as -lc. | |
1219 | if (strncmp(soname, "libc.so", 7) == 0) | |
1220 | { | |
1221 | const char* object_name = dynobj->name().c_str(); | |
1222 | const char* base = lbasename(object_name); | |
1223 | if (base != object_name) | |
1224 | this->system_library_directory_.assign(object_name, | |
1225 | base - 1 - object_name); | |
1226 | } | |
008db82e | 1227 | } |
75f65a3e | 1228 | |
96803768 | 1229 | set_parameters_target(target); |
9025d29d | 1230 | |
008db82e | 1231 | return true; |
54dc6425 ILT |
1232 | } |
1233 | ||
9a2d6984 ILT |
1234 | // Return whether an object was found in the system library directory. |
1235 | ||
1236 | bool | |
1237 | Input_objects::found_in_system_library_directory(const Object* object) const | |
1238 | { | |
1239 | return (!this->system_library_directory_.empty() | |
1240 | && object->name().compare(0, | |
1241 | this->system_library_directory_.size(), | |
1242 | this->system_library_directory_) == 0); | |
1243 | } | |
1244 | ||
e2827e5f ILT |
1245 | // For each dynamic object, record whether we've seen all of its |
1246 | // explicit dependencies. | |
1247 | ||
1248 | void | |
1249 | Input_objects::check_dynamic_dependencies() const | |
1250 | { | |
1251 | for (Dynobj_list::const_iterator p = this->dynobj_list_.begin(); | |
1252 | p != this->dynobj_list_.end(); | |
1253 | ++p) | |
1254 | { | |
1255 | const Dynobj::Needed& needed((*p)->needed()); | |
1256 | bool found_all = true; | |
1257 | for (Dynobj::Needed::const_iterator pneeded = needed.begin(); | |
1258 | pneeded != needed.end(); | |
1259 | ++pneeded) | |
1260 | { | |
1261 | if (this->sonames_.find(*pneeded) == this->sonames_.end()) | |
1262 | { | |
1263 | found_all = false; | |
1264 | break; | |
1265 | } | |
1266 | } | |
1267 | (*p)->set_has_unknown_needed_entries(!found_all); | |
1268 | } | |
1269 | } | |
1270 | ||
92e059d8 ILT |
1271 | // Relocate_info methods. |
1272 | ||
1273 | // Return a string describing the location of a relocation. This is | |
1274 | // only used in error messages. | |
1275 | ||
1276 | template<int size, bool big_endian> | |
1277 | std::string | |
f7e2ee48 | 1278 | Relocate_info<size, big_endian>::location(size_t, off_t offset) const |
92e059d8 | 1279 | { |
5c2c6c95 ILT |
1280 | // See if we can get line-number information from debugging sections. |
1281 | std::string filename; | |
1282 | std::string file_and_lineno; // Better than filename-only, if available. | |
4c50553d | 1283 | |
a55ce7fe | 1284 | Sized_dwarf_line_info<size, big_endian> line_info(this->object); |
24badc65 ILT |
1285 | // This will be "" if we failed to parse the debug info for any reason. |
1286 | file_and_lineno = line_info.addr2line(this->data_shndx, offset); | |
4c50553d | 1287 | |
92e059d8 | 1288 | std::string ret(this->object->name()); |
f7e2ee48 ILT |
1289 | ret += ':'; |
1290 | Symbol_location_info info; | |
1291 | if (this->object->get_symbol_location_info(this->data_shndx, offset, &info)) | |
1292 | { | |
1293 | ret += " in function "; | |
1294 | ret += info.enclosing_symbol_name; | |
1295 | ret += ":"; | |
5c2c6c95 ILT |
1296 | filename = info.source_file; |
1297 | } | |
1298 | ||
1299 | if (!file_and_lineno.empty()) | |
1300 | ret += file_and_lineno; | |
1301 | else | |
1302 | { | |
1303 | if (!filename.empty()) | |
1304 | ret += filename; | |
1305 | ret += "("; | |
1306 | ret += this->object->section_name(this->data_shndx); | |
1307 | char buf[100]; | |
1308 | // Offsets into sections have to be positive. | |
1309 | snprintf(buf, sizeof(buf), "+0x%lx", static_cast<long>(offset)); | |
1310 | ret += buf; | |
1311 | ret += ")"; | |
f7e2ee48 | 1312 | } |
92e059d8 ILT |
1313 | return ret; |
1314 | } | |
1315 | ||
bae7f79e ILT |
1316 | } // End namespace gold. |
1317 | ||
1318 | namespace | |
1319 | { | |
1320 | ||
1321 | using namespace gold; | |
1322 | ||
1323 | // Read an ELF file with the header and return the appropriate | |
1324 | // instance of Object. | |
1325 | ||
1326 | template<int size, bool big_endian> | |
1327 | Object* | |
1328 | make_elf_sized_object(const std::string& name, Input_file* input_file, | |
1329 | off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr) | |
1330 | { | |
1331 | int et = ehdr.get_e_type(); | |
bae7f79e ILT |
1332 | if (et == elfcpp::ET_REL) |
1333 | { | |
f6ce93d6 ILT |
1334 | Sized_relobj<size, big_endian>* obj = |
1335 | new Sized_relobj<size, big_endian>(name, input_file, offset, ehdr); | |
bae7f79e ILT |
1336 | obj->setup(ehdr); |
1337 | return obj; | |
1338 | } | |
dbe717ef ILT |
1339 | else if (et == elfcpp::ET_DYN) |
1340 | { | |
1341 | Sized_dynobj<size, big_endian>* obj = | |
1342 | new Sized_dynobj<size, big_endian>(name, input_file, offset, ehdr); | |
1343 | obj->setup(ehdr); | |
1344 | return obj; | |
1345 | } | |
bae7f79e ILT |
1346 | else |
1347 | { | |
75f2446e ILT |
1348 | gold_error(_("%s: unsupported ELF file type %d"), |
1349 | name.c_str(), et); | |
1350 | return NULL; | |
bae7f79e ILT |
1351 | } |
1352 | } | |
1353 | ||
1354 | } // End anonymous namespace. | |
1355 | ||
1356 | namespace gold | |
1357 | { | |
1358 | ||
1359 | // Read an ELF file and return the appropriate instance of Object. | |
1360 | ||
1361 | Object* | |
1362 | make_elf_object(const std::string& name, Input_file* input_file, off_t offset, | |
1363 | const unsigned char* p, off_t bytes) | |
1364 | { | |
1365 | if (bytes < elfcpp::EI_NIDENT) | |
1366 | { | |
75f2446e ILT |
1367 | gold_error(_("%s: ELF file too short"), name.c_str()); |
1368 | return NULL; | |
bae7f79e ILT |
1369 | } |
1370 | ||
1371 | int v = p[elfcpp::EI_VERSION]; | |
1372 | if (v != elfcpp::EV_CURRENT) | |
1373 | { | |
1374 | if (v == elfcpp::EV_NONE) | |
75f2446e | 1375 | gold_error(_("%s: invalid ELF version 0"), name.c_str()); |
bae7f79e | 1376 | else |
75f2446e ILT |
1377 | gold_error(_("%s: unsupported ELF version %d"), name.c_str(), v); |
1378 | return NULL; | |
bae7f79e ILT |
1379 | } |
1380 | ||
1381 | int c = p[elfcpp::EI_CLASS]; | |
1382 | if (c == elfcpp::ELFCLASSNONE) | |
1383 | { | |
75f2446e ILT |
1384 | gold_error(_("%s: invalid ELF class 0"), name.c_str()); |
1385 | return NULL; | |
bae7f79e ILT |
1386 | } |
1387 | else if (c != elfcpp::ELFCLASS32 | |
1388 | && c != elfcpp::ELFCLASS64) | |
1389 | { | |
75f2446e ILT |
1390 | gold_error(_("%s: unsupported ELF class %d"), name.c_str(), c); |
1391 | return NULL; | |
bae7f79e ILT |
1392 | } |
1393 | ||
1394 | int d = p[elfcpp::EI_DATA]; | |
1395 | if (d == elfcpp::ELFDATANONE) | |
1396 | { | |
75f2446e ILT |
1397 | gold_error(_("%s: invalid ELF data encoding"), name.c_str()); |
1398 | return NULL; | |
bae7f79e ILT |
1399 | } |
1400 | else if (d != elfcpp::ELFDATA2LSB | |
1401 | && d != elfcpp::ELFDATA2MSB) | |
1402 | { | |
75f2446e ILT |
1403 | gold_error(_("%s: unsupported ELF data encoding %d"), name.c_str(), d); |
1404 | return NULL; | |
bae7f79e ILT |
1405 | } |
1406 | ||
1407 | bool big_endian = d == elfcpp::ELFDATA2MSB; | |
1408 | ||
1409 | if (c == elfcpp::ELFCLASS32) | |
1410 | { | |
1411 | if (bytes < elfcpp::Elf_sizes<32>::ehdr_size) | |
1412 | { | |
75f2446e ILT |
1413 | gold_error(_("%s: ELF file too short"), name.c_str()); |
1414 | return NULL; | |
bae7f79e ILT |
1415 | } |
1416 | if (big_endian) | |
1417 | { | |
193a53d9 | 1418 | #ifdef HAVE_TARGET_32_BIG |
bae7f79e ILT |
1419 | elfcpp::Ehdr<32, true> ehdr(p); |
1420 | return make_elf_sized_object<32, true>(name, input_file, | |
1421 | offset, ehdr); | |
193a53d9 | 1422 | #else |
75f2446e ILT |
1423 | gold_error(_("%s: not configured to support " |
1424 | "32-bit big-endian object"), | |
1425 | name.c_str()); | |
1426 | return NULL; | |
193a53d9 | 1427 | #endif |
bae7f79e ILT |
1428 | } |
1429 | else | |
1430 | { | |
193a53d9 | 1431 | #ifdef HAVE_TARGET_32_LITTLE |
bae7f79e ILT |
1432 | elfcpp::Ehdr<32, false> ehdr(p); |
1433 | return make_elf_sized_object<32, false>(name, input_file, | |
1434 | offset, ehdr); | |
193a53d9 | 1435 | #else |
75f2446e ILT |
1436 | gold_error(_("%s: not configured to support " |
1437 | "32-bit little-endian object"), | |
1438 | name.c_str()); | |
1439 | return NULL; | |
193a53d9 | 1440 | #endif |
bae7f79e ILT |
1441 | } |
1442 | } | |
1443 | else | |
1444 | { | |
1445 | if (bytes < elfcpp::Elf_sizes<32>::ehdr_size) | |
1446 | { | |
75f2446e ILT |
1447 | gold_error(_("%s: ELF file too short"), name.c_str()); |
1448 | return NULL; | |
bae7f79e ILT |
1449 | } |
1450 | if (big_endian) | |
1451 | { | |
193a53d9 | 1452 | #ifdef HAVE_TARGET_64_BIG |
bae7f79e ILT |
1453 | elfcpp::Ehdr<64, true> ehdr(p); |
1454 | return make_elf_sized_object<64, true>(name, input_file, | |
1455 | offset, ehdr); | |
193a53d9 | 1456 | #else |
75f2446e ILT |
1457 | gold_error(_("%s: not configured to support " |
1458 | "64-bit big-endian object"), | |
1459 | name.c_str()); | |
1460 | return NULL; | |
193a53d9 | 1461 | #endif |
bae7f79e ILT |
1462 | } |
1463 | else | |
1464 | { | |
193a53d9 | 1465 | #ifdef HAVE_TARGET_64_LITTLE |
bae7f79e ILT |
1466 | elfcpp::Ehdr<64, false> ehdr(p); |
1467 | return make_elf_sized_object<64, false>(name, input_file, | |
1468 | offset, ehdr); | |
193a53d9 | 1469 | #else |
75f2446e ILT |
1470 | gold_error(_("%s: not configured to support " |
1471 | "64-bit little-endian object"), | |
1472 | name.c_str()); | |
1473 | return NULL; | |
193a53d9 | 1474 | #endif |
bae7f79e ILT |
1475 | } |
1476 | } | |
1477 | } | |
1478 | ||
1479 | // Instantiate the templates we need. We could use the configure | |
1480 | // script to restrict this to only the ones for implemented targets. | |
1481 | ||
193a53d9 | 1482 | #ifdef HAVE_TARGET_32_LITTLE |
bae7f79e | 1483 | template |
f6ce93d6 | 1484 | class Sized_relobj<32, false>; |
193a53d9 | 1485 | #endif |
bae7f79e | 1486 | |
193a53d9 | 1487 | #ifdef HAVE_TARGET_32_BIG |
bae7f79e | 1488 | template |
f6ce93d6 | 1489 | class Sized_relobj<32, true>; |
193a53d9 | 1490 | #endif |
bae7f79e | 1491 | |
193a53d9 | 1492 | #ifdef HAVE_TARGET_64_LITTLE |
bae7f79e | 1493 | template |
f6ce93d6 | 1494 | class Sized_relobj<64, false>; |
193a53d9 | 1495 | #endif |
bae7f79e | 1496 | |
193a53d9 | 1497 | #ifdef HAVE_TARGET_64_BIG |
bae7f79e | 1498 | template |
f6ce93d6 | 1499 | class Sized_relobj<64, true>; |
193a53d9 | 1500 | #endif |
bae7f79e | 1501 | |
193a53d9 | 1502 | #ifdef HAVE_TARGET_32_LITTLE |
92e059d8 ILT |
1503 | template |
1504 | struct Relocate_info<32, false>; | |
193a53d9 | 1505 | #endif |
92e059d8 | 1506 | |
193a53d9 | 1507 | #ifdef HAVE_TARGET_32_BIG |
92e059d8 ILT |
1508 | template |
1509 | struct Relocate_info<32, true>; | |
193a53d9 | 1510 | #endif |
92e059d8 | 1511 | |
193a53d9 | 1512 | #ifdef HAVE_TARGET_64_LITTLE |
92e059d8 ILT |
1513 | template |
1514 | struct Relocate_info<64, false>; | |
193a53d9 | 1515 | #endif |
92e059d8 | 1516 | |
193a53d9 | 1517 | #ifdef HAVE_TARGET_64_BIG |
92e059d8 ILT |
1518 | template |
1519 | struct Relocate_info<64, true>; | |
193a53d9 | 1520 | #endif |
92e059d8 | 1521 | |
bae7f79e | 1522 | } // End namespace gold. |