From 9ff8aa7d418bc508dbd429576b93e30ed9dc5891 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 31 Jan 2022 09:38:17 +1030 Subject: Re: PR28827, assertion building LLVM 9 on powerpc64le-linux-gnu In trying to find a testcase for PR28827, I managed to hit a linker error in bfd_set_section_contents with a .branch_lt input section being too large for the output .branch_lt. bfd/ PR 28827 * elf64-ppc.c (ppc64_elf_size_stubs): Set section size to maxsize past STUB_SHRINK_ITER before laying out. Remove now unnecessary conditional setting of maxsize at start of loop. ld/ * testsuite/ld-powerpc/pr28827-2.d, * testsuite/ld-powerpc/pr28827-2.lnk, * testsuite/ld-powerpc/pr28827-2.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it. --- bfd/elf64-ppc.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'bfd/elf64-ppc.c') diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index d53128debc..b4fa4aed7b 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -14093,10 +14093,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info) { asection *stub_sec = group->stub_sec; - if (htab->stub_iteration <= STUB_SHRINK_ITER - || stub_sec->rawsize < stub_sec->size) - /* Past STUB_SHRINK_ITER, rawsize is the max size seen. */ - stub_sec->rawsize = stub_sec->size; + stub_sec->rawsize = stub_sec->size; stub_sec->size = 0; stub_sec->reloc_count = 0; stub_sec->flags &= ~SEC_RELOC; @@ -14111,9 +14108,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info) htab->tga_group->stub_sec->size = 24 * 4; } - if (htab->stub_iteration <= STUB_SHRINK_ITER - || htab->brlt->rawsize < htab->brlt->size) - htab->brlt->rawsize = htab->brlt->size; + htab->brlt->rawsize = htab->brlt->size; htab->brlt->size = 0; htab->brlt->reloc_count = 0; htab->brlt->flags &= ~SEC_RELOC; @@ -14122,9 +14117,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info) if (htab->elf.srelrdyn != NULL) { - if (htab->stub_iteration <= STUB_SHRINK_ITER - || htab->elf.srelrdyn->rawsize < htab->elf.srelrdyn->size) - htab->elf.srelrdyn->rawsize = htab->elf.srelrdyn->size; + htab->elf.srelrdyn->rawsize = htab->elf.srelrdyn->size; htab->elf.srelrdyn->size = 0; } @@ -14240,6 +14233,21 @@ ppc64_elf_size_stubs (struct bfd_link_info *info) || htab->stub_iteration > 1)) break; + if (htab->stub_iteration > STUB_SHRINK_ITER) + { + for (group = htab->group; group != NULL; group = group->next) + if (group->stub_sec != NULL + && group->stub_sec->size < group->stub_sec->rawsize) + group->stub_sec->size = group->stub_sec->rawsize; + + if (htab->brlt->size < htab->brlt->rawsize) + htab->brlt->size = htab->brlt->rawsize; + + if (htab->elf.srelrdyn != NULL + && htab->elf.srelrdyn->size < htab->elf.srelrdyn->rawsize) + htab->elf.srelrdyn->size = htab->elf.srelrdyn->rawsize; + } + /* Ask the linker to do its stuff. */ (*htab->params->layout_sections_again) (); } -- cgit v1.2.3