[lld] cf54424 - [lld][WebAssembly] Do not remove name section with --strip-debug

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 11:07:09 PDT 2021


Author: Derek Schuff
Date: 2021-07-26T11:06:52-07:00
New Revision: cf54424a46ffb505bd1a117a44fc30c01bbff882

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

LOG: [lld][WebAssembly] Do not remove name section with --strip-debug

Leave the name section in the output when using the --strip-debug
flag. This treats it more like ELF symbol tables, as the name
section has similar uses at runtime (e.g. wasm engines understand
it and it can be used for symbolization at runtime).

Fixes https://github.com/emscripten-core/emscripten/issues/14623

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

Added: 
    

Modified: 
    lld/test/wasm/strip-debug.test
    lld/test/wasm/weak-undefined.s
    lld/wasm/SyntheticSections.h

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/strip-debug.test b/lld/test/wasm/strip-debug.test
index 12a9dc7816f57..ce8cbffe5fb78 100644
--- a/lld/test/wasm/strip-debug.test
+++ b/lld/test/wasm/strip-debug.test
@@ -6,5 +6,5 @@ RUN: obj2yaml %t.wasm | FileCheck %s
 RUN: wasm-ld -S -o %t.wasm %t.start.o
 RUN: obj2yaml %t.wasm | FileCheck %s
 
-# Check that there is no name section
-CHECK-NOT:   Name:    name
+# Check that there is a name section
+CHECK:   Name:    name

diff  --git a/lld/test/wasm/weak-undefined.s b/lld/test/wasm/weak-undefined.s
index a542cf9af3d9d..5b8b9775fcea1 100644
--- a/lld/test/wasm/weak-undefined.s
+++ b/lld/test/wasm/weak-undefined.s
@@ -1,5 +1,5 @@
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
-# RUN: wasm-ld -strip-debug %t.o -o %t.wasm
+# RUN: wasm-ld -strip-all %t.o -o %t.wasm
 # RUN: obj2yaml %t.wasm | FileCheck %s
 
 # Test that undefined weak externals (global_var) and (foo) don't cause

diff  --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h
index 8c678fa0853f3..8eebe916780c6 100644
--- a/lld/wasm/SyntheticSections.h
+++ b/lld/wasm/SyntheticSections.h
@@ -362,9 +362,7 @@ class NameSection : public SyntheticSection {
   NameSection(ArrayRef<OutputSegment *> segments)
       : SyntheticSection(llvm::wasm::WASM_SEC_CUSTOM, "name"),
         segments(segments) {}
-  bool isNeeded() const override {
-    return !config->stripDebug && !config->stripAll && numNames() > 0;
-  }
+  bool isNeeded() const override { return !config->stripAll && numNames() > 0; }
   void writeBody() override;
   unsigned numNames() const { return numNamedGlobals() + numNamedFunctions(); }
   unsigned numNamedGlobals() const;


        


More information about the llvm-commits mailing list