[lld] [lld][elf] Skip BP ordering input sections with null data (PR #149265)
Pengying Xu via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 09:23:26 PDT 2025
Colibrow wrote:
@MaskRay Yes. I encountered a crash after updating lld to the latest version and enabling BP (Balanced Partitioning) ordering for the .data section in the ELF output.
```
The ld.lld command returned non-zero exit code: 139.
output:
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ld.lld --export ...
1. 0x00000001025f7432 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (ld.lld+0x101934324)
2. 0x00000001025f4998 llvm::sys::RunSignalHandlers() (ld.lld+0x101932768)
3. 0x00000001025f4998 SignalHandler(int) (ld.lld+0x101932768)
4. 0x0000000193ecfe04 (/usr/lib/system/libsystem_platform.dylib+0x10842e04)
5. 0x0000000101ac1f1c llvm::SmallVectorBase::unsigned int, 12u>::base::grow_pod(void*, unsigned long, unsigned long) (ld.lld+0x100b6271c)
6. 0x0000000101e56f14 lld::elf::runBalancedPartitioning(lld::elf::PartitioningParams const&) (ld.lld+0x100eccc14)
7. 0x0000000101e58204 lld::elf::Ctx::Ctx() (ld.lld+0x100ecde14)
8. 0x0000000101e5d268 lld::elf::LinkerDriver::LinkerDriver() (ld.lld+0x100ed2c78)
9. 0x0000000101e5eb74 void lld::elf::writeResult<llvm::object::ELFType<llvm::endianness::little, true>>(lld::elf::Ctx&) (ld.lld+0x100ed4644)
10. 0x0000000101e5ed3c lld::elf::LinkerDriver::link(llvm::ArrayRef<char const*>) (ld.lld+0x100ed47f4)
11. 0x0000000101e5ef54 lld::elf::Link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, bool, bool) (ld.lld+0x100ed4a0c)
12. 0x0000000100003798 lld_main(int, char**, llvm::ToolContext const&) (ld.lld+0x100003798)
13. 0x0000000100003c98 main (ld.lld+0x100003c98)
14. 0x000000019fb0274b (/usr/lib/dyld+0x10004274b)
```
After investigation, I found that the crash occurs in [BPSectionOrderer.cpp](https://github.com/llvm/llvm-project/blob/main/lld/ELF/BPSectionOrderer.cpp#L51), where data.data() is nullptr, leading to a segmentation fault.
https://github.com/llvm/llvm-project/pull/149265
More information about the llvm-commits
mailing list