[PATCH] D45579: [WebAssembly] libObject: Don't include the name the size of custom sections

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 10:18:06 PDT 2018


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

Repository:
  rL LLVM

https://reviews.llvm.org/D45579

Files:
  lib/Object/WasmObjectFile.cpp
  test/MC/WebAssembly/custom-sections.ll


Index: test/MC/WebAssembly/custom-sections.ll
===================================================================
--- test/MC/WebAssembly/custom-sections.ll
+++ test/MC/WebAssembly/custom-sections.ll
@@ -11,13 +11,13 @@
 
 ; CHECK:  Section {
 ; CHECK:    Type: CUSTOM (0x0)
-; CHECK:    Size: 7
+; CHECK:    Size: 3
 ; CHECK:    Offset: 72
 ; CHECK:    Name: red
 ; CHECK:  }
 ; CHECK:  Section {
 ; CHECK:    Type: CUSTOM (0x0)
-; CHECK:    Size: 12
+; CHECK:    Size: 6
 ; CHECK:    Offset: 85
 ; CHECK:    Name: green
 ; CHECK:  }
Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -178,6 +178,11 @@
   if (Ptr + Size > Eof)
     return make_error<StringError>("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<uint8_t>(Ptr, Size);
   Ptr += Size;
   return Error::success();
@@ -618,7 +623,6 @@
 
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45579.142208.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180412/512c2142/attachment.bin>


More information about the llvm-commits mailing list