This was seen building skiboot 6.2 for powerpc64-linux-gnu using binutils trunk 20190614. (gdb) run Starting program: /usr/bin/powerpc64-linux-gnu-ld -EB -m elf64ppc --no-multi-toc -N --build-id=none --whole-archive -static -nostdlib -pie -Ttext-segment=0x0 --oformat=elf64-powerpc -o skiboot.tmp.elf -T skiboot.lds skiboot.tmp.a asm/dummy_map.o Breakpoint 1, _bfd_error_handler (fmt=0x7ffff7f6b480 "BFD %s internal error, aborting at %s:%d in %s\n") at ../../bfd/bfd.c:1174 1174 ../../bfd/bfd.c: No such file or directory. (gdb) bt #0 _bfd_error_handler (fmt=0x7ffff7f6b480 "BFD %s internal error, aborting at %s:%d in %s\n") at ../../bfd/bfd.c:1174 #1 0x00007ffff7ebc6c4 in _bfd_abort (file=file@entry=0x7ffff7f7e071 "../../bfd/elf64-ppc.c", line=line@entry=15381, fn=fn@entry=0x7ffff7f81480 <__PRETTY_FUNCTION__.18116> "ppc64_elf_relocate_section") at ../../bfd/bfd.c:1440 #2 0x00007ffff7ee1e70 in ppc64_elf_relocate_section (output_bfd=output_bfd@entry=0x55555570b4c0, info=<optimized out>, input_bfd=input_bfd@entry=0x555555740d00, input_section=input_section@entry=0x555555742270, contents=<optimized out>, relocs=relocs@entry=0x555555744ca8, local_syms=<optimized out>, local_sections=<optimized out>) at ../../bfd/elf64-ppc.c:15381 #3 0x00007ffff7f133e1 in elf_link_input_bfd (flinfo=flinfo@entry=0x7fffffffe0e0, input_bfd=input_bfd@entry=0x555555740d00) at ../../bfd/elflink.c:10887 #4 0x00007ffff7f14eef in bfd_elf_final_link (abfd=<optimized out>, info=<optimized out>) at ../../bfd/elflink.c:12215 #5 0x0000555555578e0f in ldwrite () at ../../ld/ldwrite.c:581 #6 0x0000555555561514 in main (argc=<optimized out>, argv=<optimized out>) at ../../ld/ldmain.c:457
Created attachment 11848 [details] test case
This is due to a horrible linker script breaking a new GOT indirect to GOT relative optimisation (git commit 066f4018ae78). ld does a preliminary layout to see whether various optimisations can be done. In this case the preliminary layout indicates that code using a GOT indirect address can be replaced with code calculating a GOT relative address (saving a GOT entry and load from memory). The trouble is that skiboot.lds puts a bunch of dynamic sections between .got and the address in question. Those dynamic sections are not filled out for the preliminary layout, nor can they be since one of the aims of the ppc64 linker optimisation is to reduce dynamic relocations. With the dynamic sections adding over 150kb, the optimisation is no longer valid but ld has already removed the GOT entry.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bb22a41815facfaa3de621aad5d055eb8e477082 commit bb22a41815facfaa3de621aad5d055eb8e477082 Author: Alan Modra <amodra@gmail.com> Date: Sun Jun 23 12:28:39 2019 +0930 PR24704, Internal error building skiboot for powerpc64-linux-gnu While the skiboot linker script bears some culpability in this PR, it's also true that the GOT indirect to GOT relative optimisation for 16-bit offsets isn't safe. At least, it isn't safe to remove the GOT entry based on distance between the GOT pointer and symbol calculated from the preliminary layout. So this patch removes that optimisation, and reduces the range allowed for 32-bit and 34-bit offsets. PR 24704 bfd/ * elf64-ppc.c (R_PPC64_GOT16_DS): Don't set has_gotrel. (ppc64_elf_edit_toc): Don't remove R_PPC64_GOT16_DS got entries. Reduce range of offsets allowed for other GOT relocs. ld/ * testsuite/ld-powerpc/elfv2exe.d: Update. * testsuite/ld-powerpc/elfv2so.d: Update.
Fixed.