[llvm-branch-commits] [lld] d8ed639 - [lld][WebAssembly] Don't emit names for data segments that we omit

Sam Clegg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 9 21:05:01 PST 2020


Author: Sam Clegg
Date: 2020-12-09T20:59:26-08:00
New Revision: d8ed639a6a3b210d7df9a3f77d5a7546fad15f49

URL: https://github.com/llvm/llvm-project/commit/d8ed639a6a3b210d7df9a3f77d5a7546fad15f49
DIFF: https://github.com/llvm/llvm-project/commit/d8ed639a6a3b210d7df9a3f77d5a7546fad15f49.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/bss-only.s b/lld/test/wasm/bss-only.s
index 56963530a0b0..1c0500f172ca 100644
--- a/lld/test/wasm/bss-only.s
+++ b/lld/test/wasm/bss-only.s
@@ -41,3 +41,5 @@ b:
 # 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
index 95a48528db9e..8e2c7c631f95 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -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);


        


More information about the llvm-branch-commits mailing list