| OLD | NEW |
| 1 // sparc.cc -- sparc target support for gold. | 1 // sparc.cc -- sparc target support for gold. |
| 2 | 2 |
| 3 // Copyright 2008, 2009 Free Software Foundation, Inc. | 3 // Copyright 2008, 2009 Free Software Foundation, Inc. |
| 4 // Written by David S. Miller <davem@davemloft.net>. | 4 // Written by David S. Miller <davem@davemloft.net>. |
| 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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (this->got_ == NULL) | 1020 if (this->got_ == NULL) |
| 1021 { | 1021 { |
| 1022 gold_assert(symtab != NULL && layout != NULL); | 1022 gold_assert(symtab != NULL && layout != NULL); |
| 1023 | 1023 |
| 1024 this->got_ = new Output_data_got<size, big_endian>(); | 1024 this->got_ = new Output_data_got<size, big_endian>(); |
| 1025 | 1025 |
| 1026 Output_section* os; | 1026 Output_section* os; |
| 1027 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS, | 1027 os = layout->add_output_section_data(".got", elfcpp::SHT_PROGBITS, |
| 1028 (elfcpp::SHF_ALLOC | 1028 (elfcpp::SHF_ALLOC |
| 1029 | elfcpp::SHF_WRITE), | 1029 | elfcpp::SHF_WRITE), |
| 1030 » » » » » this->got_); | 1030 » » » » » this->got_, false); |
| 1031 os->set_is_relro(); | 1031 os->set_is_relro(); |
| 1032 | 1032 |
| 1033 // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section. | 1033 // Define _GLOBAL_OFFSET_TABLE_ at the start of the .got section. |
| 1034 symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL, | 1034 symtab->define_in_output_data("_GLOBAL_OFFSET_TABLE_", NULL, |
| 1035 this->got_, | 1035 this->got_, |
| 1036 0, 0, elfcpp::STT_OBJECT, | 1036 0, 0, elfcpp::STT_OBJECT, |
| 1037 elfcpp::STB_LOCAL, | 1037 elfcpp::STB_LOCAL, |
| 1038 elfcpp::STV_HIDDEN, 0, | 1038 elfcpp::STV_HIDDEN, 0, |
| 1039 false, false); | 1039 false, false); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 return this->got_; | 1042 return this->got_; |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 // Get the dynamic reloc section, creating it if necessary. | 1045 // Get the dynamic reloc section, creating it if necessary. |
| 1046 | 1046 |
| 1047 template<int size, bool big_endian> | 1047 template<int size, bool big_endian> |
| 1048 typename Target_sparc<size, big_endian>::Reloc_section* | 1048 typename Target_sparc<size, big_endian>::Reloc_section* |
| 1049 Target_sparc<size, big_endian>::rela_dyn_section(Layout* layout) | 1049 Target_sparc<size, big_endian>::rela_dyn_section(Layout* layout) |
| 1050 { | 1050 { |
| 1051 if (this->rela_dyn_ == NULL) | 1051 if (this->rela_dyn_ == NULL) |
| 1052 { | 1052 { |
| 1053 gold_assert(layout != NULL); | 1053 gold_assert(layout != NULL); |
| 1054 this->rela_dyn_ = new Reloc_section(parameters->options().combreloc()); | 1054 this->rela_dyn_ = new Reloc_section(parameters->options().combreloc()); |
| 1055 layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA, | 1055 layout->add_output_section_data(".rela.dyn", elfcpp::SHT_RELA, |
| 1056 » » » » elfcpp::SHF_ALLOC, this->rela_dyn_); | 1056 » » » » elfcpp::SHF_ALLOC, this->rela_dyn_, true); |
| 1057 } | 1057 } |
| 1058 return this->rela_dyn_; | 1058 return this->rela_dyn_; |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 // A class to handle the PLT data. | 1061 // A class to handle the PLT data. |
| 1062 | 1062 |
| 1063 template<int size, bool big_endian> | 1063 template<int size, bool big_endian> |
| 1064 class Output_data_plt_sparc : public Output_section_data | 1064 class Output_data_plt_sparc : public Output_section_data |
| 1065 { | 1065 { |
| 1066 public: | 1066 public: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1148 |
| 1149 // Create the PLT section. The ordinary .got section is an argument, | 1149 // Create the PLT section. The ordinary .got section is an argument, |
| 1150 // since we need to refer to the start. | 1150 // since we need to refer to the start. |
| 1151 | 1151 |
| 1152 template<int size, bool big_endian> | 1152 template<int size, bool big_endian> |
| 1153 Output_data_plt_sparc<size, big_endian>::Output_data_plt_sparc(Layout* layout) | 1153 Output_data_plt_sparc<size, big_endian>::Output_data_plt_sparc(Layout* layout) |
| 1154 : Output_section_data(size == 32 ? 4 : 8), count_(0) | 1154 : Output_section_data(size == 32 ? 4 : 8), count_(0) |
| 1155 { | 1155 { |
| 1156 this->rel_ = new Reloc_section(false); | 1156 this->rel_ = new Reloc_section(false); |
| 1157 layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA, | 1157 layout->add_output_section_data(".rela.plt", elfcpp::SHT_RELA, |
| 1158 » » » » elfcpp::SHF_ALLOC, this->rel_); | 1158 » » » » elfcpp::SHF_ALLOC, this->rel_, true); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 template<int size, bool big_endian> | 1161 template<int size, bool big_endian> |
| 1162 void | 1162 void |
| 1163 Output_data_plt_sparc<size, big_endian>::do_adjust_output_section(Output_section
* os) | 1163 Output_data_plt_sparc<size, big_endian>::do_adjust_output_section(Output_section
* os) |
| 1164 { | 1164 { |
| 1165 os->set_entsize(0); | 1165 os->set_entsize(0); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 // Add an entry to the PLT. | 1168 // Add an entry to the PLT. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 if (this->plt_ == NULL) | 1365 if (this->plt_ == NULL) |
| 1366 { | 1366 { |
| 1367 // Create the GOT sections first. | 1367 // Create the GOT sections first. |
| 1368 this->got_section(symtab, layout); | 1368 this->got_section(symtab, layout); |
| 1369 | 1369 |
| 1370 this->plt_ = new Output_data_plt_sparc<size, big_endian>(layout); | 1370 this->plt_ = new Output_data_plt_sparc<size, big_endian>(layout); |
| 1371 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS, | 1371 layout->add_output_section_data(".plt", elfcpp::SHT_PROGBITS, |
| 1372 (elfcpp::SHF_ALLOC | 1372 (elfcpp::SHF_ALLOC |
| 1373 | elfcpp::SHF_EXECINSTR | 1373 | elfcpp::SHF_EXECINSTR |
| 1374 | elfcpp::SHF_WRITE), | 1374 | elfcpp::SHF_WRITE), |
| 1375 » » » » this->plt_); | 1375 » » » » this->plt_, false); |
| 1376 | 1376 |
| 1377 // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section. | 1377 // Define _PROCEDURE_LINKAGE_TABLE_ at the start of the .plt section. |
| 1378 symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL, | 1378 symtab->define_in_output_data("_PROCEDURE_LINKAGE_TABLE_", NULL, |
| 1379 this->plt_, | 1379 this->plt_, |
| 1380 0, 0, elfcpp::STT_OBJECT, | 1380 0, 0, elfcpp::STT_OBJECT, |
| 1381 elfcpp::STB_LOCAL, | 1381 elfcpp::STB_LOCAL, |
| 1382 elfcpp::STV_HIDDEN, 0, | 1382 elfcpp::STV_HIDDEN, 0, |
| 1383 false, false); | 1383 false, false); |
| 1384 } | 1384 } |
| 1385 | 1385 |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 // Finalize the sections. | 2327 // Finalize the sections. |
| 2328 | 2328 |
| 2329 template<int size, bool big_endian> | 2329 template<int size, bool big_endian> |
| 2330 void | 2330 void |
| 2331 Target_sparc<size, big_endian>::do_finalize_sections(Layout* layout) | 2331 Target_sparc<size, big_endian>::do_finalize_sections(Layout* layout) |
| 2332 { | 2332 { |
| 2333 // Fill in some more dynamic tags. | 2333 // Fill in some more dynamic tags. |
| 2334 Output_data_dynamic* const odyn = layout->dynamic_data(); | 2334 Output_data_dynamic* const odyn = layout->dynamic_data(); |
| 2335 if (odyn != NULL) | 2335 if (odyn != NULL) |
| 2336 { | 2336 { |
| 2337 if (this->plt_ != NULL) | 2337 if (this->plt_ != NULL |
| 2338 » && this->plt_->output_section() != NULL) |
| 2338 { | 2339 { |
| 2339 const Output_data* od = this->plt_->rel_plt(); | 2340 const Output_data* od = this->plt_->rel_plt(); |
| 2340 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); | 2341 odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); |
| 2341 odyn->add_section_address(elfcpp::DT_JMPREL, od); | 2342 odyn->add_section_address(elfcpp::DT_JMPREL, od); |
| 2342 odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_RELA); | 2343 odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_RELA); |
| 2343 | 2344 |
| 2344 odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_); | 2345 odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_); |
| 2345 } | 2346 } |
| 2346 | 2347 |
| 2347 if (this->rela_dyn_ != NULL) | 2348 if (this->rela_dyn_ != NULL |
| 2349 » && this->rela_dyn_->output_section() != NULL) |
| 2348 { | 2350 { |
| 2349 const Output_data* od = this->rela_dyn_; | 2351 const Output_data* od = this->rela_dyn_; |
| 2350 odyn->add_section_address(elfcpp::DT_RELA, od); | 2352 odyn->add_section_address(elfcpp::DT_RELA, od); |
| 2351 odyn->add_section_size(elfcpp::DT_RELASZ, od); | 2353 odyn->add_section_size(elfcpp::DT_RELASZ, od); |
| 2352 odyn->add_constant(elfcpp::DT_RELAENT, | 2354 odyn->add_constant(elfcpp::DT_RELAENT, |
| 2353 elfcpp::Elf_sizes<size>::rela_size); | 2355 elfcpp::Elf_sizes<size>::rela_size); |
| 2354 } | 2356 } |
| 2355 | 2357 |
| 2356 if (!parameters->options().shared()) | 2358 if (!parameters->options().shared()) |
| 2357 { | 2359 { |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 } | 3267 } |
| 3266 | 3268 |
| 3267 Target* do_instantiate_target() | 3269 Target* do_instantiate_target() |
| 3268 { return new Target_sparc<size, big_endian>(); } | 3270 { return new Target_sparc<size, big_endian>(); } |
| 3269 }; | 3271 }; |
| 3270 | 3272 |
| 3271 Target_selector_sparc<32, true> target_selector_sparc32; | 3273 Target_selector_sparc<32, true> target_selector_sparc32; |
| 3272 Target_selector_sparc<64, true> target_selector_sparc64; | 3274 Target_selector_sparc<64, true> target_selector_sparc64; |
| 3273 | 3275 |
| 3274 } // End anonymous namespace. | 3276 } // End anonymous namespace. |
| OLD | NEW |