[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
This commit is contained in:
Sam Clegg 2019-04-22 05:26:44 +00:00
parent bc4b159bb1
commit 7868fb6fdd
1 changed files with 7 additions and 6 deletions

View File

@ -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<DefinedFunction>(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: