summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-06-06 19:15:05 +0000
committerSam Clegg <sbc@chromium.org>2017-06-06 19:15:05 +0000
commitacd7d2b00bba425e46dcbd652b787051bcce2d02 (patch)
tree3093d185ca1a3e187bfe1c8d5f826c92298e1048 /llvm/lib/Target/WebAssembly
parent8b5f9e4438ed97a4134e17ff14da419a2cc6b9d6 (diff)
downloadbcm5719-llvm-acd7d2b00bba425e46dcbd652b787051bcce2d02.tar.gz
bcm5719-llvm-acd7d2b00bba425e46dcbd652b787051bcce2d02.zip
[WebAssembly] MC: Refactor relocation handling
The change cleans up and unifies the handling of relocation entries in WasmObjectWriter. Type index relocation no longer need to be handled separately. The only externally visible change should be that type index relocations are no longer grouped at the end. Differential Revision: https://reviews.llvm.org/D33918 llvm-svn: 304816
Diffstat (limited to 'llvm/lib/Target/WebAssembly')
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
index 00d7fc71c49..c773e57402e 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -54,6 +54,11 @@ static bool IsFunctionExpr(const MCExpr *Expr) {
return false;
}
+static bool IsFunctionType(const MCValue &Target) {
+ const MCSymbolRefExpr *RefA = Target.getSymA();
+ return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX;
+}
+
unsigned WebAssemblyWasmObjectWriter::getRelocType(MCContext &Ctx,
const MCValue &Target,
const MCFixup &Fixup,
@@ -71,6 +76,8 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(MCContext &Ctx,
case WebAssembly::fixup_code_sleb128_i64:
llvm_unreachable("fixup_sleb128_i64 not implemented yet");
case WebAssembly::fixup_code_uleb128_i32:
+ if (IsFunctionType(Target))
+ return wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB;
if (IsFunction)
return wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB;
return wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB;
OpenPOWER on IntegriCloud