Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lld][WebAssembly] Ignore local symbols when parsing lazy object files. #104876

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lld/test/wasm/archive-local-sym.s
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lld/wasm/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading