summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
diff options
context:
space:
mode:
authorNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-08-03 14:33:37 +0000
committerNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-08-03 14:33:37 +0000
commite408a89a3aa83acb97f22d7d51ab341c22c6e05c (patch)
tree6b829861c534d9dc48c4940345183f528fe1c081 /llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
parent873de9866119754dab9146026f357a27bb1d5e26 (diff)
downloadbcm5719-llvm-e408a89a3aa83acb97f22d7d51ab341c22c6e05c.tar.gz
bcm5719-llvm-e408a89a3aa83acb97f22d7d51ab341c22c6e05c.zip
[WebAssembly] Cleanup of the way globals and global flags are handled
Differential Revision: https://reviews.llvm.org/D44030 llvm-svn: 338894
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
index 4fb12d40b01..dc876ab585b 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -81,6 +81,11 @@ static const MCSection *GetFixupSection(const MCExpr *Expr) {
return nullptr;
}
+static bool IsGlobalType(const MCValue &Target) {
+ const MCSymbolRefExpr *RefA = Target.getSymA();
+ return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_GLOBAL;
+}
+
unsigned
WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
const MCFixup &Fixup) const {
@@ -89,8 +94,6 @@ WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
bool IsFunction = IsFunctionExpr(Fixup.getValue());
switch (unsigned(Fixup.getKind())) {
- case WebAssembly::fixup_code_global_index:
- return wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB;
case WebAssembly::fixup_code_sleb128_i32:
if (IsFunction)
return wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB;
@@ -98,6 +101,8 @@ WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
case WebAssembly::fixup_code_sleb128_i64:
llvm_unreachable("fixup_sleb128_i64 not implemented yet");
case WebAssembly::fixup_code_uleb128_i32:
+ if (IsGlobalType(Target))
+ return wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB;
if (IsFunctionType(Target))
return wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB;
if (IsFunction)
OpenPOWER on IntegriCloud