GNU Binutils with patches for OS216
Revisión | cb4630af68d065b99c9ce9d22d27281900089774 (tree) |
---|---|
Tiempo | 2017-02-22 08:10:22 |
Autor | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
[GOLD] powerpc.cc tidies
Plus some paranoia in symval_for_branch. We shouldn't get there with
dynamic symbols, but if we ever did the static_cast to Powerpc_relobj
would be wrong.
* powerpc.cc: Use shorter equivalent elfcpp typedef for
Reltype and reloc_size throughout.
(Target_powerpc::symval_for_branch): Exclude dynamic symbols.
(Target_powerpc::Scan::local): Use local var r_sym.
(Target_powerpc::Scan::global: Likewise.
(Target_powerpc::Relocate::relocate): Delete shadowing r_sym.
@@ -1,6 +1,14 @@ | ||
1 | 1 | 2017-02-22 Alan Modra <amodra@gmail.com> |
2 | 2 | |
3 | 3 | Apply from master |
4 | + 2017-01-07 Alan Modra <amodra@gmail.com> | |
5 | + * powerpc.cc: Use shorter equivalent elfcpp typedef for | |
6 | + Reltype and reloc_size throughout. | |
7 | + (Target_powerpc::symval_for_branch): Exclude dynamic symbols. | |
8 | + (Target_powerpc::Scan::local): Use local var r_sym. | |
9 | + (Target_powerpc::Scan::global: Likewise. | |
10 | + (Target_powerpc::Relocate::relocate): Delete shadowing r_sym. | |
11 | + | |
4 | 12 | 2016-12-08 Alan Modra <amodra@gmail.com> |
5 | 13 | * powerpc.cc (Powerpc_relobj::stub_table): Return NULL rather |
6 | 14 | then asserting. |
@@ -1816,10 +1816,8 @@ Powerpc_relobj<size, big_endian>::scan_opd_relocs( | ||
1816 | 1816 | { |
1817 | 1817 | if (size == 64) |
1818 | 1818 | { |
1819 | - typedef typename Reloc_types<elfcpp::SHT_RELA, size, big_endian>::Reloc | |
1820 | - Reltype; | |
1821 | - const int reloc_size | |
1822 | - = Reloc_types<elfcpp::SHT_RELA, size, big_endian>::reloc_size; | |
1819 | + typedef typename elfcpp::Rela<size, big_endian> Reltype; | |
1820 | + const int reloc_size = elfcpp::Elf_sizes<size>::rela_size; | |
1823 | 1821 | const int sym_size = elfcpp::Elf_sizes<size>::sym_size; |
1824 | 1822 | Address expected_off = 0; |
1825 | 1823 | bool regular = true; |
@@ -3493,8 +3491,7 @@ class Output_data_brlt_powerpc : public Output_section_data_build | ||
3493 | 3491 | os->set_section_offsets_need_adjustment(); |
3494 | 3492 | if (this->rel_ != NULL) |
3495 | 3493 | { |
3496 | - unsigned int reloc_size | |
3497 | - = Reloc_types<elfcpp::SHT_RELA, size, big_endian>::reloc_size; | |
3494 | + const unsigned int reloc_size = elfcpp::Elf_sizes<size>::rela_size; | |
3498 | 3495 | this->rel_->reset_address_and_file_offset(); |
3499 | 3496 | this->rel_->set_current_data_size(num_branches * reloc_size); |
3500 | 3497 | this->rel_->finalize_data_size(); |
@@ -5780,9 +5777,11 @@ Target_powerpc<size, big_endian>::Scan::local( | ||
5780 | 5777 | case elfcpp::R_POWERPC_REL14_BRTAKEN: |
5781 | 5778 | case elfcpp::R_POWERPC_REL14_BRNTAKEN: |
5782 | 5779 | if (!is_ifunc) |
5783 | - target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), | |
5784 | - r_type, elfcpp::elf_r_sym<size>(reloc.get_r_info()), | |
5785 | - reloc.get_r_addend()); | |
5780 | + { | |
5781 | + unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); | |
5782 | + target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), | |
5783 | + r_type, r_sym, reloc.get_r_addend()); | |
5784 | + } | |
5786 | 5785 | break; |
5787 | 5786 | |
5788 | 5787 | case elfcpp::R_PPC64_REL64: |
@@ -6043,9 +6042,9 @@ Target_powerpc<size, big_endian>::Scan::global( | ||
6043 | 6042 | bool pushed_ifunc = false; |
6044 | 6043 | if (is_ifunc && this->reloc_needs_plt_for_ifunc(target, object, r_type, true)) |
6045 | 6044 | { |
6045 | + unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); | |
6046 | 6046 | target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), |
6047 | - r_type, elfcpp::elf_r_sym<size>(reloc.get_r_info()), | |
6048 | - reloc.get_r_addend()); | |
6047 | + r_type, r_sym, reloc.get_r_addend()); | |
6049 | 6048 | target->make_plt_entry(symtab, layout, gsym); |
6050 | 6049 | pushed_ifunc = true; |
6051 | 6050 | } |
@@ -6135,9 +6134,9 @@ Target_powerpc<size, big_endian>::Scan::global( | ||
6135 | 6134 | } |
6136 | 6135 | if (!is_ifunc || (!pushed_ifunc && need_ifunc_plt)) |
6137 | 6136 | { |
6137 | + unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); | |
6138 | 6138 | target->push_branch(ppc_object, data_shndx, |
6139 | - reloc.get_r_offset(), r_type, | |
6140 | - elfcpp::elf_r_sym<size>(reloc.get_r_info()), | |
6139 | + reloc.get_r_offset(), r_type, r_sym, | |
6141 | 6140 | reloc.get_r_addend()); |
6142 | 6141 | target->make_plt_entry(symtab, layout, gsym); |
6143 | 6142 | } |
@@ -6192,10 +6191,9 @@ Target_powerpc<size, big_endian>::Scan::global( | ||
6192 | 6191 | case elfcpp::R_POWERPC_REL24: |
6193 | 6192 | if (!is_ifunc) |
6194 | 6193 | { |
6194 | + unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); | |
6195 | 6195 | target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), |
6196 | - r_type, | |
6197 | - elfcpp::elf_r_sym<size>(reloc.get_r_info()), | |
6198 | - reloc.get_r_addend()); | |
6196 | + r_type, r_sym, reloc.get_r_addend()); | |
6199 | 6197 | if (gsym->needs_plt_entry() |
6200 | 6198 | || (!gsym->final_value_is_known() |
6201 | 6199 | && (gsym->is_undefined() |
@@ -6233,9 +6231,11 @@ Target_powerpc<size, big_endian>::Scan::global( | ||
6233 | 6231 | case elfcpp::R_POWERPC_REL14_BRTAKEN: |
6234 | 6232 | case elfcpp::R_POWERPC_REL14_BRNTAKEN: |
6235 | 6233 | if (!is_ifunc) |
6236 | - target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), | |
6237 | - r_type, elfcpp::elf_r_sym<size>(reloc.get_r_info()), | |
6238 | - reloc.get_r_addend()); | |
6234 | + { | |
6235 | + unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info()); | |
6236 | + target->push_branch(ppc_object, data_shndx, reloc.get_r_offset(), | |
6237 | + r_type, r_sym, reloc.get_r_addend()); | |
6238 | + } | |
6239 | 6239 | break; |
6240 | 6240 | |
6241 | 6241 | case elfcpp::R_POWERPC_REL16: |
@@ -7036,7 +7036,8 @@ Target_powerpc<size, big_endian>::symval_for_branch( | ||
7036 | 7036 | // descriptor, use the function descriptor code entry address |
7037 | 7037 | Powerpc_relobj<size, big_endian>* symobj = object; |
7038 | 7038 | if (gsym != NULL |
7039 | - && gsym->source() != Symbol::FROM_OBJECT) | |
7039 | + && (gsym->source() != Symbol::FROM_OBJECT | |
7040 | + || gsym->object()->is_dynamic())) | |
7040 | 7041 | return true; |
7041 | 7042 | if (gsym != NULL) |
7042 | 7043 | symobj = static_cast<Powerpc_relobj<size, big_endian>*>(gsym->object()); |
@@ -7107,8 +7108,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7107 | 7108 | |
7108 | 7109 | typedef Powerpc_relocate_functions<size, big_endian> Reloc; |
7109 | 7110 | typedef typename elfcpp::Swap<32, big_endian>::Valtype Insn; |
7110 | - typedef typename Reloc_types<elfcpp::SHT_RELA, | |
7111 | - size, big_endian>::Reloc Reltype; | |
7111 | + typedef typename elfcpp::Rela<size, big_endian> Reltype; | |
7112 | 7112 | // Offset from start of insn to d-field reloc. |
7113 | 7113 | const int d_offset = big_endian ? 2 : 0; |
7114 | 7114 |
@@ -7182,7 +7182,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7182 | 7182 | } |
7183 | 7183 | else |
7184 | 7184 | { |
7185 | - unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); | |
7186 | 7185 | gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_STANDARD)); |
7187 | 7186 | value = object->local_got_offset(r_sym, GOT_TYPE_STANDARD); |
7188 | 7187 | } |
@@ -7284,7 +7283,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7284 | 7283 | } |
7285 | 7284 | else |
7286 | 7285 | { |
7287 | - unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); | |
7288 | 7286 | gold_assert(object->local_has_got_offset(r_sym, got_type)); |
7289 | 7287 | value = object->local_got_offset(r_sym, got_type); |
7290 | 7288 | } |
@@ -7384,7 +7382,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7384 | 7382 | } |
7385 | 7383 | else |
7386 | 7384 | { |
7387 | - unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); | |
7388 | 7385 | gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_DTPREL)); |
7389 | 7386 | value = object->local_got_offset(r_sym, GOT_TYPE_DTPREL); |
7390 | 7387 | } |
@@ -7407,7 +7404,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7407 | 7404 | } |
7408 | 7405 | else |
7409 | 7406 | { |
7410 | - unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info()); | |
7411 | 7407 | gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_TPREL)); |
7412 | 7408 | value = object->local_got_offset(r_sym, GOT_TYPE_TPREL); |
7413 | 7409 | } |
@@ -7803,8 +7799,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate( | ||
7803 | 7799 | && gsym != NULL |
7804 | 7800 | && strcmp(gsym->name(), ".TOC.") == 0) |
7805 | 7801 | { |
7806 | - const int reloc_size | |
7807 | - = Reloc_types<elfcpp::SHT_RELA, size, big_endian>::reloc_size; | |
7802 | + const int reloc_size = elfcpp::Elf_sizes<size>::rela_size; | |
7808 | 7803 | Reltype prev_rela(preloc - reloc_size); |
7809 | 7804 | if ((prev_rela.get_r_info() |
7810 | 7805 | == elfcpp::elf_r_info<size>(r_sym, |
@@ -8277,10 +8272,8 @@ template<int size, bool big_endian> | ||
8277 | 8272 | class Powerpc_scan_relocatable_reloc |
8278 | 8273 | { |
8279 | 8274 | public: |
8280 | - typedef typename Reloc_types<elfcpp::SHT_RELA, size, big_endian>::Reloc | |
8281 | - Reltype; | |
8282 | - static const int reloc_size = | |
8283 | - Reloc_types<elfcpp::SHT_RELA, size, big_endian>::reloc_size; | |
8275 | + typedef typename elfcpp::Rela<size, big_endian> Reltype; | |
8276 | + static const int reloc_size = elfcpp::Elf_sizes<size>::rela_size; | |
8284 | 8277 | static const int sh_type = elfcpp::SHT_RELA; |
8285 | 8278 | |
8286 | 8279 | // Return the symbol referred to by the relocation. |
@@ -8420,12 +8413,9 @@ Target_powerpc<size, big_endian>::relocate_relocs( | ||
8420 | 8413 | { |
8421 | 8414 | gold_assert(sh_type == elfcpp::SHT_RELA); |
8422 | 8415 | |
8423 | - typedef typename Reloc_types<elfcpp::SHT_RELA, size, big_endian>::Reloc | |
8424 | - Reltype; | |
8425 | - typedef typename Reloc_types<elfcpp::SHT_RELA, size, big_endian>::Reloc_write | |
8426 | - Reltype_write; | |
8427 | - const int reloc_size | |
8428 | - = Reloc_types<elfcpp::SHT_RELA, size, big_endian>::reloc_size; | |
8416 | + typedef typename elfcpp::Rela<size, big_endian> Reltype; | |
8417 | + typedef typename elfcpp::Rela_write<size, big_endian> Reltype_write; | |
8418 | + const int reloc_size = elfcpp::Elf_sizes<size>::rela_size; | |
8429 | 8419 | // Offset from start of insn to d-field reloc. |
8430 | 8420 | const int d_offset = big_endian ? 2 : 0; |
8431 | 8421 |