summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-12-08 00:13:14 +0000
committerSam Clegg <sbc@chromium.org>2017-12-08 00:13:14 +0000
commitc5872e864a236bc7ffda508a8f7c6a74083c477f (patch)
treea878bac9195f11e35efe8c5927ceae0fcb4fef70
parent2569edd9b8888421402f825d31ace27b9df9360f (diff)
downloadbcm5719-llvm-c5872e864a236bc7ffda508a8f7c6a74083c477f.tar.gz
bcm5719-llvm-c5872e864a236bc7ffda508a8f7c6a74083c477f.zip
[WebAssembly] Add check to ensure symbol VA is only set once. NFC.
Also remove resulting unneeded function. Differential Revision: https://reviews.llvm.org/D40990 llvm-svn: 320118
-rw-r--r--lld/wasm/Driver.cpp13
-rw-r--r--lld/wasm/Symbols.cpp1
2 files changed, 2 insertions, 12 deletions
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 2858f68397b..475682b87df 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -134,17 +134,6 @@ static Optional<std::string> findFile(StringRef Path1, const Twine &Path2) {
return None;
}
-// Inject a new wasm global into the output binary with the given value.
-// Wasm global are used in relocatable object files to model symbol imports
-// and exports. In the final executable the only use of wasm globals is
-// for the exlicit stack pointer (__stack_pointer).
-static Symbol* addSyntheticGlobal(StringRef Name, int32_t Value) {
- log("injecting global: " + Name);
- Symbol *S = Symtab->addDefinedGlobal(Name);
- S->setVirtualAddress(Value);
- return S;
-}
-
// Inject a new undefined symbol into the link. This will cause the link to
// fail unless this symbol can be found.
static void addSyntheticUndefinedFunction(StringRef Name,
@@ -285,7 +274,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
for (StringRef S : args::getStrings(Args, OPT_undefined))
addSyntheticUndefinedFunction(S, nullptr);
- Config->StackPointerSymbol = addSyntheticGlobal("__stack_pointer", 0);
+ Config->StackPointerSymbol = Symtab->addDefinedGlobal("__stack_pointer");
}
createFiles(Args);
diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp
index 2be2ef91d2d..764e00e37cd 100644
--- a/lld/wasm/Symbols.cpp
+++ b/lld/wasm/Symbols.cpp
@@ -61,6 +61,7 @@ uint32_t Symbol::getOutputIndex() const {
void Symbol::setVirtualAddress(uint32_t Value) {
DEBUG(dbgs() << "setVirtualAddress " << Name << " -> " << Value << "\n");
+ assert(!VirtualAddress.hasValue());
VirtualAddress = Value;
}
OpenPOWER on IntegriCloud