summaryrefslogtreecommitdiffstats
path: root/lld/wasm/Driver.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-09-27 21:06:25 +0000
committerSam Clegg <sbc@chromium.org>2018-09-27 21:06:25 +0000
commit305b0343cee31bb500b00786d48b8f8f945a141d (patch)
tree8a5dbe819252d74492cbcf0dd16a952a7c03c298 /lld/wasm/Driver.cpp
parent5f1b8181ad499108ecdfaa1fcac3d8326e2ef86d (diff)
downloadbcm5719-llvm-305b0343cee31bb500b00786d48b8f8f945a141d.tar.gz
bcm5719-llvm-305b0343cee31bb500b00786d48b8f8f945a141d.zip
[WebAssembly] Add --[no]-export-dynamic to replace --export-default
In a very recent change I introduced a --no-export-default flag but after conferring with others it seems that this feature already exists in gnu GNU ld and lld in the form the --export-dynamic flag which is off by default. This change replaces export-default with export-dynamic and also changes the default to match the traditional linker behaviour. Now, by default, only the entry point is exported. If other symbols are required by the embedder then --export-dynamic or --export can be used to export all visibility hidden symbols or individual symbols respectively. This change touches a lot of tests that were relying on symbols being exported by default. I imagine it will also effect many users but do think the change is worth it match of the traditional behaviour and flag names. Differential Revision: https://reviews.llvm.org/D52587 llvm-svn: 343265
Diffstat (limited to 'lld/wasm/Driver.cpp')
-rw-r--r--lld/wasm/Driver.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 89785587304..7165f75227e 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -373,8 +373,8 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? "" : "_start");
Config->ExportAll = Args.hasArg(OPT_export_all);
- Config->ExportDefault = Args.hasFlag(OPT_export_default,
- OPT_no_export_default, true);
+ Config->ExportDynamic = Args.hasFlag(OPT_export_dynamic,
+ OPT_no_export_dynamic, false);
Config->ExportTable = Args.hasArg(OPT_export_table);
errorHandler().FatalWarnings =
Args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false);
@@ -473,6 +473,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
WasmSym::DsoHandle = Symtab->addSyntheticDataSymbol(
"__dso_handle", WASM_SYMBOL_VISIBILITY_HIDDEN);
WasmSym::DataEnd = Symtab->addSyntheticDataSymbol("__data_end", 0);
+
+ // These two synthetic symbols exist purely for the embedder so we always
+ // want to export them.
+ WasmSym::HeapBase->ForceExport = true;
+ WasmSym::DataEnd->ForceExport = true;
}
createFiles(Args);
@@ -507,7 +512,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
if (!Config->Entry.empty()) {
EntrySym = handleUndefined(Config->Entry);
- if (!EntrySym)
+ if (EntrySym && EntrySym->isDefined())
+ EntrySym->ForceExport = true;
+ else
error("entry symbol not defined (pass --no-entry to supress): " +
Config->Entry);
}
OpenPOWER on IntegriCloud