Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d1f598a

Browse files
sbc100radekdoulik
authored andcommittedNov 25, 2024·
[lld][WebAssembly] Ignore local symbols when parsing lazy object files. (llvm#104876)
This was broken back in llvm#78658 when we transitioned away from archive indexes to parsing lazy object files. Fixes: llvm#94077 Fixes: emscripten-core/emscripten#22008
1 parent 6252055 commit d1f598a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎lld/test/wasm/archive-local-sym.s

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Test that local symbols in archive files are ignored.
2+
# RUN: split-file %s %t
3+
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t/foo.o %t/foo.s
4+
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t/main.o %t/main.s
5+
# RUN: rm -f %t/libfoo.a
6+
# RUN: llvm-ar rcs %t/libfoo.a %t/foo.o
7+
# RUN: not wasm-ld %t/libfoo.a %t/main.o -o out.wasm 2>&1 | FileCheck %s
8+
9+
#--- main.s
10+
11+
.functype foo () -> ()
12+
13+
.globl _start
14+
_start:
15+
.functype _start () -> ()
16+
call foo
17+
# CHECK: main.o: undefined symbol: foo
18+
end_function
19+
20+
#--- foo.s
21+
22+
foo:
23+
.functype foo () -> ()
24+
end_function

‎lld/wasm/InputFiles.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void ObjFile::parseLazy() {
392392
<< wasmObj.get() << "\n");
393393
for (const SymbolRef &sym : wasmObj->symbols()) {
394394
const WasmSymbol &wasmSym = wasmObj->getWasmSymbol(sym.getRawDataRefImpl());
395-
if (!wasmSym.isDefined())
395+
if (wasmSym.isUndefined() || wasmSym.isBindingLocal())
396396
continue;
397397
symtab->addLazy(wasmSym.Info.Name, this);
398398
// addLazy() may trigger this->extract() if an existing symbol is an

0 commit comments

Comments
 (0)
Please sign in to comment.