brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 35aa547 Raw
172 lines · yaml
1## For regular sections, it is common to specify `Size` and/or `Content` fields in YAML.2## Here we test the behavior in different cases.3 4## In this case, we have both `Content` and `Size` fields specified and `Size`5## is less than content size. Check we report an error.6 7# RUN: not yaml2obj --docnum=1 %s -o %t1 2>&1 | FileCheck %s --check-prefix=ERR8# ERR: error: Section size must be greater than or equal to the content size9 10--- !ELF11FileHeader:12  Class: ELFCLASS6413  Data:  ELFDATA2LSB14  Type:  ET_DYN15Sections:16  - Name:    .foo17    Type:    SHT_PROGBITS18    Content: "FF"19    Size:    020 21## In this case, we have both `Content` and `Size` fields specified and22## `Size` is equal to the content size. We check that this is allowed and23## that the output section has a correct size value.24 25# RUN: yaml2obj --docnum=2 %s -o %t226# RUN: llvm-readobj --section-data -S %t2 | FileCheck %s --check-prefix=CASE227 28# CASE2:      Name: .foo29# CASE2-NEXT: Type: SHT_PROGBITS30# CASE2-NEXT: Flags [31# CASE2-NEXT: ]32# CASE2-NEXT: Address: 0x033# CASE2-NEXT: Offset: 0x4034# CASE2-NEXT: Size: 135# CASE2-NEXT: Link: 036# CASE2-NEXT: Info: 037# CASE2-NEXT: AddressAlignment: 038# CASE2-NEXT: EntrySize: 039# CASE2-NEXT: SectionData (40# CASE2-NEXT:   0000: FF41# CASE2-NEXT: )42 43--- !ELF44FileHeader:45  Class: ELFCLASS6446  Data:  ELFDATA2LSB47  Type:  ET_DYN48Sections:49  - Name:    .foo50    Type:    SHT_PROGBITS51    Content: "FF"52    Size:    153 54## Check we can specify only `Content`.55 56# RUN: yaml2obj --docnum=3 %s -o %t357# RUN: llvm-readobj --section-data -S %t3 | FileCheck %s --check-prefix=CASE258 59--- !ELF60FileHeader:61  Class: ELFCLASS6462  Data:  ELFDATA2LSB63  Type:  ET_DYN64Sections:65  - Name:    .foo66    Type:    SHT_PROGBITS67    Content: "FF"68 69## Check we can specify only `Size`.70 71# RUN: yaml2obj --docnum=4 %s -o %t472# RUN: llvm-readobj --section-data -S %t4 | FileCheck %s --check-prefix=CASE373 74# CASE3:      Name: .foo75# CASE3-NEXT: Type: SHT_PROGBITS76# CASE3-NEXT: Flags [77# CASE3-NEXT: ]78# CASE3-NEXT: Address: 0x079# CASE3-NEXT: Offset: 0x4080# CASE3-NEXT: Size: 181# CASE3-NEXT: Link: 082# CASE3-NEXT: Info: 083# CASE3-NEXT: AddressAlignment: 084# CASE3-NEXT: EntrySize: 085# CASE3-NEXT: SectionData (86# CASE3-NEXT:   0000: 0087# CASE3-NEXT: )88 89--- !ELF90FileHeader:91  Class: ELFCLASS6492  Data:  ELFDATA2LSB93  Type:  ET_DYN94Sections:95  - Name: .foo96    Type: SHT_PROGBITS97    Size: 198 99## Check we can specify both `Size` and `Content` when size is greater100## than content size. In this case zeroes are added as padding101## after the specified content.102 103# RUN: yaml2obj --docnum=5 %s -o %t5104# RUN: llvm-readobj --section-data -S %t5 | FileCheck %s --check-prefix=CASE4105 106# CASE4:      Name: .foo107# CASE4-NEXT: Type: SHT_PROGBITS108# CASE4-NEXT: Flags [109# CASE4-NEXT: ]110# CASE4-NEXT: Address: 0x0111# CASE4-NEXT: Offset: 0x40112# CASE4-NEXT: Size: 3113# CASE4-NEXT: Link: 0114# CASE4-NEXT: Info: 0115# CASE4-NEXT: AddressAlignment: 0116# CASE4-NEXT: EntrySize: 0117# CASE4-NEXT: SectionData (118# CASE4-NEXT:   0000: FF0000119# CASE4-NEXT: )120 121--- !ELF122FileHeader:123  Class: ELFCLASS64124  Data:  ELFDATA2LSB125  Type:  ET_DYN126Sections:127  - Name:    .foo128    Type:    SHT_PROGBITS129    Content: "FF"130    Size:    3131 132## Check we emit an empty section if neither 'Content' nor 'Size' were set.133 134# RUN: yaml2obj --docnum=6 %s -o %t6135# RUN: llvm-readobj %t6 --sections | FileCheck %s --check-prefix=CASE5136 137# CASE5:      Name: .foo138# CASE5-NEXT: Type: SHT_PROGBITS139# CASE5-NEXT: Flags [140# CASE5-NEXT: ]141# CASE5-NEXT: Address: 0x0142# CASE5-NEXT: Offset: 0x40143# CASE5-NEXT: Size: 0144 145--- !ELF146FileHeader:147  Class: ELFCLASS64148  Data:  ELFDATA2LSB149  Type:  ET_DYN150Sections:151  - Name: .foo152    Type: SHT_PROGBITS153 154# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERR2155 156--- !ELF157FileHeader:158  Class: ELFCLASS64159  Data:  ELFDATA2LSB160  Type:  ET_REL161Sections:162  - Name: .data163    Type: SHT_PROGBITS164    Flags: [ SHF_ALLOC ]165    Content: 0000000000000000166    Size: 2167 168# ERR2:      error: Section size must be greater than or equal to the content size169# ERR2-NEXT: - Name: .data170# ERR2-NEXT:   ^171# ERR2-NEXT: error: failed to parse YAML input172