1## Check we are able to set custom sh_size field 2## for different sections. 3 4# RUN: yaml2obj --docnum=1 %s -o %t1 5# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1 6 7# CASE1: Section Headers: 8# CASE1-NEXT: [Nr] Name Type Address Off Size 9# CASE1-NEXT: [ 0] NULL 0000000000000000 000000 000000 10# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000001 11# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000058 000002 12# CASE1-NEXT: [ 3] .dynamic DYNAMIC 0000000000000000 000070 000003 13# CASE1-NEXT: [ 4] .rela RELA 0000000000000000 000070 000004 14# CASE1-NEXT: [ 5] .nobits NOBITS 0000000000000000 000070 000005 15# CASE1-NEXT: [ 6] .group GROUP 0000000000000000 000070 000006 16# CASE1-NEXT: [ 7] .gnu.version VERSYM 0000000000000000 000070 000007 17# CASE1-NEXT: [ 8] .gnu.version_r VERNEED 0000000000000000 000070 000008 18# CASE1-NEXT: [ 9] .gnu.version_d VERDEF 0000000000000000 000070 000009 19# CASE1-NEXT: [10] .regular PROGBITS 0000000000000000 000070 00000a 20# CASE1-NEXT: [11] .strtab STRTAB 0000000000000000 000070 00000b 21 22--- !ELF 23FileHeader: 24 Class: ELFCLASS64 25 Data: ELFDATA2LSB 26 Type: ET_REL 27Sections: 28 - Name: .dynsym 29 Type: SHT_DYNSYM 30 ShSize: 0x000000001 31 - Name: .symtab 32 Type: SHT_SYMTAB 33 ShSize: 0x000000002 34 - Name: .dynamic 35 Type: SHT_DYNAMIC 36 ShSize: 0x000000003 37 - Name: .rela 38 Type: SHT_RELA 39 ShSize: 0x000000004 40 - Name: .nobits 41 Type: SHT_NOBITS 42 ShSize: 0x000000005 43 - Name: .group 44 Type: SHT_GROUP 45 ShSize: 0x000000006 46 Members: 47 - Name: .gnu.version 48 Type: SHT_GNU_versym 49 Entries: [ ] 50 ShSize: 0x000000007 51 - Name: .gnu.version_r 52 Type: SHT_GNU_verneed 53 Info: 0x0000000000000001 54 ShSize: 0x000000008 55 Dependencies: 56 - Name: .gnu.version_d 57 Type: SHT_GNU_verdef 58 Info: 0x0000000000000001 59 ShSize: 0x000000009 60 Entries: 61 - Name: .regular 62 Type: SHT_PROGBITS 63 ShSize: 0x00000000A 64 - Name: .strtab 65 Type: SHT_STRTAB 66 ShSize: 0x00000000B 67 68## Here we check that defining ShSize does not actually change 69## the content and also does not affect file size. 70 71# RUN: yaml2obj --docnum=2 %s -o %t2 72# RUN: yaml2obj --docnum=3 %s -o %t3 73# RUN: od -t x1 -v %t2 > %t.txt 74# RUN: od -t x1 -v %t3 >> %t.txt 75# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2 76 77# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe 78# CASE2: [[FILESIZE:.*]]{{$}} 79# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe 80# CASE2: [[FILESIZE]]{{$}} 81 82--- !ELF 83FileHeader: 84 Class: ELFCLASS64 85 Data: ELFDATA2LSB 86 Type: ET_REL 87Sections: 88 - Name: .foo 89 Type: SHT_PROGBITS 90 Content: "fefefefefefefefe" 91 92--- !ELF 93FileHeader: 94 Class: ELFCLASS64 95 Data: ELFDATA2LSB 96 Type: ET_REL 97Sections: 98 - Name: .foo 99 Type: SHT_PROGBITS 100 ShSize: 1 101 Content: "fefefefefefefefe" 102 103## Check we can define sh_size larger than section content size 104## and thus create overlaping sections. 105 106# RUN: yaml2obj --docnum=4 %s -o %t4 107# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4 108 109# CASE4: Name: .foo 110# CASE4: SectionData ( 111# CASE4-NEXT: 0000: AAAABBBB |....| 112# CASE4: Name: .bar 113# CASE4: SectionData ( 114# CASE4-NEXT: 0000: BBBB |..| 115 116--- !ELF 117FileHeader: 118 Class: ELFCLASS64 119 Data: ELFDATA2LSB 120 Type: ET_REL 121Sections: 122 - Name: .foo 123 Type: SHT_PROGBITS 124 Content: "aaaa" 125 ShSize: 4 126 - Name: .bar 127 Type: SHT_PROGBITS 128 Content: "bbbb" 129 130## Check we can set both Size and ShSize and the number of the actual 131## bytes written is equal to Size in this case. 132 133# RUN: yaml2obj --docnum=5 %s -o %t5 134# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5 135 136# CASE5: aa aa 00 00 bb bb 137 138--- !ELF 139FileHeader: 140 Class: ELFCLASS64 141 Data: ELFDATA2LSB 142 Type: ET_REL 143Sections: 144 - Name: .foo 145 Type: SHT_PROGBITS 146 Content: "aaaa" 147 - Name: .bar 148 Type: SHT_PROGBITS 149 Size: 2 150 ShSize: 4 151 - Name: .zed 152 Type: SHT_PROGBITS 153 Content: "bbbb" 154