summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-03-08 01:16:05 +0000
committerSam Clegg <sbc@chromium.org>2018-03-08 01:16:05 +0000
commit7f8141818358375cc626fc7e4779d61e39ee9276 (patch)
tree9da206b5b7e4f82e37dfced337d39367905d3d32
parentfb2d34229941a32666bec8ca96ba3beb703ed188 (diff)
downloadbcm5719-llvm-7f8141818358375cc626fc7e4779d61e39ee9276.tar.gz
bcm5719-llvm-7f8141818358375cc626fc7e4779d61e39ee9276.zip
[WebAssembly] Honor --allow-undefined even for explicit exports
When a symbol is exported via --export=foo but --allow-undefined is also specified, the symbol is now allowed to be undefined. Previously we were special casing such symbols. This combinations of behavior is exactly what emescripten requires. Although we are trying hard not to allow emscripten specific features in lld, this one makes sense. Enforce this behavior by added this case to test/wasm/undefined.ll. Differential Revision: https://reviews.llvm.org/D44237 llvm-svn: 326976
-rw-r--r--lld/test/wasm/undefined.ll5
-rw-r--r--lld/wasm/Driver.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/lld/test/wasm/undefined.ll b/lld/test/wasm/undefined.ll
index 69b7a8238fd..a74dd6d66de 100644
--- a/lld/test/wasm/undefined.ll
+++ b/lld/test/wasm/undefined.ll
@@ -6,10 +6,13 @@
; CHECK: error: {{.*}}.o: undefined symbol: foo
; CHECK: error: undefined symbol: baz
-; But succeeds if we pass a file containing 'foo' as --allow-undefined-file.
+; Succeeds if we pass a file containing 'foo' as --allow-undefined-file.
; RUN: echo 'foo' > %t.txt
; RUN: wasm-ld --check-signatures --allow-undefined-file=%t.txt -o %t.wasm %t.o
+; Succeeds even if a missing symbol is added via --export
+; RUN: wasm-ld --check-signatures --allow-undefined --export=xxx -o %t.wasm %t.o
+
target triple = "wasm32-unknown-unknown-wasm"
; Takes the address of the external foo() resulting in undefined external
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index ef0794c3073..a97026d4df8 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -346,7 +346,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Symbol *Sym = Symtab->find(Name);
if (Sym && Sym->isDefined())
Sym->setHidden(false);
- else
+ else if (!Config->AllowUndefined)
error("symbol exported via --export not found: " + Name);
}
OpenPOWER on IntegriCloud