From 7868fb6fdd79927a1f3b2e7185183bf4702f290c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 22 Apr 2019 05:26:44 +0000 Subject: [PATCH] [WebAssembly] Fix R_WASM_FUNCTION_OFFSET_I32 relocation warnings We were incorrectly used the symbol table version of the function rather than the object-local version when checking the existing relocation value. This was causing erroneous warnings for comat symbols defined in multiple object.s Fixes: https://bugs.llvm.org/show_bug.cgi?id=40503 Differential Revision: https://reviews.llvm.org/D60928 llvm-svn: 358871 --- lld/wasm/InputFiles.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index e118b041ca06..2929379b9738 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -117,12 +117,13 @@ uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const { return Segment.Data.Offset.Value.Int32 + Sym.Info.DataRef.Offset + Reloc.Addend; } - case R_WASM_FUNCTION_OFFSET_I32: - if (auto *Sym = dyn_cast(getFunctionSymbol(Reloc.Index))) { - return Sym->Function->getFunctionInputOffset() + - Sym->Function->getFunctionCodeOffset() + Reloc.Addend; - } - return 0; + case R_WASM_FUNCTION_OFFSET_I32: { + const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index]; + InputFunction *F = + Functions[Sym.Info.ElementIndex - WasmObj->getNumImportedFunctions()]; + return F->getFunctionInputOffset() + F->getFunctionCodeOffset() + + Reloc.Addend; + } case R_WASM_SECTION_OFFSET_I32: return Reloc.Addend; case R_WASM_TYPE_INDEX_LEB: