After the binutils 2.41 update that landed in rawhide yesterday, the test https://github.com/llvm/llvm-project/blob/main/llvm/test/tools/gold/PowerPC/mtriple.ll in the LLVM test suite started failing with: /usr/bin/ld.gold: internal error in add_output_section_to_load, at ../../gold/output.cc:4097 This is either a bug in binutils or a previously not exposed problem in the LLVM gold plugin. Reproducible: Always
Steps to reproduce without the LLVM test suite: Create test.ll with: target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-unknown-linux-gnu" Then run: dnf install llvm llvm-as < test.ll > test.o ld.gold -plugin /usr/lib64/LLVMgold.so -m elf32ppc -plugin-opt=mtriple=powerpc-linux-gnu -shared test.o -o test Results in: ld.gold: internal error in add_output_section_to_load, at ../../gold/output.cc:4097
While I agree that ld.gold should not throw the internal error, I wonder if this is also a broken test.. What is it trying to accomplish? Is it testing if a ppc64 object can be linked into a ppc32 shared object? Is this really a valid test? By the way, this links successfully into a powerpc64-linux-gnu shared object.
I don't think that's what this is doing. We can get rid of the weird triple switching and start of with this test.ll: target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32" target triple = "powerpc-unknown-linux-gnu" and then: llvm-as < test.ll > test.o ld.gold -plugin /usr/lib64/LLVMgold.so -m elf32ppc -shared test.o -o test This is just linking a ppc32 shared object with ppc64 not being involved. It works without -shared and also if ld.gold is replaced by ld.bfd. ---- It looks like this can also be reproduced without the LLVM gold plugin. This fails in the same way: llc -filetype=obj < test.ll > test.o ld.gold -m elf32ppc -shared test.o -o test (llc just produces a normal ELF object here, rather than the LTO object that llvm-as produces.)
In fact it seems that llvm is not needed at all, as the same bug can be reproduced by: % ld.gold -m elf32ppc -shared /dev/null -o test ld.gold: error: /dev/null: file is empty ld.gold: internal error in add_output_section_to_load, at gold/output.cc:4097 I have reported this upstream as: https://sourceware.org/bugzilla/show_bug.cgi?id=30794
Fixed upstream.
... and in binutils-2.41-5.fc40
The aforementioned update has shipped, and I confirmed that the LLVM test suite passes again, so marking this as closed.