1## Check we are able to set custom sh_offset 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 9# CASE1-NEXT: [ 0] NULL {{.*}} 000000 10# CASE1-NEXT: [ 1] .dynsym DYNSYM {{.*}} 000001 11# CASE1-NEXT: [ 2] .symtab SYMTAB {{.*}} 000002 12# CASE1-NEXT: [ 3] .dynamic DYNAMIC {{.*}} 000003 13# CASE1-NEXT: [ 4] .rela RELA {{.*}} 000004 14# CASE1-NEXT: [ 5] .nobits NOBITS {{.*}} 000005 15# CASE1-NEXT: [ 6] .group GROUP {{.*}} 000006 16# CASE1-NEXT: [ 7] .gnu.version VERSYM {{.*}} 000007 17# CASE1-NEXT: [ 8] .gnu.version_r VERNEED {{.*}} 000008 18# CASE1-NEXT: [ 9] .gnu.version_d VERDEF {{.*}} 000009 19# CASE1-NEXT: [10] .regular PROGBITS {{.*}} 00000a 20# CASE1-NEXT: [11] .strtab STRTAB {{.*}} 00000b 21 22--- !ELF 23FileHeader: 24 Class: ELFCLASS64 25 Data: ELFDATA2LSB 26 Type: ET_REL 27Sections: 28 - Name: .dynsym 29 Type: SHT_DYNSYM 30 ShOffset: 0x000000001 31 - Name: .symtab 32 Type: SHT_SYMTAB 33 ShOffset: 0x000000002 34 - Name: .dynamic 35 Type: SHT_DYNAMIC 36 ShOffset: 0x000000003 37 - Name: .rela 38 Type: SHT_RELA 39 ShOffset: 0x000000004 40 - Name: .nobits 41 Type: SHT_NOBITS 42 ShOffset: 0x000000005 43 - Name: .group 44 Type: SHT_GROUP 45 ShOffset: 0x000000006 46 Members: 47 - Name: .gnu.version 48 Type: SHT_GNU_versym 49 Entries: [ ] 50 ShOffset: 0x000000007 51 - Name: .gnu.version_r 52 Type: SHT_GNU_verneed 53 Info: 0x0000000000000001 54 ShOffset: 0x000000008 55 Dependencies: 56 - Name: .gnu.version_d 57 Type: SHT_GNU_verdef 58 Info: 0x0000000000000001 59 ShOffset: 0x000000009 60 Entries: 61 - Name: .regular 62 Type: SHT_PROGBITS 63 ShOffset: 0x00000000A 64 - Name: .strtab 65 Type: SHT_STRTAB 66 ShOffset: 0x00000000B 67 68## Here we check that defining ShOffset does not actually change 69## the offset at which section data is placed and also does 70## not affect file size. 71 72# RUN: yaml2obj --docnum=2 %s -o %t2 73# RUN: yaml2obj --docnum=3 %s -o %t3 74# RUN: od -t x1 -v %t2 > %t.txt 75# RUN: od -t x1 -v %t3 >> %t.txt 76# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2 77 78# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe 79# CASE2: [[FILESIZE:.*]]{{$}} 80# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe 81# CASE2: [[FILESIZE]]{{$}} 82 83--- !ELF 84FileHeader: 85 Class: ELFCLASS64 86 Data: ELFDATA2LSB 87 Type: ET_REL 88Sections: 89 - Name: .foo 90 Type: SHT_PROGBITS 91 Content: "fefefefefefefefe" 92 93--- !ELF 94FileHeader: 95 Class: ELFCLASS64 96 Data: ELFDATA2LSB 97 Type: ET_REL 98Sections: 99 - Name: .foo 100 Type: SHT_PROGBITS 101 ShOffset: 0xFFFF0000 102 Content: "fefefefefefefefe" 103