• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisióncb4630af68d065b99c9ce9d22d27281900089774 (tree)
Tiempo2017-02-22 08:10:22
AutorAlan Modra <amodra@gmai...>
CommiterAlan Modra

Log Message

[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.

Cambiar Resumen

Diferencia incremental

--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,6 +1,14 @@
11 2017-02-22 Alan Modra <amodra@gmail.com>
22
33 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+
412 2016-12-08 Alan Modra <amodra@gmail.com>
513 * powerpc.cc (Powerpc_relobj::stub_table): Return NULL rather
614 then asserting.
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -1816,10 +1816,8 @@ Powerpc_relobj<size, big_endian>::scan_opd_relocs(
18161816 {
18171817 if (size == 64)
18181818 {
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;
18231821 const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
18241822 Address expected_off = 0;
18251823 bool regular = true;
@@ -3493,8 +3491,7 @@ class Output_data_brlt_powerpc : public Output_section_data_build
34933491 os->set_section_offsets_need_adjustment();
34943492 if (this->rel_ != NULL)
34953493 {
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;
34983495 this->rel_->reset_address_and_file_offset();
34993496 this->rel_->set_current_data_size(num_branches * reloc_size);
35003497 this->rel_->finalize_data_size();
@@ -5780,9 +5777,11 @@ Target_powerpc<size, big_endian>::Scan::local(
57805777 case elfcpp::R_POWERPC_REL14_BRTAKEN:
57815778 case elfcpp::R_POWERPC_REL14_BRNTAKEN:
57825779 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+ }
57865785 break;
57875786
57885787 case elfcpp::R_PPC64_REL64:
@@ -6043,9 +6042,9 @@ Target_powerpc<size, big_endian>::Scan::global(
60436042 bool pushed_ifunc = false;
60446043 if (is_ifunc && this->reloc_needs_plt_for_ifunc(target, object, r_type, true))
60456044 {
6045+ unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
60466046 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());
60496048 target->make_plt_entry(symtab, layout, gsym);
60506049 pushed_ifunc = true;
60516050 }
@@ -6135,9 +6134,9 @@ Target_powerpc<size, big_endian>::Scan::global(
61356134 }
61366135 if (!is_ifunc || (!pushed_ifunc && need_ifunc_plt))
61376136 {
6137+ unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
61386138 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,
61416140 reloc.get_r_addend());
61426141 target->make_plt_entry(symtab, layout, gsym);
61436142 }
@@ -6192,10 +6191,9 @@ Target_powerpc<size, big_endian>::Scan::global(
61926191 case elfcpp::R_POWERPC_REL24:
61936192 if (!is_ifunc)
61946193 {
6194+ unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
61956195 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());
61996197 if (gsym->needs_plt_entry()
62006198 || (!gsym->final_value_is_known()
62016199 && (gsym->is_undefined()
@@ -6233,9 +6231,11 @@ Target_powerpc<size, big_endian>::Scan::global(
62336231 case elfcpp::R_POWERPC_REL14_BRTAKEN:
62346232 case elfcpp::R_POWERPC_REL14_BRNTAKEN:
62356233 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+ }
62396239 break;
62406240
62416241 case elfcpp::R_POWERPC_REL16:
@@ -7036,7 +7036,8 @@ Target_powerpc<size, big_endian>::symval_for_branch(
70367036 // descriptor, use the function descriptor code entry address
70377037 Powerpc_relobj<size, big_endian>* symobj = object;
70387038 if (gsym != NULL
7039- && gsym->source() != Symbol::FROM_OBJECT)
7039+ && (gsym->source() != Symbol::FROM_OBJECT
7040+ || gsym->object()->is_dynamic()))
70407041 return true;
70417042 if (gsym != NULL)
70427043 symobj = static_cast<Powerpc_relobj<size, big_endian>*>(gsym->object());
@@ -7107,8 +7108,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
71077108
71087109 typedef Powerpc_relocate_functions<size, big_endian> Reloc;
71097110 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;
71127112 // Offset from start of insn to d-field reloc.
71137113 const int d_offset = big_endian ? 2 : 0;
71147114
@@ -7182,7 +7182,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
71827182 }
71837183 else
71847184 {
7185- unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
71867185 gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_STANDARD));
71877186 value = object->local_got_offset(r_sym, GOT_TYPE_STANDARD);
71887187 }
@@ -7284,7 +7283,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
72847283 }
72857284 else
72867285 {
7287- unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
72887286 gold_assert(object->local_has_got_offset(r_sym, got_type));
72897287 value = object->local_got_offset(r_sym, got_type);
72907288 }
@@ -7384,7 +7382,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
73847382 }
73857383 else
73867384 {
7387- unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
73887385 gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_DTPREL));
73897386 value = object->local_got_offset(r_sym, GOT_TYPE_DTPREL);
73907387 }
@@ -7407,7 +7404,6 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
74077404 }
74087405 else
74097406 {
7410- unsigned int r_sym = elfcpp::elf_r_sym<size>(rela.get_r_info());
74117407 gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_TPREL));
74127408 value = object->local_got_offset(r_sym, GOT_TYPE_TPREL);
74137409 }
@@ -7803,8 +7799,7 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
78037799 && gsym != NULL
78047800 && strcmp(gsym->name(), ".TOC.") == 0)
78057801 {
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;
78087803 Reltype prev_rela(preloc - reloc_size);
78097804 if ((prev_rela.get_r_info()
78107805 == elfcpp::elf_r_info<size>(r_sym,
@@ -8277,10 +8272,8 @@ template<int size, bool big_endian>
82778272 class Powerpc_scan_relocatable_reloc
82788273 {
82798274 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;
82848277 static const int sh_type = elfcpp::SHT_RELA;
82858278
82868279 // Return the symbol referred to by the relocation.
@@ -8420,12 +8413,9 @@ Target_powerpc<size, big_endian>::relocate_relocs(
84208413 {
84218414 gold_assert(sh_type == elfcpp::SHT_RELA);
84228415
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;
84298419 // Offset from start of insn to d-field reloc.
84308420 const int d_offset = big_endian ? 2 : 0;
84318421