From 9745afa6748bcd5424cf7b2324b5a3dc7f1feb35 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 12 Apr 2018 20:31:12 +0000 Subject: [WebAssembly] libObject: Don't include the name the size of custom sections Differential Revision: https://reviews.llvm.org/D45579 llvm-svn: 329947 --- llvm/lib/Object/WasmObjectFile.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 0c78631..b9eba01 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -178,6 +178,11 @@ static Error readSection(WasmSection &Section, const uint8_t *&Ptr, if (Ptr + Size > Eof) return make_error("Section too large", object_error::parse_failed); + if (Section.Type == wasm::WASM_SEC_CUSTOM) { + const uint8_t *NameStart = Ptr; + Section.Name = readString(Ptr); + Size -= Ptr - NameStart; + } Section.Content = ArrayRef(Ptr, Size); Ptr += Size; return Error::success(); @@ -618,7 +623,6 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, const uint8_t *Ptr, Error WasmObjectFile::parseCustomSection(WasmSection &Sec, const uint8_t *Ptr, const uint8_t *End) { - Sec.Name = readString(Ptr); if (Sec.Name == "name") { if (Error Err = parseNameSection(Ptr, End)) return Err; -- cgit v1.1