[llvm] r329947 - [WebAssembly] libObject: Don't include the name the size of custom sections
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 12 13:31:12 PDT 2018
Author: sbc
Date: Thu Apr 12 13:31:12 2018
New Revision: 329947
URL: http://llvm.org/viewvc/llvm-project?rev=329947&view=rev
Log:
[WebAssembly] libObject: Don't include the name the size of custom sections
Differential Revision: https://reviews.llvm.org/D45579
Modified:
llvm/trunk/lib/Object/WasmObjectFile.cpp
llvm/trunk/test/MC/WebAssembly/custom-sections.ll
llvm/trunk/test/ObjectYAML/wasm/custom_section.yaml
llvm/trunk/test/tools/llvm-objdump/wasm.txt
llvm/trunk/test/tools/llvm-readobj/sections.test
llvm/trunk/tools/yaml2obj/yaml2wasm.cpp
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Thu Apr 12 13:31:12 2018
@@ -178,6 +178,11 @@ static Error readSection(WasmSection &Se
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::parseRelocSection(
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;
Modified: llvm/trunk/test/MC/WebAssembly/custom-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/custom-sections.ll?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/custom-sections.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/custom-sections.ll Thu Apr 12 13:31:12 2018
@@ -11,13 +11,13 @@ target triple = "wasm32-unknown-unknown-
; 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: }
Modified: llvm/trunk/test/ObjectYAML/wasm/custom_section.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/wasm/custom_section.yaml?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/test/ObjectYAML/wasm/custom_section.yaml (original)
+++ llvm/trunk/test/ObjectYAML/wasm/custom_section.yaml Thu Apr 12 13:31:12 2018
@@ -5,7 +5,7 @@ FileHeader:
Sections:
- Type: CUSTOM
Name: foo
- Payload: 03666F6F0401020304
+ Payload: '0401020304'
...
# CHECK: --- !WASM
# CHECK: FileHeader:
@@ -13,5 +13,5 @@ Sections:
# CHECK: Sections:
# CHECK: - Type: CUSTOM
# CHECK: Name: foo
-# CHECK: Payload: 03666F6F0401020304
+# CHECK: Payload: '0401020304'
# CHECK: ...
Modified: llvm/trunk/test/tools/llvm-objdump/wasm.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/wasm.txt?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/wasm.txt (original)
+++ llvm/trunk/test/tools/llvm-objdump/wasm.txt Thu Apr 12 13:31:12 2018
@@ -7,8 +7,8 @@
# CHECK-NEXT: 2 FUNCTION 00000002 0000000000000000
# CHECK-NEXT: 3 CODE 00000019 0000000000000000 TEXT
# CHECK-NEXT: 4 DATA 0000001c 0000000000000000 DATA
-# CHECK-NEXT: 5 linking 00000055 0000000000000000
-# CHECK-NEXT: 6 reloc.CODE 00000017 0000000000000000
+# CHECK-NEXT: 5 linking 0000004d 0000000000000000
+# CHECK-NEXT: 6 reloc.CODE 0000000c 0000000000000000
# RUN: llvm-objdump -p %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-HEADER
Modified: llvm/trunk/test/tools/llvm-readobj/sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/sections.test?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/sections.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/sections.test Thu Apr 12 13:31:12 2018
@@ -528,13 +528,13 @@ WASM-NEXT: ]
WASM-NEXT: }
WASM-NEXT: Section {
WASM-NEXT: Type: CUSTOM (0x0)
-WASM-NEXT: Size: 65
+WASM-NEXT: Size: 57
WASM-NEXT: Offset: 191
WASM-NEXT: Name: linking
WASM-NEXT: }
WASM-NEXT: Section {
WASM-NEXT: Type: CUSTOM (0x0)
-WASM-NEXT: Size: 23
+WASM-NEXT: Size: 12
WASM-NEXT: Offset: 262
WASM-NEXT: Name: reloc.CODE
WASM-NEXT: }
Modified: llvm/trunk/tools/yaml2obj/yaml2wasm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2wasm.cpp?rev=329947&r1=329946&r2=329947&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2wasm.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2wasm.cpp Thu Apr 12 13:31:12 2018
@@ -240,6 +240,7 @@ int WasmWriter::writeSectionContent(raw_
if (auto Err = writeSectionContent(OS, *S))
return Err;
} else {
+ writeStringRef(Section.Name, OS);
Section.Payload.writeAsBinary(OS);
}
return 0;
More information about the llvm-commits
mailing list