diff options
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp index 3b800858063..1a9c714ed0f 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -46,6 +46,10 @@ static bool isFunctionSignatureRef(const MCSymbolRefExpr *Ref) { return Ref->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX; } +static bool isGOTRef(const MCSymbolRefExpr *Ref) { + return Ref->getKind() == MCSymbolRefExpr::VK_GOT; +} + static const MCSection *getFixupSection(const MCExpr *Expr) { if (auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) { if (SyExp->getSymbol().isInSection()) @@ -79,14 +83,14 @@ unsigned 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 (SymA.isGlobal() || isGOTRef(RefA)) + return wasm::R_WASM_GLOBAL_INDEX_LEB; if (SymA.isFunction()) { if (isFunctionSignatureRef(RefA)) return wasm::R_WASM_TYPE_INDEX_LEB; else return wasm::R_WASM_FUNCTION_INDEX_LEB; } - if (SymA.isGlobal()) - return wasm::R_WASM_GLOBAL_INDEX_LEB; if (SymA.isEvent()) return wasm::R_WASM_EVENT_INDEX_LEB; return wasm::R_WASM_MEMORY_ADDR_LEB; |