11# # In this test case we check that we can override the default values for
2- # # e_shentsize, e_shoff, e_shnum and e_shstrndx fields in the YAML.
2+ # # ELF header fields in the YAML.
33
44# # First we check the default values.
55
66# RUN: yaml2obj %s -o %t-default
77# RUN: llvm-readelf --file-headers %t-default | FileCheck %s --check-prefix=DEFAULT
88
9- # DEFAULT: Start of section headers: 88 (bytes into file)
10- # DEFAULT: Size of section headers: 64 (bytes)
11- # DEFAULT: Number of section headers: 3
12- # DEFAULT: Section header string table index: 2
9+ # DEFAULT: Start of program headers: 64 (bytes into file)
10+ # DEFAULT: Start of section headers: 200 (bytes into file)
11+ # DEFAULT: Size of program headers: 56 (bytes)
12+ # DEFAULT: Number of program headers: 2
13+ # DEFAULT: Size of section headers: 64 (bytes)
14+ # DEFAULT: Number of section headers: 3
15+ # DEFAULT: Section header string table index: 2
1316
1417--- !ELF
1518FileHeader :
1619 Class : ELFCLASS64
1720 Data : ELFDATA2LSB
1821 Type : ET_REL
1922 Machine : EM_X86_64
23+ ProgramHeaders :
24+ - Type : PT_LOAD
25+ Sections : []
26+ - Type : PT_LOAD
27+ Sections : []
2028
2129# # Check we can override all default values using the same values
2230# # and that this does not change the output.
@@ -29,10 +37,18 @@ FileHeader:
2937 Data : ELFDATA2LSB
3038 Type : ET_REL
3139 Machine : EM_X86_64
32- SHEntSize : [[SHENTSIZE=64]]
33- SHOff : [[SHOFF=88]]
34- SHNum : [[SHNUM=3]]
35- SHStrNdx : [[SHSTRNDX=2]]
40+ SHEntSize : [[SHENTSIZE=64]]
41+ SHOff : [[SHOFF=200]]
42+ SHNum : [[SHNUM=3]]
43+ SHStrNdx : [[SHSTRNDX=2]]
44+ EPhOff : [[PHOFF=64]]
45+ EPhEntSize : [[PHENTSIZE=56]]
46+ EPhNum : [[PHNUM=2]]
47+ ProgramHeaders :
48+ - Type : PT_LOAD
49+ Sections : []
50+ - Type : PT_LOAD
51+ Sections : []
3652
3753# # Override different fields to check the output produced.
3854
@@ -63,3 +79,21 @@ FileHeader:
6379# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t-default | FileCheck %s --check-prefix=OLDSIZE
6480# NEWSIZE: 01
6581# OLDSIZE: 40
82+
83+ # # Override the e_phoff field.
84+ # RUN: yaml2obj --docnum=2 %s -DPHOFF=3 -o %t6
85+ # RUN: llvm-readelf --file-headers %t6 | FileCheck %s --check-prefix=PHOFF
86+
87+ # PHOFF: Start of program headers: 3 (bytes into file){{$}}
88+
89+ # # Override the e_phnum field.
90+ # RUN: yaml2obj --docnum=2 %s -DPHNUM=1 -o %t7
91+ # RUN: llvm-readelf --file-headers %t7 | FileCheck %s --check-prefix=PHNUM
92+
93+ # PHNUM: Number of program headers: 1{{$}}
94+
95+ # # Override the e_phentsize field.
96+ # RUN: yaml2obj --docnum=2 %s -DPHENTSIZE=1 -o %t8
97+ # RUN: not llvm-readelf --file-headers %t8 2>&1 | FileCheck %s --check-prefix=PHENTSIZE
98+
99+ # PHENTSIZE: invalid e_phentsize: 1{{$}}
0 commit comments