Closed kees closed 2 years ago
mentioned in issue llvm/llvm-bugzilla-archive#45553
mentioned in issue llvm/llvm-project#44654
Bug llvm/llvm-bugzilla-archive#45553 has been marked as a duplicate of this bug.
Committed 489a7356cca373de761ada4c06c5b43edc581b4b to release/10.x
(I was waiting for someone in charge to do this ... )
Android also cherry picked the commit (r377782d)
git cherry-pick -n 6c73246179376442705b3a545f4e1f1478777a04
is safe in release/10.x and I am in favor of the cherry-pick.
lld 10.0.0 will be broken with the Linux kernel after https://git.kernel.org/bpf/bpf-next/c/af73d78bd384aa9b8789aa6e7ddbb165f971276f (x86_64 defconfig specifically), which will be in 5.7-rc1.
Can we please have 6c73246179376442705b3a545f4e1f1478777a04 merged into LLVM 10.0.1, where I have verified that it builds, fixes the issue, and passes the test it added?
Fixed by 6c73246179376442705b3a545f4e1f1478777a04 (will be included in lld 11)
Looking
There is an assertion error in
void LinkerScript::addOrphanSections() { ... StringRef name = getOutputSectionName(s);
(https://reviews.llvm.org/D66704 disallows --strip-all + --emit-relocs)
assigned to @MaskRay
Extended Description
Combining --emit-relocs with --strip-debug on an object with debug sections will crash during orphan placement:
$ echo "a;" > test.c $ clang -g -c -o test.o test.c ... $ objdump -wh test.o
test.o: file format elf64-x86-64
Sections: Idx Name Size VMA LMA File off Algn Flags 0 .text 00000000 0000000000000000 0000000000000000 00000040 22 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .debug_str 00000091 0000000000000000 0000000000000000 00000040 20 CONTENTS, READONLY, DEBUGGING 2 .debug_abbrev 0000002c 0000000000000000 0000000000000000 000000d1 20 CONTENTS, READONLY, DEBUGGING 3 .debug_info 0000003b 0000000000000000 0000000000000000 000000fd 20 CONTENTS, RELOC, READONLY, DEBUGGING 4 .comment 0000006a 0000000000000000 0000000000000000 00000138 20 CONTENTS, READONLY 5 .note.GNU-stack 00000000 0000000000000000 0000000000000000 000001a2 20 CONTENTS, READONLY 6 .debug_line 0000002e 0000000000000000 0000000000000000 000001a2 20 CONTENTS, READONLY, DEBUGGING 7 .llvm_addrsig 00000000 0000000000000000 0000000000000000 00000320 20 CONTENTS, READONLY, EXCLUDE
$ ld.lld --emit-relocs --strip-debug -o /dev/null test.o Stack dump:
0 0x000055a6d904b68e llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/kees/src/llvm-build/x86/bin/lld+0x51168e)
1 0x000055a6d9049514 llvm::sys::RunSignalHandlers() (/home/kees/src/llvm-build/x86/bin/lld+0x50f514)
2 0x000055a6d9049658 SignalHandler(int) (/home/kees/src/llvm-build/x86/bin/lld+0x50f658)
3 0x00007fe35d416540 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x15540)
4 0x000055a6d9028122 llvm::Twine::printOneChild(llvm::raw_ostream&, llvm::Twine::Child, llvm::Twine::NodeKind) const (/home/kees/src/llvm-build/x86/bin/lld+0x4ee122)
5 0x000055a6d90282a1 llvm::Twine::toVector(llvm::SmallVectorImpl&) const (/home/kees/src/llvm-build/x86/bin/lld+0x4ee2a1)
6 0x000055a6d902834b llvm::Twine::str[abi:cxx11]() const (/home/kees/src/llvm-build/x86/bin/lld+0x4ee34b)
7 0x000055a6d9261a9f lld::elf::getOutputSectionName(lld::elf::InputSectionBase const*) (/home/kees/src/llvm-build/x86/bin/lld+0x727a9f)
8 0x000055a6d91a8a5e lld::elf::LinkerScript::addOrphanSections()::'lambda'(lld::elf::InputSectionBase)::operator()(lld::elf::InputSectionBase) const (/home/kees/src/llvm-build/x86/bin/lld+0x66ea5e)
9 0x000055a6d91a6177 lld::elf::LinkerScript::addOrphanSections() (/home/kees/src/llvm-build/x86/bin/lld+0x66c177)
10 0x000055a6d912ce0e void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::support::endianness)1, true> >(llvm::opt::InputArgList&) (/home/kees/src/llvm-build/x86/bin/lld+0x5f2e0e)
11 0x000055a6d8f7c833 lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) (/home/kees/src/llvm-build/x86/bin/lld+0x442833)
12 0x000055a6d9130dfb lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) (/home/kees/src/llvm-build/x86/bin/lld+0x5f6dfb)
13 0x000055a6d8f79ede main (/home/kees/src/llvm-build/x86/bin/lld+0x43fede)
14 0x00007fe35ce921e3 __libc_start_main /build/glibc-4WA41p/glibc-2.30/csu/../csu/libc-start.c:342:3
15 0x000055a6d900aa4e _start (/home/kees/src/llvm-build/x86/bin/lld+0x4d0a4e)
Segmentation fault (core dumped)