From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id EFBB73858017; Fri, 25 Aug 2023 02:04:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFBB73858017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] PR30794, PowerPC gold: internal error in add_output_section_to_load X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: cbbeee21a280a288e5efc52061e2b001e5626ce3 X-Git-Newrev: d537f77ef3b18a5fbfd598643aaad957652e9608 Message-Id: <20230825020404.EFBB73858017@sourceware.org> Date: Fri, 25 Aug 2023 02:04:04 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2023 02:04:05 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd537f77ef3b1= 8a5fbfd598643aaad957652e9608 commit d537f77ef3b18a5fbfd598643aaad957652e9608 Author: Alan Modra Date: Fri Aug 25 09:12:18 2023 +0930 PR30794, PowerPC gold: internal error in add_output_section_to_load =20 Caused by commit 5a97377e5513, specifically this code added to Target_powerpc::do_relax + if (parameters->options().output_is_position_independent()) + this->rela_dyn_size_ + =3D this->rela_dyn_section(layout)->current_data_size(); =20 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. =20 PR 30794 * powerpc.cc (Target_powerpc::do_relax): Only set rela_dyn_size_ for size =3D=3D 64, and assert that rela_dyn_ already exists. Tidy code setting plt_thread_safe, which also only needs to be set when size =3D=3D 64 for ELFv1. Diff: --- gold/powerpc.cc | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/gold/powerpc.cc b/gold/powerpc.cc index e66d9cbb900..a4fecaae55a 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -3714,12 +3714,7 @@ Target_powerpc::do_relax(int pass, unsigned int prev_brlt_size =3D 0; if (pass =3D=3D 1) { - bool thread_safe - =3D this->abiversion() < 2 && parameters->options().plt_thread_safe(); - if (size =3D=3D 64 - && this->abiversion() < 2 - && !thread_safe - && !parameters->options().user_set_plt_thread_safe()) + if (size =3D=3D 64 && this->abiversion() < 2) { static const char* const thread_starter[] =3D { @@ -3747,29 +3742,37 @@ Target_powerpc::do_relax(int pass, /* libgo */ "__go_go", }; + bool thread_safe =3D parameters->options().plt_thread_safe(); =20 - if (parameters->options().shared()) - thread_safe =3D true; - else + if (!thread_safe + && !parameters->options().user_set_plt_thread_safe()) { - for (unsigned int i =3D 0; - i < sizeof(thread_starter) / sizeof(thread_starter[0]); - i++) + if (parameters->options().shared()) + thread_safe =3D true; + else { - Symbol* sym =3D symtab->lookup(thread_starter[i], NULL); - thread_safe =3D (sym !=3D NULL - && sym->in_reg() - && sym->in_real_elf()); - if (thread_safe) - break; + for (unsigned int i =3D 0; + i < sizeof(thread_starter) / sizeof(thread_starter[0]); + i++) + { + Symbol* sym =3D symtab->lookup(thread_starter[i], NULL); + thread_safe =3D (sym !=3D NULL + && sym->in_reg() + && sym->in_real_elf()); + if (thread_safe) + break; + } } } + this->plt_thread_safe_ =3D thread_safe; } - this->plt_thread_safe_ =3D thread_safe; =20 - if (parameters->options().output_is_position_independent()) - this->rela_dyn_size_ - =3D this->rela_dyn_section(layout)->current_data_size(); + if (size =3D=3D 64 + && parameters->options().output_is_position_independent()) + { + gold_assert (this->rela_dyn_); + this->rela_dyn_size_ =3D this->rela_dyn_->current_data_size(); + } =20 this->stub_group_size_ =3D parameters->options().stub_group_size(); bool no_size_errors =3D true;