Skip to content

Commit efef83e

Browse files
authored
[lld][InstrProf] Skip BP ordering input sections with null data (llvm#137906)
In MachO, `.bss` `isec`s have a length, but point to null. This causes Balanced Partitioning to crash on these inputs. This code was in the original implementation, but was removed in https://github.com/llvm/llvm-project/pull/124482/files#diff-b2aac8833d29d297ae5ada1b36eb4e88f53691fd91df954c24e0c264f3131d4aL27
1 parent 36850a0 commit efef83e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lld/MachO/BPSectionOrderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ DenseMap<const InputSection *, int> lld::macho::runBalancedPartitioning(
115115
for (auto *sec : file->sections) {
116116
for (auto &subsec : sec->subsections) {
117117
auto *isec = subsec.isec;
118-
if (!isec || isec->data.empty())
118+
if (!isec || isec->data.empty() || !isec->data.data())
119119
continue;
120120
// ConcatInputSections are entirely live or dead, so the offset is
121121
// irrelevant.

lld/test/MachO/bp-section-orderer.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ r3:
106106
r4:
107107
.quad s2
108108

109+
.bss
110+
bss0:
111+
.zero 10
112+
109113
.subsections_via_symbols
110114

111115
#--- a.proftext

0 commit comments

Comments
 (0)