1## Check we are able to describe the content of a section 2## using the ContentArray key. 3 4## Check we are able to use ContentArray to create multi-line descriptions 5## of section contents with comments on the same line. 6# RUN: yaml2obj --docnum=1 %s -o %t1 7# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s 8 9# CHECK: Section { 10# CHECK: Index: 1 11# CHECK-NEXT: Name: .foo 12# CHECK-NEXT: Type: SHT_PROGBITS 13# CHECK-NEXT: Flags [ 14# CHECK-NEXT: ] 15# CHECK-NEXT: Address: 0x0 16# CHECK-NEXT: Offset: 0x40 17# CHECK-NEXT: Size: 16 18# CHECK-NEXT: Link: 0 19# CHECK-NEXT: Info: 0 20# CHECK-NEXT: AddressAlignment: 0 21# CHECK-NEXT: EntrySize: 0 22# CHECK-NEXT: SectionData ( 23# CHECK-NEXT: 0000: 11223344 55667788 99AABBCC DDEEFF00 24# CHECK-NEXT: ) 25# CHECK-NEXT: } 26 27--- !ELF 28FileHeader: 29 Class: ELFCLASS64 30 Data: ELFDATA2LSB 31 Type: ET_DYN 32Sections: 33 - Name: .foo 34 Type: SHT_PROGBITS 35 ContentArray: [ 0x11, 0x22, 0x33, 0x44, ## .long 11223344 36 0x55, 0x66, ## .short 5566. 37 0x77, ## .byte 0x77 38 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 ] ## .quad 0x8899aabbccddeeff00 39 40## Check we do not allow using 'Content' and 'ContentArray' at the same time. 41# RUN: not yaml2obj --docnum=2 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=BOTH 42# BOTH: error: Content and ContentArray can't be used together 43 44--- !ELF 45FileHeader: 46 Class: ELFCLASS64 47 Data: ELFDATA2LSB 48 Type: ET_DYN 49Sections: 50 - Name: .foo 51 Type: SHT_PROGBITS 52 Content: [ 0x0 ] 53 ContentArray: [ 0x1 ] 54 55## Check how the "Size" and the "ContentArray" keys can be used together. 56 57## Case A: check that we report an error when the the value of "Size" is less than the content size. 58# RUN: not yaml2obj --docnum=3 -DSIZE=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=SIZE-LESS 59# SIZE-LESS: error: Section size must be greater than or equal to the content size 60 61--- !ELF 62FileHeader: 63 Class: ELFCLASS64 64 Data: ELFDATA2LSB 65 Type: ET_DYN 66Sections: 67 - Name: .foo 68 Type: SHT_PROGBITS 69 ContentArray: [ 0x11, 0x22 ] 70 Size: [[SIZE]] 71 72## Case B: check we are able to produce an output when the value of "Size" is equal 73## to the content size. In this case the "Size" key has no effect. 74# RUN: yaml2obj --docnum=3 -DSIZE=2 %s -o %t3.eq 75# RUN: llvm-readobj --sections --section-data %t3.eq | FileCheck %s --check-prefix=SIZE-EQ 76 77# SIZE-EQ: Name: .foo 78# SIZE-EQ: SectionData ( 79# SIZE-EQ-NEXT: 0000: 1122 | 80# SIZE-EQ-NEXT: ) 81 82## Case C: check we are able to produce an output when the value of "Size" is greater 83## than the content size. In this case zeroes are added as padding after the 84## specified content. 85# RUN: yaml2obj --docnum=3 -DSIZE=3 %s -o %t4.gr 86# RUN: llvm-readobj --sections --section-data %t4.gr | FileCheck %s --check-prefix=SIZE-GR 87 88# SIZE-GR: Name: .foo 89# SIZE-GR: SectionData ( 90# SIZE-GR-NEXT: 0000: 112200 | 91# SIZE-GR-NEXT: ) 92