|
| 1 | +## Check how yaml2obj produces .stack_sizes sections. |
| 2 | + |
| 3 | +## Test the following cases when the .stack_sizes Content field is specified: |
| 4 | +## 1) We can produce a .stack_sizes section from a description with |
| 5 | +## a valid section content. |
| 6 | +## 2) We can produce an incorrect .stack_sizes section from a description with |
| 7 | +## a broken (truncated) section content. |
| 8 | +## 3) We can produce an empty .stack_sizes section from a description with |
| 9 | +## empty section content. |
| 10 | + |
| 11 | +# RUN: yaml2obj --docnum=1 %s -o %t1 |
| 12 | +# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s |
| 13 | + |
| 14 | +## Case 1: valid content. |
| 15 | +# CHECK: Section { |
| 16 | +# CHECK: Index: 1 |
| 17 | +# CHECK-NEXT: Name: .stack_sizes (1) |
| 18 | +# CHECK-NEXT: Type: SHT_PROGBITS (0x1) |
| 19 | +# CHECK-NEXT: Flags [ (0x0) |
| 20 | +# CHECK-NEXT: ] |
| 21 | +# CHECK-NEXT: Address: 0x0 |
| 22 | +# CHECK-NEXT: Offset: 0x40 |
| 23 | +# CHECK-NEXT: Size: 9 |
| 24 | +# CHECK-NEXT: Link: 0 |
| 25 | +# CHECK-NEXT: Info: 0 |
| 26 | +# CHECK-NEXT: AddressAlignment: 0 |
| 27 | +# CHECK-NEXT: EntrySize: 0 |
| 28 | +# CHECK-NEXT: SectionData ( |
| 29 | +# CHECK-NEXT: 0000: 10000000 00000000 20 |
| 30 | +# CHECK-NEXT: ) |
| 31 | +# CHECK-NEXT: } |
| 32 | + |
| 33 | +## Case 2: truncated content. |
| 34 | +# CHECK: Name: .stack_sizes |
| 35 | +# CHECK: Size: |
| 36 | +# CHECK-SAME: 8 |
| 37 | +# CHECK: SectionData ( |
| 38 | +# CHECK-NEXT: 0000: 10000000 00000000 |
| 39 | + |
| 40 | +## Case 3: empty content. |
| 41 | +# CHECK: Name: .stack_sizes |
| 42 | +# CHECK: Size: |
| 43 | +# CHECK-SAME: 0 |
| 44 | + |
| 45 | +--- !ELF |
| 46 | +FileHeader: |
| 47 | + Class: ELFCLASS64 |
| 48 | + Data: ELFDATA2LSB |
| 49 | + Type: ET_EXEC |
| 50 | + Machine: EM_X86_64 |
| 51 | +Sections: |
| 52 | +## Valid. |
| 53 | + - Name: '.stack_sizes [1]' |
| 54 | + Type: SHT_PROGBITS |
| 55 | + Content: "100000000000000020" |
| 56 | +## Truncated. |
| 57 | + - Name: '.stack_sizes [2]' |
| 58 | + Type: SHT_PROGBITS |
| 59 | + Content: "1000000000000000" |
| 60 | +## Empty. |
| 61 | + - Name: '.stack_sizes [3]' |
| 62 | + Type: SHT_PROGBITS |
| 63 | + Content: "" |
| 64 | + |
| 65 | +## Check we can describe .stack_sizes section using <address, size> pairs. |
| 66 | + |
| 67 | +# RUN: yaml2obj --docnum=2 %s -o %t2 |
| 68 | +# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=ENTRIES-LE64-BOTH |
| 69 | +# RUN: yaml2obj --docnum=3 %s -o %t3 |
| 70 | +# RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=ENTRIES-BE64-BOTH |
| 71 | +# RUN: yaml2obj --docnum=4 %s -o %t4 |
| 72 | +# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=ENTRIES-LE32-BOTH |
| 73 | +# RUN: yaml2obj --docnum=5 %s -o %t5 |
| 74 | +# RUN: llvm-readobj --sections --section-data %t5 | FileCheck %s --check-prefix=ENTRIES-BE32-BOTH |
| 75 | + |
| 76 | +# ENTRIES-LE64-BOTH: Name: .stack_sizes |
| 77 | +# ENTRIES-LE64-BOTH: SectionData ( |
| 78 | +# ENTRIES-LE64-BOTH-NEXT: 0000: 10000000 00000000 20300000 00000000 | |
| 79 | +# ENTRIES-LE64-BOTH-NEXT: 0010: 0040 | |
| 80 | + |
| 81 | +# ENTRIES-BE64-BOTH: Name: .stack_sizes |
| 82 | +# ENTRIES-BE64-BOTH: SectionData ( |
| 83 | +# ENTRIES-BE64-BOTH-NEXT: 0000: 00000000 00000010 20000000 00000000 | |
| 84 | +# ENTRIES-BE64-BOTH-NEXT: 0010: 3040 |
| 85 | + |
| 86 | +# ENTRIES-LE32-BOTH: Name: .stack_sizes |
| 87 | +# ENTRIES-LE32-BOTH: SectionData ( |
| 88 | +# ENTRIES-LE32-BOTH-NEXT: 0000: 10000000 20300000 0040 | |
| 89 | + |
| 90 | +# ENTRIES-BE32-BOTH: Name: .stack_sizes |
| 91 | +# ENTRIES-BE32-BOTH: SectionData ( |
| 92 | +# ENTRIES-BE32-BOTH-NEXT: 0000: 00000010 20000000 3040 | |
| 93 | + |
| 94 | +--- !ELF |
| 95 | +FileHeader: |
| 96 | + Class: ELFCLASS64 |
| 97 | + Data: ELFDATA2LSB |
| 98 | + Type: ET_EXEC |
| 99 | + Machine: EM_X86_64 |
| 100 | +Sections: |
| 101 | + - Name: .stack_sizes |
| 102 | + Type: SHT_PROGBITS |
| 103 | + Entries: |
| 104 | + - Address: 0x10 |
| 105 | + Size: 0x20 |
| 106 | + - Address: 0x30 |
| 107 | + Size: 0x40 |
| 108 | + |
| 109 | +--- !ELF |
| 110 | +FileHeader: |
| 111 | + Class: ELFCLASS64 |
| 112 | + Data: ELFDATA2MSB |
| 113 | + Type: ET_EXEC |
| 114 | + Machine: EM_X86_64 |
| 115 | +Sections: |
| 116 | + - Name: .stack_sizes |
| 117 | + Type: SHT_PROGBITS |
| 118 | + Entries: |
| 119 | + - Address: 0x10 |
| 120 | + Size: 0x20 |
| 121 | + - Address: 0x30 |
| 122 | + Size: 0x40 |
| 123 | + |
| 124 | +--- !ELF |
| 125 | +FileHeader: |
| 126 | + Class: ELFCLASS32 |
| 127 | + Data: ELFDATA2LSB |
| 128 | + Type: ET_EXEC |
| 129 | + Machine: EM_386 |
| 130 | +Sections: |
| 131 | + - Name: .stack_sizes |
| 132 | + Type: SHT_PROGBITS |
| 133 | + Entries: |
| 134 | + - Address: 0x10 |
| 135 | + Size: 0x20 |
| 136 | + - Address: 0x30 |
| 137 | + Size: 0x40 |
| 138 | + |
| 139 | +--- !ELF |
| 140 | +FileHeader: |
| 141 | + Class: ELFCLASS32 |
| 142 | + Data: ELFDATA2MSB |
| 143 | + Type: ET_EXEC |
| 144 | + Machine: EM_386 |
| 145 | +Sections: |
| 146 | + - Name: .stack_sizes |
| 147 | + Type: SHT_PROGBITS |
| 148 | + Entries: |
| 149 | + - Address: 0x10 |
| 150 | + Size: 0x20 |
| 151 | + - Address: 0x30 |
| 152 | + Size: 0x40 |
| 153 | + |
| 154 | +## Check we can omit the "Address" tag. In this case the address will be zero. |
| 155 | + |
| 156 | +# RUN: yaml2obj --docnum=6 %s -o %t6 |
| 157 | +# RUN: llvm-readobj --sections --section-data %t6 | FileCheck %s --check-prefix=ENTRIES-NOADDR |
| 158 | + |
| 159 | +# ENTRIES-NOADDR: Name: .stack_sizes |
| 160 | +# ENTRIES-NOADDR: SectionData ( |
| 161 | +# ENTRIES-NOADDR-NEXT: 0000: 00000000 00000000 10000000 00000000 | |
| 162 | +# ENTRIES-NOADDR-NEXT: 0010: 0020 | |
| 163 | + |
| 164 | +--- !ELF |
| 165 | +FileHeader: |
| 166 | + Class: ELFCLASS64 |
| 167 | + Data: ELFDATA2LSB |
| 168 | + Type: ET_EXEC |
| 169 | + Machine: EM_X86_64 |
| 170 | +Sections: |
| 171 | + - Name: .stack_sizes |
| 172 | + Type: SHT_PROGBITS |
| 173 | + Entries: |
| 174 | + - Size: 0x10 |
| 175 | + - Size: 0x20 |
| 176 | + |
| 177 | +## Check that "Size" tag is mandatory when we describe .stack_sizes using "Entries". |
| 178 | + |
| 179 | +# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-NOSIZE |
| 180 | + |
| 181 | +# ENTRIES-NOSIZE: error: missing required key 'Size' |
| 182 | + |
| 183 | +--- !ELF |
| 184 | +FileHeader: |
| 185 | + Class: ELFCLASS64 |
| 186 | + Data: ELFDATA2LSB |
| 187 | + Type: ET_EXEC |
| 188 | + Machine: EM_X86_64 |
| 189 | +Sections: |
| 190 | + - Name: .stack_sizes |
| 191 | + Type: SHT_PROGBITS |
| 192 | + Entries: |
| 193 | + - Address: 0x10 |
| 194 | + |
| 195 | +## Check we can't use both "Content" and "Entries" tags at the same time. |
| 196 | + |
| 197 | +# RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-CONTENT |
| 198 | + |
| 199 | +# ENTRIES-AND-CONTENT: error: .stack_sizes: Content and Entries cannot be used together |
| 200 | + |
| 201 | +--- !ELF |
| 202 | +FileHeader: |
| 203 | + Class: ELFCLASS64 |
| 204 | + Data: ELFDATA2LSB |
| 205 | + Type: ET_EXEC |
| 206 | + Machine: EM_X86_64 |
| 207 | +Sections: |
| 208 | + - Name: .stack_sizes |
| 209 | + Type: SHT_PROGBITS |
| 210 | + Content: "00" |
| 211 | + Entries: |
| 212 | + - Address: 0x10 |
| 213 | + Size: 0x20 |
| 214 | + |
| 215 | +## Check we must specify either "Content" or "Entries" tag when describing .stack_sizes. |
| 216 | + |
| 217 | +# RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=NO-TAGS |
| 218 | + |
| 219 | +# NO-TAGS: error: .stack_sizes: either Content or Entries tag must be specified |
| 220 | + |
| 221 | +--- !ELF |
| 222 | +FileHeader: |
| 223 | + Class: ELFCLASS64 |
| 224 | + Data: ELFDATA2LSB |
| 225 | + Type: ET_EXEC |
| 226 | + Machine: EM_X86_64 |
| 227 | +Sections: |
| 228 | + - Name: .stack_sizes |
| 229 | + Type: SHT_PROGBITS |
0 commit comments