[llvm] r332406 - [WebAssembly] Provide WasmFunction content offset information.

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 14:49:59 PDT 2018


Author: sbc
Date: Tue May 15 14:49:58 2018
New Revision: 332406

URL: http://llvm.org/viewvc/llvm-project?rev=332406&view=rev
Log:
[WebAssembly] Provide WasmFunction content offset information.

WasmObjectWriter mostly operates with function segments offsets that do
not include their size fields. WasmObjectFile needs to have and provide
this information to the lld to maintain proper
R_WEBASSEMBLY_FUNCTION_OFFSET_I32 relocations entries.

Patch by Yury Delendik

Differential Revision: https://reviews.llvm.org/D46763

Modified:
    llvm/trunk/include/llvm/BinaryFormat/Wasm.h
    llvm/trunk/lib/Object/WasmObjectFile.cpp

Modified: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Wasm.h?rev=332406&r1=332405&r2=332406&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Tue May 15 14:49:58 2018
@@ -102,6 +102,7 @@ struct WasmFunction {
   ArrayRef<uint8_t> Body;
   uint32_t CodeSectionOffset;
   uint32_t Size;
+  uint32_t CodeOffset;  // start of Locals and Body
   StringRef SymbolName; // from the "linking" section
   StringRef DebugName; // from the "name" section
   uint32_t Comdat; // from the "comdat info" section

Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=332406&r1=332405&r2=332406&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Tue May 15 14:49:58 2018
@@ -875,6 +875,7 @@ Error WasmObjectFile::parseCodeSection(c
     uint32_t Size = readVaruint32(Ptr);
     const uint8_t *FunctionEnd = Ptr + Size;
 
+    Function.CodeOffset = Ptr - FunctionStart;
     Function.Index = NumImportedFunctions + Functions.size();
     Function.CodeSectionOffset = FunctionStart - CodeSectionStart;
     Function.Size = FunctionEnd - FunctionStart;




More information about the llvm-commits mailing list