[PATCH] D74110: [lld][WebAssembly] Allow symbols with explict import names to be undefined at link time.
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 15:55:08 PST 2020
sbc100 updated this revision to Diff 245549.
sbc100 added a comment.
typo
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74110/new/
https://reviews.llvm.org/D74110
Files:
lld/docs/WebAssembly.rst
lld/test/wasm/import-name.ll
lld/wasm/Relocations.cpp
Index: lld/wasm/Relocations.cpp
===================================================================
--- lld/wasm/Relocations.cpp
+++ lld/wasm/Relocations.cpp
@@ -28,6 +28,11 @@
// compiling with -fPIC)
if (isa<DataSymbol>(sym))
return false;
+ // Undefined functions with explicit import name are allowed to be undefined
+ // at link time.
+ if (auto* F = dyn_cast<UndefinedFunction>(sym))
+ if (F->importName)
+ return true;
return (config->allowUndefined ||
config->allowUndefinedSymbols.count(sym->getName()) != 0);
}
Index: lld/test/wasm/import-name.ll
===================================================================
--- lld/test/wasm/import-name.ll
+++ lld/test/wasm/import-name.ll
@@ -1,5 +1,5 @@
; RUN: llc -filetype=obj %s -o %t.o
-; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
+; RUN: wasm-ld -o %t.wasm %t.o
; RUN: obj2yaml %t.wasm | FileCheck %s
target triple = "wasm32-unknown-unknown"
Index: lld/docs/WebAssembly.rst
===================================================================
--- lld/docs/WebAssembly.rst
+++ lld/docs/WebAssembly.rst
@@ -112,8 +112,8 @@
a warning. The ``--fatal-warnings`` flag can be used to disable this behaviour
and error out if mismatched are found.
-Imports and Exports
-~~~~~~~~~~~~~~~~~~~
+Exports
+~~~~~~~
When building a shared library any symbols marked as ``visibility=default`` will
be exported.
@@ -130,6 +130,17 @@
used to export symbols in the executable which are marked as
``visibility=default``.
+Imports
+~~~~~~~
+
+By default no undefined symbols are allowed in the final binary. The flag
+``--allow-undefined`` results in a WebAssembly import being defined for each
+undefined symbol. It is then up to the runtime to provide such symbols.
+
+Alternativly symbols can be marked in the source code as with the
+``import_name`` and/or ``import_module`` clang attributes which signals that
+they are expected to be undefined at static link time.
+
Garbage Collection
~~~~~~~~~~~~~~~~~~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74110.245549.patch
Type: text/x-patch
Size: 2011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200219/c59599a5/attachment.bin>
More information about the llvm-commits
mailing list