This assertion was added as part of D70659 but did not account for .bss
input sections. I noticed that this assert was incorrectly triggering
while building FreeBSD for MIPS64. Fixed by relaxing the assert to also
account for SHT_NOBITS input sections and adjust the test
mips-jalr-non-function.s to link a file with a .bss section first.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Unit tests: pass. 61774 tests passed, 0 failed and 780 were skipped.
clang-tidy: pass.
clang-format: pass.
Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml
FTR, SHT_NOBITS sections have nullptr as .data().data() because:
template <class ELFT> static ArrayRef<uint8_t> getSectionContents(ObjFile<ELFT> &file, const typename ELFT::Shdr &hdr) { if (hdr.sh_type == SHT_NOBITS) return makeArrayRef<uint8_t>(nullptr, hdr.sh_size); return check(file.getObj().getSectionContents(&hdr)); }
lld/test/ELF/mips-jalr-non-functions.s | ||
---|---|---|
14 | # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %S/Inputs/common.s -o %t-common.o # RUN: ld.lld -shared %t-common.o %t.o -o %t.so 2>&1 | FileCheck %s -check-prefix WARNING-MESSAGE The RUN lines are the only needed change. Changes below (e.g. .comm common_sym,4,4) are unneeded. |
Remove unncessary changes.
I originally made those because I though I could avoid an additional input file, but it appears that the .bss section is only iterated over later. Depending on this order is fragile anyway so adding another file first is better.
lld/ELF/Target.cpp | ||
---|---|---|
98 | I could also add the || (isec->type & SHT_NOBITS) to this if? Is that preferable? |
Unit tests: pass. 61776 tests passed, 0 failed and 780 were skipped.
clang-tidy: pass.
clang-format: pass.
Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml
lld/ELF/Target.cpp | ||
---|---|---|
98 | Agree. || (isec->type & SHT_NOBITS) here is preferable. |
Unit tests: pass. 61807 tests passed, 0 failed and 781 were skipped.
clang-tidy: unknown.
clang-format: pass.
Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml
Looks like a good candidate. Is @hans responsible for pushing a commit to release/10.x?
I could also add the || (isec->type & SHT_NOBITS) to this if? Is that preferable?