llvm.org GIT mirror llvm / b068ce9
[WebAssembly] libObject: Don't include the name the size of custom sections Differential Revision: https://reviews.llvm.org/D45579 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329947 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 1 year, 4 months ago
6 changed file(s) with 14 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
177177 if (Ptr + Size > Eof)
178178 return make_error("Section too large",
179179 object_error::parse_failed);
180 if (Section.Type == wasm::WASM_SEC_CUSTOM) {
181 const uint8_t *NameStart = Ptr;
182 Section.Name = readString(Ptr);
183 Size -= Ptr - NameStart;
184 }
180185 Section.Content = ArrayRef(Ptr, Size);
181186 Ptr += Size;
182187 return Error::success();
617622
618623 Error WasmObjectFile::parseCustomSection(WasmSection &Sec,
619624 const uint8_t *Ptr, const uint8_t *End) {
620 Sec.Name = readString(Ptr);
621625 if (Sec.Name == "name") {
622626 if (Error Err = parseNameSection(Ptr, End))
623627 return Err;
1010
1111 ; CHECK: Section {
1212 ; CHECK: Type: CUSTOM (0x0)
13 ; CHECK: Size: 7
13 ; CHECK: Size: 3
1414 ; CHECK: Offset: 72
1515 ; CHECK: Name: red
1616 ; CHECK: }
1717 ; CHECK: Section {
1818 ; CHECK: Type: CUSTOM (0x0)
19 ; CHECK: Size: 12
19 ; CHECK: Size: 6
2020 ; CHECK: Offset: 85
2121 ; CHECK: Name: green
2222 ; CHECK: }
44 Sections:
55 - Type: CUSTOM
66 Name: foo
7 Payload: 03666F6F0401020304
7 Payload: '0401020304'
88 ...
99 # CHECK: --- !WASM
1010 # CHECK: FileHeader:
1212 # CHECK: Sections:
1313 # CHECK: - Type: CUSTOM
1414 # CHECK: Name: foo
15 # CHECK: Payload: 03666F6F0401020304
15 # CHECK: Payload: '0401020304'
1616 # CHECK: ...
66 # CHECK-NEXT: 2 FUNCTION 00000002 0000000000000000
77 # CHECK-NEXT: 3 CODE 00000019 0000000000000000 TEXT
88 # CHECK-NEXT: 4 DATA 0000001c 0000000000000000 DATA
9 # CHECK-NEXT: 5 linking 00000055 0000000000000000
10 # CHECK-NEXT: 6 reloc.CODE 00000017 0000000000000000
9 # CHECK-NEXT: 5 linking 0000004d 0000000000000000
10 # CHECK-NEXT: 6 reloc.CODE 0000000c 0000000000000000
1111
1212 # RUN: llvm-objdump -p %p/Inputs/trivial.obj.wasm | FileCheck %s -check-prefix CHECK-HEADER
1313
527527 WASM-NEXT: }
528528 WASM-NEXT: Section {
529529 WASM-NEXT: Type: CUSTOM (0x0)
530 WASM-NEXT: Size: 65
530 WASM-NEXT: Size: 57
531531 WASM-NEXT: Offset: 191
532532 WASM-NEXT: Name: linking
533533 WASM-NEXT: }
534534 WASM-NEXT: Section {
535535 WASM-NEXT: Type: CUSTOM (0x0)
536 WASM-NEXT: Size: 23
536 WASM-NEXT: Size: 12
537537 WASM-NEXT: Offset: 262
538538 WASM-NEXT: Name: reloc.CODE
539539 WASM-NEXT: }
239239 if (auto Err = writeSectionContent(OS, *S))
240240 return Err;
241241 } else {
242 writeStringRef(Section.Name, OS);
242243 Section.Payload.writeAsBinary(OS);
243244 }
244245 return 0;