From c551522d250ae53d7cac031f91f9c605c02893e7 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 17 Dec 2017 17:50:07 +0000 Subject: [WebAssembly] Export some more info on wasm funtions Summary: These fields are useful for lld's gc-sections support Also remove an unused field. Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish Differential Revision: https://reviews.llvm.org/D41320 llvm-svn: 320946 --- llvm/lib/Object/WasmObjectFile.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 4137757..7a0c05e 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -684,18 +684,21 @@ Error WasmObjectFile::parseStartSection(const uint8_t *Ptr, const uint8_t *End) } Error WasmObjectFile::parseCodeSection(const uint8_t *Ptr, const uint8_t *End) { + const uint8_t *CodeSectionStart = Ptr; uint32_t FunctionCount = readVaruint32(Ptr); if (FunctionCount != FunctionTypes.size()) { return make_error("Invalid function count", object_error::parse_failed); } - CodeSection = ArrayRef(Ptr, End - Ptr); - while (FunctionCount--) { wasm::WasmFunction Function; - uint32_t FunctionSize = readVaruint32(Ptr); - const uint8_t *FunctionEnd = Ptr + FunctionSize; + const uint8_t *FunctionStart = Ptr; + uint32_t Size = readVaruint32(Ptr); + const uint8_t *FunctionEnd = Ptr + Size; + + Function.CodeSectionOffset = FunctionStart - CodeSectionStart; + Function.Size = FunctionEnd - FunctionStart; uint32_t NumLocalDecls = readVaruint32(Ptr); Function.Locals.reserve(NumLocalDecls); -- cgit v1.1