diff options
author | Sam Clegg <sbc@chromium.org> | 2017-12-17 17:50:07 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-12-17 17:50:07 +0000 |
commit | c551522d250ae53d7cac031f91f9c605c02893e7 (patch) | |
tree | e3e754275d2f93367c244d3c3ee4baea32203209 /llvm/lib/Object | |
parent | 6f7bbf349f05eb569cf17ed9e8cf6a94acbd6120 (diff) | |
download | bcm5719-llvm-c551522d250ae53d7cac031f91f9c605c02893e7.tar.gz bcm5719-llvm-c551522d250ae53d7cac031f91f9c605c02893e7.zip |
[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
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 41377579ae0..7a0c05ed8a1 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<GenericBinaryError>("Invalid function count", object_error::parse_failed); } - CodeSection = ArrayRef<uint8_t>(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); |