OSDN Git Service

[lld][WebAssembly] Don't emit names for data segments that we omit
authorSam Clegg <sbc@chromium.org>
Thu, 10 Dec 2020 04:46:37 +0000 (20:46 -0800)
committerSam Clegg <sbc@chromium.org>
Thu, 10 Dec 2020 04:59:26 +0000 (20:59 -0800)
Followup to https://reviews.llvm.org/D92909

Differential Revision: https://reviews.llvm.org/D92997

lld/test/wasm/bss-only.s
lld/wasm/SyntheticSections.cpp

index 5696353..1c0500f 100644 (file)
@@ -41,3 +41,5 @@ b:
 # CHECK-NEXT:       - Name:            __data_end
 # CHECK-NEXT:         Kind:            GLOBAL
 # CHECK-NEXT:         Index:           1
+
+# CHECK-NOT: DataSegmentNames:
index 95a4852..8e2c7c6 100644 (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);