| ## Test that obj2yaml output includes the section header size encoding length |
| ## only when the length isn't padded to 5 bytes. |
| # RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s |
| |
| --- !WASM |
| FileHeader: |
| Version: 0x1 |
| Sections: |
| - Type: TYPE |
| HeaderSecSizeEncodingLen: 3 |
| Signatures: |
| - Index: 0 |
| ParamTypes: |
| - I32 |
| - I32 |
| ReturnTypes: |
| - I32 |
| - Type: FUNCTION |
| HeaderSecSizeEncodingLen: 4 |
| FunctionTypes: [ 0 ] |
| - Type: MEMORY |
| HeaderSecSizeEncodingLen: 1 |
| Memories: |
| - Flags: [ HAS_MAX ] |
| Minimum: 0x100 |
| Maximum: 0x100 |
| - Type: EXPORT |
| HeaderSecSizeEncodingLen: 5 |
| Exports: |
| - Name: add |
| Kind: FUNCTION |
| Index: 0 |
| - Type: CODE |
| HeaderSecSizeEncodingLen: 2 |
| Functions: |
| - Index: 0 |
| Locals: [] |
| Body: 200020016A0B |
| ... |
| # CHECK: --- !WASM |
| # CHECK-NEXT: FileHeader: |
| # CHECK-NEXT: Version: 0x1 |
| # CHECK-NEXT: Sections: |
| # CHECK-NEXT: - Type: TYPE |
| # CHECK-NEXT: HeaderSecSizeEncodingLen: 3 |
| # CHECK-NEXT: Signatures: |
| # CHECK-NEXT: - Index: 0 |
| # CHECK-NEXT: ParamTypes: |
| # CHECK-NEXT: - I32 |
| # CHECK-NEXT: - I32 |
| # CHECK-NEXT: ReturnTypes: |
| # CHECK-NEXT: - I32 |
| # CHECK-NEXT: - Type: FUNCTION |
| # CHECK-NEXT: HeaderSecSizeEncodingLen: 4 |
| # CHECK-NEXT: FunctionTypes: [ 0 ] |
| # CHECK-NEXT: - Type: MEMORY |
| # CHECK-NEXT: Memories: |
| # CHECK-NEXT: - Flags: [ HAS_MAX ] |
| # CHECK-NEXT: Minimum: 0x100 |
| # CHECK-NEXT: Maximum: 0x100 |
| # CHECK-NEXT: - Type: EXPORT |
| # CHECK-NEXT: Exports: |
| # CHECK-NEXT: - Name: add |
| # CHECK-NEXT: Kind: FUNCTION |
| # CHECK-NEXT: Index: 0 |
| # CHECK-NEXT: - Type: CODE |
| # CHECK-NEXT: HeaderSecSizeEncodingLen: 2 |
| # CHECK-NEXT: Functions: |
| # CHECK-NEXT: - Index: 0 |
| # CHECK-NEXT: Locals: [] |
| # CHECK-NEXT: Body: 200020016A0B |
| |
| ## Test if we correctly error out if the provided section header size is less |
| ## than the size required. |
| # RUN: not yaml2obj --docnum=2 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=INVALID |
| # INVALID: yaml2obj: error: section header length can't be encoded in a LEB of size 0 |
| |
| --- !WASM |
| FileHeader: |
| Version: 0x1 |
| Sections: |
| - Type: TYPE |
| HeaderSecSizeEncodingLen: 0 |
| Signatures: |
| - Index: 0 |
| ParamTypes: |
| - I32 |
| - I32 |
| ReturnTypes: |
| - I32 |
| ... |