1## In this test case we check that we can override the default values for
2## ELF header fields in the YAML.
3
4## First we check the default values.
5
6# RUN: yaml2obj %s -o %t-default
7# RUN: llvm-readelf --file-headers %t-default | FileCheck %s --check-prefix=DEFAULT
8
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
16
17--- !ELF
18FileHeader:
19  Class: ELFCLASS64
20  Data:  ELFDATA2LSB
21  Type:  ET_REL
22ProgramHeaders:
23  - Type: PT_LOAD
24  - Type: PT_LOAD
25
26## Check we can override all default values using the same values
27## and that this does not change the output.
28# RUN: yaml2obj --docnum=2 %s -o %t-default-override
29# RUN: cmp %t-default %t-default-override
30
31--- !ELF
32FileHeader:
33  Class:      ELFCLASS64
34  Data:       ELFDATA2LSB
35  Type:       ET_REL
36  EShEntSize: [[SHENTSIZE=64]]
37  EShOff:     [[SHOFF=200]]
38  EShNum:     [[SHNUM=3]]
39  EShStrNdx:  [[SHSTRNDX=2]]
40  EPhOff:     [[PHOFF=64]]
41  EPhEntSize: [[PHENTSIZE=56]]
42  EPhNum:     [[PHNUM=2]]
43ProgramHeaders:
44  - Type: PT_LOAD
45  - Type: PT_LOAD
46
47## Override different fields to check the output produced.
48
49## Override the e_shoff field.
50# RUN: yaml2obj --docnum=2 %s -DSHOFF=3 -o %t2
51# RUN: llvm-readelf --file-headers %t2 | FileCheck %s --check-prefix=SHOFF
52
53# SHOFF: Start of section headers: 3 (bytes into file)
54
55## Override the e_shnum field.
56# RUN: yaml2obj --docnum=2 %s -DSHNUM=2 -o %t3
57# RUN: llvm-readelf --file-headers %t3 | FileCheck %s --check-prefix=SHNUM
58
59# SHNUM: Number of section headers: 2{{$}}
60
61## Override the e_shstrndx field.
62# RUN: yaml2obj --docnum=2 %s -DSHSTRNDX=4 -o %t4
63# RUN: llvm-readelf --file-headers %t4 | FileCheck %s --check-prefix=SHSTRNDX
64
65# SHSTRNDX: Section header string table index: 4{{$}}
66
67## Override the e_shentsize field.
68## Check the result using raw output from 'od' because llvm-readelf
69## is unable to dump such headers.
70
71# RUN: yaml2obj --docnum=2 %s -DSHENTSIZE=1 -o %t5
72# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t5 | FileCheck %s --check-prefix=NEWSIZE
73# RUN: od -A n -t x1 -v -j 0x3a -N 1 %t-default | FileCheck %s --check-prefix=OLDSIZE
74# NEWSIZE: 01
75# OLDSIZE: 40
76
77## Override the e_phoff field.
78# RUN: yaml2obj --docnum=2 %s -DPHOFF=3 -o %t6
79# RUN: llvm-readelf --file-headers %t6 | FileCheck %s --check-prefix=PHOFF
80
81# PHOFF: Start of program headers: 3 (bytes into file){{$}}
82
83## Override the e_phnum field.
84# RUN: yaml2obj --docnum=2 %s -DPHNUM=1 -o %t7
85# RUN: llvm-readelf --file-headers %t7 | FileCheck %s --check-prefix=PHNUM
86
87# PHNUM: Number of program headers: 1{{$}}
88
89## Override the e_phentsize field.
90# RUN: yaml2obj --docnum=2 %s -DPHENTSIZE=1 -o %t8
91# RUN: llvm-readelf --file-headers %t8 | FileCheck %s --check-prefix=PHENTSIZE
92
93# PHENTSIZE: Size of program headers: 1 (bytes)
94