diff --git a/lld/test/wasm/bss-only.s b/lld/test/wasm/bss-only.s --- a/lld/test/wasm/bss-only.s +++ b/lld/test/wasm/bss-only.s @@ -41,3 +41,5 @@ # CHECK-NEXT: - Name: __data_end # CHECK-NEXT: Kind: GLOBAL # CHECK-NEXT: Index: 1 + +# CHECK-NOT: DataSegmentNames: diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -566,7 +566,7 @@ 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 @@ 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);