summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-03-30 16:06:14 +0000
committerRui Ueyama <ruiu@google.com>2018-03-30 16:06:14 +0000
commit0961218c109feac256c612f79a3d7c1249aef0f3 (patch)
tree7a95387547cb9696f2fbc602b53a9ee8ebffe958
parente09b7dcf3d64372b8370d309ba3cce4d9e5e6402 (diff)
downloadbcm5719-llvm-0961218c109feac256c612f79a3d7c1249aef0f3.tar.gz
bcm5719-llvm-0961218c109feac256c612f79a3d7c1249aef0f3.zip
[WebAssembly] Error if both --export-table and --import-table are specified.
Differential Revision: https://reviews.llvm.org/D45001 llvm-svn: 328873
-rw-r--r--lld/test/wasm/driver.ll4
-rw-r--r--lld/wasm/Driver.cpp10
2 files changed, 9 insertions, 5 deletions
diff --git a/lld/test/wasm/driver.ll b/lld/test/wasm/driver.ll
index 10a8eca4892..7222cb58d40 100644
--- a/lld/test/wasm/driver.ll
+++ b/lld/test/wasm/driver.ll
@@ -16,3 +16,7 @@ entry:
; RUN: not wasm-ld 2>&1 | FileCheck -check-prefix=BOTH %s
; BOTH: error: no input files
; BOTH-NOT: error: no output file specified
+
+; RUN: not wasm-ld --export-table --import-table %t.o 2>&1 \
+; RUN: | FileCheck -check-prefix=TABLE %s
+; TABLE: error: --import-table and --export-table may not be used together
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 56eb3614fa2..97a8159e57d 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -286,7 +286,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Args.hasFlag(OPT_check_signatures, OPT_no_check_signatures, false);
Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true);
Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? "" : "_start");
+ Config->ExportTable = Args.hasArg(OPT_export_table);
Config->ImportMemory = Args.hasArg(OPT_import_memory);
+ Config->ImportTable = Args.hasArg(OPT_import_table);
Config->OutputFile = Args.getLastArgValue(OPT_o);
Config->Relocatable = Args.hasArg(OPT_relocatable);
Config->GcSections =
@@ -296,11 +298,6 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Config->SearchPaths = args::getStrings(Args, OPT_L);
Config->StripAll = Args.hasArg(OPT_strip_all);
Config->StripDebug = Args.hasArg(OPT_strip_debug);
- auto *TableArg = Args.getLastArg(OPT_import_table, OPT_export_table);
- Config->ImportTable =
- TableArg && TableArg->getOption().getID() == OPT_import_table;
- Config->ExportTable =
- TableArg && TableArg->getOption().getID() == OPT_export_table;
errorHandler().Verbose = Args.hasArg(OPT_verbose);
ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);
@@ -321,6 +318,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
if (Config->OutputFile.empty())
error("no output file specified");
+ if (Config->ImportTable && Config->ExportTable)
+ error("--import-table and --export-table may not be used together");
+
if (Config->Relocatable) {
if (!Config->Entry.empty())
error("entry point specified for relocatable output file");
OpenPOWER on IntegriCloud