llvm / llvm/llvm-project

[lld][SystemZ] Assertion failure

Open
#224,011 2 comments 0 reactions 0 assignees View on GitHub
backend:SystemZ crash lld:ELF
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This is the assembly generated by the C test case in https://github.com/llvm/llvm-project/issues/224008:
```asm
.file "test.cpp"
.text
.globl _Z4testj # -- Begin function _Z4testj
.p2align 1
.prefalign 4, .Lfunc_end0, nop
.type _Z4testj,@function
_Z4testj: # @_Z4testj
# %bb.0: # %entry
lgrl %r1, .L__const._Z4testj.digits@GOT
llgc %r2, 0(%r2,%r1)
br %r14
.Lfunc_end0:
.size _Z4testj, .Lfunc_end0-_Z4testj
# -- End function
.type .L__const._Z4testj.digits,@object # @__const._Z4testj.digits
.section .rodata.str1.1,"aMS",@progbits,1
.L__const._Z4testj.digits:
.asciz "foobar"
.size .L__const._Z4testj.digits, 7

.ident "clang version 24.0.0git"
.section ".note.GNU-stack","",@progbits
.addrsig
```
Running it through LLD:
```
llvm-mc --triple=s390x-unknown-linux-gnu test.s -filetype=obj > test.o
ld.lld -m elf64_s390 -pie -o a.out test.o
```
Results in an assertion failure:
```
ld.lld: /home/npopov/repos/llvm-project/lld/ELF/Writer.cpp:2166: void (anonymous namespace)::Writer>::finalizeSections() [ELFT = llvm::object::ELFType]: Assertion `llvm::none_of(ctx.removedSyntheticSections, [](SyntheticSection *sec) { return sec->isNeeded(); })' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: build/bin/ld.lld -m elf64_s390 -pie -o a.out test.o
#0 0x00000000056fbbfb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build/bin/ld.lld+0x56fbbfb)
#1 0x00000000056f8971 llvm::sys::RunSignalHandlers() (build/bin/ld.lld+0x56f8971)
#2 0x00000000056fc63b SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fc034620fb0 __restore_rt (/lib64/libc.so.6+0x19fb0)
#4 0x00007fc03467bccc __pthread_kill_implementation (/lib64/libc.so.6+0x74ccc)
#5 0x00007fc034620e8e gsignal (/lib64/libc.so.6+0x19e8e)
#6 0x00007fc0346087b3 abort (/lib64/libc.so.6+0x17b3)
#7 0x00007fc034609804 _IO_peekc_locked.cold (/lib64/libc.so.6+0x2804)
#8 0x00007fc034618d45 __assert_fail (/lib64/libc.so.6+0x11d45)
#9 0x0000000005a906f6 (anonymous namespace)::Writer>::finalizeSections() Writer.cpp:0:0
#10 0x0000000005a61bd5 void lld::elf::writeResult>(lld::elf::Ctx&) (build/bin/ld.lld+0x5a61bd5)
```

Contributor guide

Open the contributing guide

Research direction

Start with lld/ELF/Writer.cpp, especially finalizeSections() near the assertion in the stack trace. Reproduce the failure by assembling test.s with llvm-mc for s390x and linking test.o with ld.lld -m elf64_s390 -pie. Done when this input no longer triggers the assertion and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.