[lld][WebAssembly] Don't emit names for data segments that we omit

Followup to https://reviews.llvm.org/D92909

Differential Revision: https://reviews.llvm.org/D92997
This commit is contained in:
Sam Clegg 2020-12-09 20:46:37 -08:00
parent d6f5e08199
commit d8ed639a6a
2 changed files with 7 additions and 3 deletions

View File

@ -41,3 +41,5 @@ b:
# CHECK-NEXT: - Name: __data_end
# CHECK-NEXT: Kind: GLOBAL
# CHECK-NEXT: Index: 1
# CHECK-NOT: DataSegmentNames:

View File

@ -566,7 +566,7 @@ unsigned NameSection::numNamedDataSegments() const {
unsigned numNames = 0;
for (const OutputSegment *s : segments)
if (!s->name.empty())
if (!s->name.empty() && !s->isBss)
++numNames;
return numNames;
@ -636,8 +636,10 @@ void NameSection::writeBody() {
writeUleb128(sub.os, count, "name count");
for (OutputSegment *s : segments) {
writeUleb128(sub.os, s->index, "global index");
writeStr(sub.os, s->name, "segment name");
if (!s->name.empty() && !s->isBss) {
writeUleb128(sub.os, s->index, "global index");
writeStr(sub.os, s->name, "segment name");
}
}
sub.writeTo(bodyOutputStream);