152 lines · yaml
1## Check we are able to set custom sh_size field2## for different sections.3 4# RUN: yaml2obj --docnum=1 %s -o %t15# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE16 7# CASE1: Section Headers:8# CASE1-NEXT: [Nr] Name Type Address Off Size9# CASE1-NEXT: [ 0] NULL 0000000000000000 000000 00000010# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 00000111# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000058 00000212# CASE1-NEXT: [ 3] .dynamic DYNAMIC 0000000000000000 000070 00000313# CASE1-NEXT: [ 4] .rela RELA 0000000000000000 000070 00000414# CASE1-NEXT: [ 5] .nobits NOBITS 0000000000000000 000070 00000515# CASE1-NEXT: [ 6] .group GROUP 0000000000000000 000070 00000616# CASE1-NEXT: [ 7] .gnu.version VERSYM 0000000000000000 000070 00000717# CASE1-NEXT: [ 8] .gnu.version_r VERNEED 0000000000000000 000070 00000818# CASE1-NEXT: [ 9] .gnu.version_d VERDEF 0000000000000000 000070 00000919# CASE1-NEXT: [10] .regular PROGBITS 0000000000000000 000070 00000a20# CASE1-NEXT: [11] .strtab STRTAB 0000000000000000 000070 00000b21 22--- !ELF23FileHeader:24 Class: ELFCLASS6425 Data: ELFDATA2LSB26 Type: ET_REL27Sections:28 - Name: .dynsym29 Type: SHT_DYNSYM30 ShSize: 0x00000000131 - Name: .symtab32 Type: SHT_SYMTAB33 ShSize: 0x00000000234 - Name: .dynamic35 Type: SHT_DYNAMIC36 ShSize: 0x00000000337 - Name: .rela38 Type: SHT_RELA39 ShSize: 0x00000000440 - Name: .nobits41 Type: SHT_NOBITS42 ShSize: 0x00000000543 - Name: .group44 Type: SHT_GROUP45 ShSize: 0x00000000646 Members:47 - Name: .gnu.version48 Type: SHT_GNU_versym49 Entries: [ ]50 ShSize: 0x00000000751 - Name: .gnu.version_r52 Type: SHT_GNU_verneed53 ShSize: 0x00000000854 Dependencies:55 - Name: .gnu.version_d56 Type: SHT_GNU_verdef57 ShSize: 0x00000000958 Entries:59 - Name: .regular60 Type: SHT_PROGBITS61 ShSize: 0x00000000A62 - Name: .strtab63 Type: SHT_STRTAB64 ShSize: 0x00000000B65 66## Here we check that defining ShSize does not actually change67## the content and also does not affect file size.68 69# RUN: yaml2obj --docnum=2 %s -o %t270# RUN: yaml2obj --docnum=3 %s -o %t371# RUN: od -t x1 -v %t2 > %t.txt72# RUN: od -t x1 -v %t3 >> %t.txt73# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE274 75# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe76# CASE2: [[FILESIZE:.*]]{{$}}77# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe78# CASE2: [[FILESIZE]]{{$}}79 80--- !ELF81FileHeader:82 Class: ELFCLASS6483 Data: ELFDATA2LSB84 Type: ET_REL85Sections:86 - Name: .foo87 Type: SHT_PROGBITS88 Content: "fefefefefefefefe"89 90--- !ELF91FileHeader:92 Class: ELFCLASS6493 Data: ELFDATA2LSB94 Type: ET_REL95Sections:96 - Name: .foo97 Type: SHT_PROGBITS98 ShSize: 199 Content: "fefefefefefefefe"100 101## Check we can define sh_size larger than section content size102## and thus create overlaping sections.103 104# RUN: yaml2obj --docnum=4 %s -o %t4105# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4106 107# CASE4: Name: .foo108# CASE4: SectionData (109# CASE4-NEXT: 0000: AAAABBBB |....|110# CASE4: Name: .bar111# CASE4: SectionData (112# CASE4-NEXT: 0000: BBBB |..|113 114--- !ELF115FileHeader:116 Class: ELFCLASS64117 Data: ELFDATA2LSB118 Type: ET_REL119Sections:120 - Name: .foo121 Type: SHT_PROGBITS122 Content: "aaaa"123 ShSize: 4124 - Name: .bar125 Type: SHT_PROGBITS126 Content: "bbbb"127 128## Check we can set both Size and ShSize and the number of the actual129## bytes written is equal to Size in this case.130 131# RUN: yaml2obj --docnum=5 %s -o %t5132# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5133 134# CASE5: aa aa 00 00 bb bb135 136--- !ELF137FileHeader:138 Class: ELFCLASS64139 Data: ELFDATA2LSB140 Type: ET_REL141Sections:142 - Name: .foo143 Type: SHT_PROGBITS144 Content: "aaaa"145 - Name: .bar146 Type: SHT_PROGBITS147 Size: 2148 ShSize: 4149 - Name: .zed150 Type: SHT_PROGBITS151 Content: "bbbb"152