[lld] r358871 - [WebAssembly] Fix R_WASM_FUNCTION_OFFSET_I32 relocation warnings

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 21 22:26:44 PDT 2019


Author: sbc
Date: Sun Apr 21 22:26:44 2019
New Revision: 358871

URL: http://llvm.org/viewvc/llvm-project?rev=358871&view=rev
Log:
[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

Modified:
    lld/trunk/wasm/InputFiles.cpp

Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=358871&r1=358870&r2=358871&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Sun Apr 21 22:26:44 2019
@@ -117,12 +117,13 @@ uint32_t ObjFile::calcExpectedValue(cons
     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:




More information about the llvm-commits mailing list