PR30794, PowerPC gold: internal error in add_output_section_to_load
authorAlan Modra <amodra@gmail.com>
Thu, 24 Aug 2023 23:42:18 +0000 (09:12 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 25 Aug 2023 01:51:47 +0000 (11:21 +0930)
commitd537f77ef3b18a5fbfd598643aaad957652e9608
tree30a33367fd373bc80e31fd590ee38de89101df05
parentcbbeee21a280a288e5efc52061e2b001e5626ce3
PR30794, PowerPC gold: internal error in add_output_section_to_load

Caused by commit 5a97377e5513, specifically this code added to
Target_powerpc::do_relax
+      if (parameters->options().output_is_position_independent())
+       this->rela_dyn_size_
+         = this->rela_dyn_section(layout)->current_data_size();

The problem here is that if .rela.dyn isn't already created then the
call to rela_dyn_section creates it, and as this comment in
Target_powerpc::do_finalize_sections says:
  // Annoyingly, we need to make these sections now whether or
  // not we need them.  If we delay until do_relax then we
  // need to mess with the relaxation machinery checkpointing.
We can't be creating sections in do_relax.

PR 30794
* powerpc.cc (Target_powerpc::do_relax): Only set rela_dyn_size_
for size == 64, and assert that rela_dyn_ already exists.
Tidy code setting plt_thread_safe, which also only needs to be
set when size == 64 for ELFv1.
gold/powerpc.cc