[PATCH] D46763: [WebAssembly] Provide WasmFunction content offset informatin.

Yury Delendik via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 11 11:26:40 PDT 2018


yurydelendik created this revision.
yurydelendik added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D46763

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


Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -875,6 +875,7 @@
     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;
Index: include/llvm/BinaryFormat/Wasm.h
===================================================================
--- include/llvm/BinaryFormat/Wasm.h
+++ include/llvm/BinaryFormat/Wasm.h
@@ -102,6 +102,7 @@
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46763.146370.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180511/5835819a/attachment.bin>


More information about the llvm-commits mailing list