[lld] 5403123 - [lld][WebAssembly] Ignore local symbols when parsing lazy object files. (#104876)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 21:51:44 PDT 2024
Author: Sam Clegg
Date: 2024-08-19T21:51:40-07:00
New Revision: 5403123197f8e331d3c2c24d82439ca1fe7e702d
URL: https://github.com/llvm/llvm-project/commit/5403123197f8e331d3c2c24d82439ca1fe7e702d
DIFF: https://github.com/llvm/llvm-project/commit/5403123197f8e331d3c2c24d82439ca1fe7e702d.diff
LOG: [lld][WebAssembly] Ignore local symbols when parsing lazy object files. (#104876)
This was broken back in #78658 when we transitioned away from archive
indexes to parsing lazy object files.
Fixes: #94077
Fixes: https://github.com/emscripten-core/emscripten/issues/22008
Added:
lld/test/wasm/archive-local-sym.s
Modified:
lld/wasm/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/test/wasm/archive-local-sym.s b/lld/test/wasm/archive-local-sym.s
new file mode 100644
index 00000000000000..53e95b9bbb1056
--- /dev/null
+++ b/lld/test/wasm/archive-local-sym.s
@@ -0,0 +1,24 @@
+## Test that local symbols in archive files are ignored.
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t/foo.o %t/foo.s
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t/main.o %t/main.s
+# RUN: rm -f %t/libfoo.a
+# RUN: llvm-ar rcs %t/libfoo.a %t/foo.o
+# RUN: not wasm-ld %t/libfoo.a %t/main.o -o out.wasm 2>&1 | FileCheck %s
+
+#--- main.s
+
+.functype foo () -> ()
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ call foo
+# CHECK: main.o: undefined symbol: foo
+ end_function
+
+#--- foo.s
+
+foo:
+ .functype foo () -> ()
+ end_function
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 706ee25d5aae27..de8e707ab2b497 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -392,7 +392,7 @@ void ObjFile::parseLazy() {
<< wasmObj.get() << "\n");
for (const SymbolRef &sym : wasmObj->symbols()) {
const WasmSymbol &wasmSym = wasmObj->getWasmSymbol(sym.getRawDataRefImpl());
- if (!wasmSym.isDefined())
+ if (wasmSym.isUndefined() || wasmSym.isBindingLocal())
continue;
symtab->addLazy(wasmSym.Info.Name, this);
// addLazy() may trigger this->extract() if an existing symbol is an
More information about the llvm-commits
mailing list