Skip to content

Commit

Permalink
[WebAssembly] Fix R_WASM_FUNCTION_OFFSET_I32 relocation warnings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbc100 committed Apr 22, 2019
1 parent bc4b159 commit 7868fb6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lld/wasm/InputFiles.cpp
Expand Up @@ -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:
Expand Down

0 comments on commit 7868fb6

Please sign in to comment.