Created attachment 13386 [details] Fix for this bug Try to link binary whose text segment does not fit within R_PPC_REL24 results in infinite recursion in ppc_elf_inline_plt(): % cat test.c #include <stdio.h> int main(void) { printf("Hello, "); __asm volatile(".rept 16777216; nop; .endr"); /* 2^24 nop's */ printf("World!\n"); return 0; } % cc -mlongcall test.c ... freeze in ld(1) ... This is due to missing of increment of loop variable in ppc_elf_inline_plt(). See the attached patch for more details. This bug exists also for HEAD as of today, and was introduced to commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=3e04d7655bf63f4e5a0d0354c21aa3fa2ece3681 i.e., first revision where ppc_elf_inline_plt() was added. With the attached patch, the above test.c successfully links for powerpc. I've never tested for powerpc64, but it should work also. ---- % ld --version GNU ld (NetBSD Binutils nb1) 2.34 Copyright (C) 2020 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. ---- % cc --version powerpc--netbsd-gcc (NetBSD nb1 20210411) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This was fixed for ppc64 with commit 435edf0bf2312 but I failed to apply the same fix for ppc32.
Thanks for comment. I overlooked it. Please apply the same for ppc32.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=337d0bf887a3ed6b6b2123fecfec0736640edcaf commit 337d0bf887a3ed6b6b2123fecfec0736640edcaf Author: Alan Modra <amodra@gmail.com> Date: Mon May 3 13:37:00 2021 +0930 PR27755, powerpc-ld infinite loop PR 27755 * elf32-ppc.c (ppc_elf_inline_plt): Do increment rel in loop.
Alan, thank you very much for your kind response!
The binutils-2_36-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ec2451f91e2f786a819f94ab6aa8704869c48a54 commit ec2451f91e2f786a819f94ab6aa8704869c48a54 Author: Alan Modra <amodra@gmail.com> Date: Mon May 3 13:37:00 2021 +0930 PR27755, powerpc-ld infinite loop PR 27755 * elf32-ppc.c (ppc_elf_inline_plt): Do increment rel in loop. (cherry picked from commit 337d0bf887a3ed6b6b2123fecfec0736640edcaf)
The binutils-2_35-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3437a8bad8a4f217e84d6e583b59a4a7f16e5a72 commit 3437a8bad8a4f217e84d6e583b59a4a7f16e5a72 Author: Alan Modra <amodra@gmail.com> Date: Mon May 3 13:37:00 2021 +0930 PR27755, powerpc-ld infinite loop PR 27755 * elf32-ppc.c (ppc_elf_inline_plt): Do increment rel in loop. (cherry picked from commit 337d0bf887a3ed6b6b2123fecfec0736640edcaf)
The binutils-2_34-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c4e78c0868a22971680217a41fdb73516a26813d commit c4e78c0868a22971680217a41fdb73516a26813d Author: Alan Modra <amodra@gmail.com> Date: Mon May 3 13:37:00 2021 +0930 PR27755, powerpc-ld infinite loop PR 27755 * elf32-ppc.c (ppc_elf_inline_plt): Do increment rel in loop. (cherry picked from commit 337d0bf887a3ed6b6b2123fecfec0736640edcaf)
Fixed 2.34, 2.35, 2.36 and mainline.