Skip to content
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
12 changes: 12 additions & 0 deletions lld/test/wasm/static-error.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
// RUN: wasm-ld --experimental-pic -shared -o %t.so %t.o

// RUN: wasm-ld --experimental-pic -pie -o /dev/null %t.o %t.so
// RUN: not wasm-ld -o /dev/null -static %t.o %t.so 2>&1 | FileCheck %s

// CHECK: attempted static link of dynamic object

.global _start
_start:
.functype _start () -> ()
end_function
10 changes: 8 additions & 2 deletions lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,15 @@ void LinkerDriver::addFile(StringRef path) {
return;
}
case file_magic::bitcode:
case file_magic::wasm_object:
files.push_back(createObjectFile(mbref, "", 0, inLib));
case file_magic::wasm_object: {
auto obj = createObjectFile(mbref, "", 0, inLib);
if (config->isStatic && isa<SharedFile>(obj)) {
error("attempted static link of dynamic object " + path);
break;
}
files.push_back(obj);
break;
}
case file_magic::unknown:
if (mbref.getBuffer().starts_with("#STUB")) {
files.push_back(make<StubFile>(mbref));
Expand Down