1## For implicit symbol table sections, `Size` and/or `Content` fields can also 2## be specified in YAML. Here we test the behavior in different cases. 3 4## When no `Size` or `Content` is specified for a symbol table section, 5## yaml2obj writes the default content. 6 7# RUN: yaml2obj --docnum=1 %s -o %t1 8# RUN: llvm-readelf %t1 -s | FileCheck %s --check-prefix=CASE1 9 10# CASE1: Symbol table '.symtab' contains 2 entries: 11# CASE1-NEXT: Num: Value Size Type Bind Vis Ndx Name 12# CASE1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 13# CASE1-NEXT: 1: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND foo 14# CASE1-EMPTY: 15 16--- !ELF 17FileHeader: 18 Class: ELFCLASS64 19 Data: ELFDATA2LSB 20 Type: ET_DYN 21Sections: 22 - Name: .symtab 23 Type: SHT_SYMTAB 24Symbols: 25 - Name: foo 26 27## Specifying both `Size` and symbols at the same time is not allowed. 28# RUN: not yaml2obj --docnum=2 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2 29# RUN: not yaml2obj --docnum=3 %s -o %t2 2>&1 | FileCheck %s --check-prefix=CASE2 30 31# CASE2: error: cannot specify both `Size` and `Symbols` for symbol table section '.symtab' 32 33--- !ELF 34FileHeader: 35 Class: ELFCLASS64 36 Data: ELFDATA2LSB 37 Type: ET_DYN 38Sections: 39 - Name: .symtab 40 Type: SHT_SYMTAB 41 Size: 0x100 42Symbols: 43 - Name: foo 44 45--- !ELF 46FileHeader: 47 Class: ELFCLASS64 48 Data: ELFDATA2LSB 49 Type: ET_DYN 50Sections: 51 - Name: .symtab 52 Type: SHT_SYMTAB 53 Size: 0x100 54Symbols: [] 55 56## Specifying both `Content` and symbols at the same time is not allowed. 57# RUN: not yaml2obj --docnum=4 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3 58# RUN: not yaml2obj --docnum=5 %s -o %t3 2>&1 | FileCheck %s --check-prefix=CASE3 59 60# CASE3: error: cannot specify both `Content` and `Symbols` for symbol table section '.symtab' 61 62--- !ELF 63FileHeader: 64 Class: ELFCLASS64 65 Data: ELFDATA2LSB 66 Type: ET_DYN 67Sections: 68 - Name: .symtab 69 Type: SHT_SYMTAB 70 Content: "00" 71Symbols: 72 - Name: foo 73 74--- !ELF 75FileHeader: 76 Class: ELFCLASS64 77 Data: ELFDATA2LSB 78 Type: ET_DYN 79Sections: 80 - Name: .symtab 81 Type: SHT_SYMTAB 82 Content: "00" 83Symbols: [] 84 85## Check we can use just `Content` to emit custom data in the symbol table section. 86# RUN: yaml2obj --docnum=6 %s -o %t4 87# RUN: llvm-readobj --section-data -S %t4 | FileCheck %s --check-prefix=CASE4 88 89# CASE4: Name: .symtab 90# CASE4-NEXT: Type: SHT_SYMTAB 91# CASE4-NEXT: Flags [ (0x0) 92# CASE4-NEXT: ] 93# CASE4-NEXT: Address: 0x0 94# CASE4-NEXT: Offset: 0x40 95# CASE4-NEXT: Size: 2 96# CASE4-NEXT: Link: 2 97# CASE4-NEXT: Info: 1 98# CASE4-NEXT: AddressAlignment: 0 99# CASE4-NEXT: EntrySize: 24 100# CASE4-NEXT: SectionData ( 101# CASE4-NEXT: 0000: 0123 102# CASE4-NEXT: ) 103 104--- !ELF 105FileHeader: 106 Class: ELFCLASS64 107 Data: ELFDATA2LSB 108 Type: ET_DYN 109Sections: 110 - Name: .symtab 111 Type: SHT_SYMTAB 112 Content: "0123" 113 114## Check we can use just `Size` to emit custom data filled with zeroes 115## in the symbol table section. 116# RUN: yaml2obj --docnum=7 %s -o %t5 117# RUN: llvm-readobj --section-data -S %t5 | FileCheck %s --check-prefix=CASE5 118 119# CASE5: Name: .symtab (19) 120# CASE5-NEXT: Type: SHT_SYMTAB (0x2) 121# CASE5-NEXT: Flags [ (0x0) 122# CASE5-NEXT: ] 123# CASE5-NEXT: Address: 0x0 124# CASE5-NEXT: Offset: 0x40 125# CASE5-NEXT: Size: 5 126# CASE5-NEXT: Link: 2 127# CASE5-NEXT: Info: 1 128# CASE5-NEXT: AddressAlignment: 0 129# CASE5-NEXT: EntrySize: 24 130# CASE5-NEXT: SectionData ( 131# CASE5-NEXT: 0000: 00000000 00 132# CASE5-NEXT: ) 133 134--- !ELF 135FileHeader: 136 Class: ELFCLASS64 137 Data: ELFDATA2LSB 138 Type: ET_DYN 139Sections: 140 - Name: .symtab 141 Type: SHT_SYMTAB 142 Size: 5 143 144## Check we can specify both `Size` and `Content` when size is greater 145## than content size. In this case zeroes are added as padding 146## after the specified content. 147 148# RUN: yaml2obj --docnum=8 %s -o %t6 149# RUN: llvm-readobj %t6 --section-data -S | FileCheck %s --check-prefix=CASE6 150 151# CASE6: Name: .symtab 152# CASE6-NEXT: Type: SHT_SYMTAB 153# CASE6-NEXT: Flags [ 154# CASE6-NEXT: ] 155# CASE6-NEXT: Address: 0x0 156# CASE6-NEXT: Offset: 0x40 157# CASE6-NEXT: Size: 4 158# CASE6-NEXT: Link: 2 159# CASE6-NEXT: Info: 1 160# CASE6-NEXT: AddressAlignment: 0 161# CASE6-NEXT: EntrySize: 24 162# CASE6-NEXT: SectionData ( 163# CASE6-NEXT: 0000: 01230000 164# CASE6-NEXT: ) 165 166--- !ELF 167FileHeader: 168 Class: ELFCLASS64 169 Data: ELFDATA2LSB 170 Type: ET_DYN 171Sections: 172 - Name: .symtab 173 Type: SHT_SYMTAB 174 Content: "0123" 175 Size: 4 176 177## Check we can specify both `Size` and `Content` when size is 178## equal to content size. 179 180# RUN: yaml2obj --docnum=9 %s -o %t7 181# RUN: llvm-readobj --section-data -S %t7 | FileCheck %s --check-prefix=CASE7 182 183# CASE7: Name: .symtab 184# CASE7-NEXT: Type: SHT_SYMTAB 185# CASE7-NEXT: Flags [ 186# CASE7-NEXT: ] 187# CASE7-NEXT: Address: 0x0 188# CASE7-NEXT: Offset: 0x40 189# CASE7-NEXT: Size: 2 190# CASE7-NEXT: Link: 2 191# CASE7-NEXT: Info: 1 192# CASE7-NEXT: AddressAlignment: 0 193# CASE7-NEXT: EntrySize: 24 194# CASE7-NEXT: SectionData ( 195# CASE7-NEXT: 0000: 0123 196# CASE7-NEXT: ) 197 198--- !ELF 199FileHeader: 200 Class: ELFCLASS64 201 Data: ELFDATA2LSB 202 Type: ET_DYN 203Sections: 204 - Name: .symtab 205 Type: SHT_SYMTAB 206 Content: "0123" 207 Size: 2 208