OLD | NEW |
---|---|
1 // target.h -- target support for gold -*- C++ -*- | 1 // target.h -- target support for gold -*- C++ -*- |
2 | 2 |
3 // Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. | 3 // Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
4 // Written by Ian Lance Taylor <iant@google.com>. | 4 // Written by Ian Lance Taylor <iant@google.com>. |
5 | 5 |
6 // This file is part of gold. | 6 // This file is part of gold. |
7 | 7 |
8 // This program is free software; you can redistribute it and/or modify | 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 | 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 | 10 // the Free Software Foundation; either version 3 of the License, or |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 class Reloc_symbol_changes; | 53 class Reloc_symbol_changes; |
54 class Symbol; | 54 class Symbol; |
55 template<int size> | 55 template<int size> |
56 class Sized_symbol; | 56 class Sized_symbol; |
57 class Symbol_table; | 57 class Symbol_table; |
58 class Output_data; | 58 class Output_data; |
59 class Output_data_got_base; | 59 class Output_data_got_base; |
60 class Output_section; | 60 class Output_section; |
61 class Input_objects; | 61 class Input_objects; |
62 class Task; | 62 class Task; |
63 class Output_data_dynamic; | |
63 | 64 |
64 // The abstract class for target specific handling. | 65 // The abstract class for target specific handling. |
65 | 66 |
66 class Target | 67 class Target |
67 { | 68 { |
68 public: | 69 public: |
69 virtual ~Target() | 70 virtual ~Target() |
70 { } | 71 { } |
71 | 72 |
72 // Return the bit size that this target implements. This should | 73 // Return the bit size that this target implements. This should |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 new_output_section(Output_section* os) const | 197 new_output_section(Output_section* os) const |
197 { this->do_new_output_section(os); } | 198 { this->do_new_output_section(os); } |
198 | 199 |
199 // This is called to tell the target to complete any sections it is | 200 // This is called to tell the target to complete any sections it is |
200 // handling. After this all sections must have their final size. | 201 // handling. After this all sections must have their final size. |
201 void | 202 void |
202 finalize_sections(Layout* layout, const Input_objects* input_objects, | 203 finalize_sections(Layout* layout, const Input_objects* input_objects, |
203 Symbol_table* symtab) | 204 Symbol_table* symtab) |
204 { return this->do_finalize_sections(layout, input_objects, symtab); } | 205 { return this->do_finalize_sections(layout, input_objects, symtab); } |
205 | 206 |
207 // Fix data that are known after finalize_sections for MIPS (and possible | |
208 // some other architectures). | |
209 void fix_sections(Layout* layout, Symbol_table* symtab) | |
210 { return this->do_fix_sections(layout, symtab); } | |
211 | |
206 // Return the value to use for a global symbol which needs a special | 212 // Return the value to use for a global symbol which needs a special |
207 // value in the dynamic symbol table. This will only be called if | 213 // value in the dynamic symbol table. This will only be called if |
208 // the backend first calls symbol->set_needs_dynsym_value(). | 214 // the backend first calls symbol->set_needs_dynsym_value(). |
209 uint64_t | 215 uint64_t |
210 dynsym_value(const Symbol* sym) const | 216 dynsym_value(const Symbol* sym) const |
211 { return this->do_dynsym_value(sym); } | 217 { return this->do_dynsym_value(sym); } |
212 | 218 |
213 // Return a string to use to fill out a code section. This is | 219 // Return a string to use to fill out a code section. This is |
214 // basically one or more NOPS which must fill out the specified | 220 // basically one or more NOPS which must fill out the specified |
215 // length in bytes. | 221 // length in bytes. |
(...skipping 12 matching lines...) Expand all Loading... | |
228 void | 234 void |
229 adjust_elf_header(unsigned char* view, int len) const | 235 adjust_elf_header(unsigned char* view, int len) const |
230 { return this->do_adjust_elf_header(view, len); } | 236 { return this->do_adjust_elf_header(view, len); } |
231 | 237 |
232 // Return whether NAME is a local label name. This is used to implement the | 238 // Return whether NAME is a local label name. This is used to implement the |
233 // --discard-locals options. | 239 // --discard-locals options. |
234 bool | 240 bool |
235 is_local_label_name(const char* name) const | 241 is_local_label_name(const char* name) const |
236 { return this->do_is_local_label_name(name); } | 242 { return this->do_is_local_label_name(name); } |
237 | 243 |
244 // Get the value for target specific dynamic tags. | |
245 unsigned int | |
246 dynamic_tag_value(elfcpp::DT tag) const | |
247 { return this->do_dynamic_tag_value(tag); } | |
248 | |
238 // Get the symbol index to use for a target specific reloc. | 249 // Get the symbol index to use for a target specific reloc. |
239 unsigned int | 250 unsigned int |
240 reloc_symbol_index(void* arg, unsigned int type) const | 251 reloc_symbol_index(void* arg, unsigned int type) const |
241 { return this->do_reloc_symbol_index(arg, type); } | 252 { return this->do_reloc_symbol_index(arg, type); } |
242 | 253 |
243 // Get the addend to use for a target specific reloc. | 254 // Get the addend to use for a target specific reloc. |
244 uint64_t | 255 uint64_t |
245 reloc_addend(void* arg, unsigned int type, uint64_t addend) const | 256 reloc_addend(void* arg, unsigned int type, uint64_t addend) const |
246 { return this->do_reloc_addend(arg, type, addend); } | 257 { return this->do_reloc_addend(arg, type, addend); } |
247 | 258 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 // Set the value to store in the EI_OSABI field in the ELF header. | 405 // Set the value to store in the EI_OSABI field in the ELF header. |
395 void | 406 void |
396 set_osabi(elfcpp::ELFOSABI osabi) | 407 set_osabi(elfcpp::ELFOSABI osabi) |
397 { this->osabi_ = osabi; } | 408 { this->osabi_ = osabi; } |
398 | 409 |
399 // Define target-specific standard symbols. | 410 // Define target-specific standard symbols. |
400 void | 411 void |
401 define_standard_symbols(Symbol_table* symtab, Layout* layout) | 412 define_standard_symbols(Symbol_table* symtab, Layout* layout) |
402 { this->do_define_standard_symbols(symtab, layout); } | 413 { this->do_define_standard_symbols(symtab, layout); } |
403 | 414 |
415 // Return address of .text section. Some architecutres needs it as entry | |
robertm
2012/04/27 19:46:15
I would prefer not have this change and the stuff
Aleksandar Simeonov
2012/05/08 15:21:42
This part is added to have same behavior as ld. We
| |
416 // point if _start symbol is not defined and no -e option is used. | |
417 virtual uint64_t | |
418 text_section_address() const | |
419 { return 0; } | |
420 | |
404 protected: | 421 protected: |
405 // This struct holds the constant information for a child class. We | 422 // This struct holds the constant information for a child class. We |
406 // use a struct to avoid the overhead of virtual function calls for | 423 // use a struct to avoid the overhead of virtual function calls for |
407 // simple information. | 424 // simple information. |
408 struct Target_info | 425 struct Target_info |
409 { | 426 { |
410 // Address size (32 or 64). | 427 // Address size (32 or 64). |
411 int size; | 428 int size; |
412 // Whether the target is big endian. | 429 // Whether the target is big endian. |
413 bool is_big_endian; | 430 bool is_big_endian; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 virtual void | 477 virtual void |
461 do_new_output_section(Output_section*) const | 478 do_new_output_section(Output_section*) const |
462 { } | 479 { } |
463 | 480 |
464 // Virtual function which may be implemented by the child class. | 481 // Virtual function which may be implemented by the child class. |
465 virtual void | 482 virtual void |
466 do_finalize_sections(Layout*, const Input_objects*, Symbol_table*) | 483 do_finalize_sections(Layout*, const Input_objects*, Symbol_table*) |
467 { } | 484 { } |
468 | 485 |
469 // Virtual function which may be implemented by the child class. | 486 // Virtual function which may be implemented by the child class. |
487 virtual void | |
488 do_fix_sections(Layout*, Symbol_table*) | |
489 { } | |
490 | |
491 // Virtual function which may be implemented by the child class. | |
470 virtual uint64_t | 492 virtual uint64_t |
471 do_dynsym_value(const Symbol*) const | 493 do_dynsym_value(const Symbol*) const |
472 { gold_unreachable(); } | 494 { gold_unreachable(); } |
473 | 495 |
474 // Virtual function which must be implemented by the child class if | 496 // Virtual function which must be implemented by the child class if |
475 // needed. | 497 // needed. |
476 virtual std::string | 498 virtual std::string |
477 do_code_fill(section_size_type) const | 499 do_code_fill(section_size_type) const |
478 { gold_unreachable(); } | 500 { gold_unreachable(); } |
479 | 501 |
480 // Virtual function which may be implemented by the child class. | 502 // Virtual function which may be implemented by the child class. |
481 virtual bool | 503 virtual bool |
482 do_is_defined_by_abi(const Symbol*) const | 504 do_is_defined_by_abi(const Symbol*) const |
483 { return false; } | 505 { return false; } |
484 | 506 |
485 // Adjust the output file header before it is written out. VIEW | 507 // Adjust the output file header before it is written out. VIEW |
486 // points to the header in external form. LEN is the length, and | 508 // points to the header in external form. LEN is the length, and |
487 // will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size. | 509 // will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size. |
488 // By default, we set the EI_OSABI field if requested (in | 510 // By default, we set the EI_OSABI field if requested (in |
489 // Sized_target). | 511 // Sized_target). |
490 virtual void | 512 virtual void |
491 do_adjust_elf_header(unsigned char*, int) const = 0; | 513 do_adjust_elf_header(unsigned char*, int) const = 0; |
492 | 514 |
493 // Virtual function which may be overridden by the child class. | 515 // Virtual function which may be overridden by the child class. |
494 virtual bool | 516 virtual bool |
495 do_is_local_label_name(const char*) const; | 517 do_is_local_label_name(const char*) const; |
496 | 518 |
497 // Virtual function that must be overridden by a target which uses | 519 // Virtual function that must be overridden by a target which uses |
520 // target specific dynamic tags. | |
521 virtual unsigned int | |
522 do_dynamic_tag_value(elfcpp::DT) const | |
523 { gold_unreachable(); } | |
524 | |
525 // Virtual function that must be overridden by a target which uses | |
498 // target specific relocations. | 526 // target specific relocations. |
499 virtual unsigned int | 527 virtual unsigned int |
500 do_reloc_symbol_index(void*, unsigned int) const | 528 do_reloc_symbol_index(void*, unsigned int) const |
501 { gold_unreachable(); } | 529 { gold_unreachable(); } |
502 | 530 |
503 // Virtual function that must be overridden by a target which uses | 531 // Virtual function that must be overridden by a target which uses |
504 // target specific relocations. | 532 // target specific relocations. |
505 virtual uint64_t | 533 virtual uint64_t |
506 do_reloc_addend(void*, unsigned int, uint64_t) const | 534 do_reloc_addend(void*, unsigned int, uint64_t) const |
507 { gold_unreachable(); } | 535 { gold_unreachable(); } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 } | 943 } |
916 | 944 |
917 // Set the EI_OSABI field if requested. | 945 // Set the EI_OSABI field if requested. |
918 virtual void | 946 virtual void |
919 do_adjust_elf_header(unsigned char*, int) const; | 947 do_adjust_elf_header(unsigned char*, int) const; |
920 }; | 948 }; |
921 | 949 |
922 } // End namespace gold. | 950 } // End namespace gold. |
923 | 951 |
924 #endif // !defined(GOLD_TARGET_H) | 952 #endif // !defined(GOLD_TARGET_H) |
OLD | NEW |