1## Evaluates the hex writer behavior with empty sections and segments.
2##
3## Show that the presence of an empty section placed at the same address of a
4## filled section doesn't affect the hex output. Also, show that the presence of
5## an empty section placed behind the filled section doesn't affect the hex
6## output. And, show that this happens regardless of the section ordering in the
7## section header table. (Two filled sections, and four empty sections, to
8## realize this test.)
9##
10## Then, show the same kind of behaviors for segments. (One filled section, four
11## empty sections, each in a single segment.)
12
13# RUN: yaml2obj %s -o %t
14# RUN: llvm-objcopy -O ihex %t - | FileCheck %s --implicit-check-not={{.}}
15
16## .data0 address
17# CHECK:         :02000004333394
18## .data0 offset, contents, checksum
19# CHECK-NEXT:    :020000000123DA
20
21## .data1 address
22# CHECK-NEXT:    :02000004444472
23## .data1 offset, contents, checksum
24# CHECK-NEXT:    :02000000456752
25
26## .data2 address
27# CHECK-NEXT:    :0200000477770C
28## .data2 offset, contents, checksum
29# CHECK-NEXT:    :0200000089ABCA
30
31## End of file
32# CHECK-NEXT:    :00000001FF
33
34--- !ELF
35FileHeader:
36  Class:           ELFCLASS32
37  Data:            ELFDATA2LSB
38  Type:            ET_EXEC
39  Machine:         EM_ARM
40Sections:
41## An empty section that's placed at the same address as a populated section.
42## This won't be in the output. It also won't affect how the subsequent section
43## is written.
44  - Name:          .empty_at_data0
45    Type:          SHT_PROGBITS
46    Flags:         [ SHF_ALLOC ]
47    Address:       0x33330000
48    Size:          0
49## A section populated with data. This is in the output.
50  - Name:          .data0
51    Type:          SHT_PROGBITS
52    Flags:         [ SHF_ALLOC ]
53    Address:       0x33330000
54    Content:       "0123"
55## An empty section that's placed at the end of .data0. This won't be in the
56## output.
57  - Name:          .empty_behind_data0
58    Type:          SHT_PROGBITS
59    Flags:         [ SHF_ALLOC ]
60    Address:       0x33330002
61    Size:          0
62## An empty section declared before .data1, but placed behind .data1. This
63## won't be in the output.
64  - Name:          .empty_behind_data1
65    Type:          SHT_PROGBITS
66    Flags:         [ SHF_ALLOC ]
67    Address:       0x44440002
68    Size:          0
69## A section populated with data. This is in the output.
70  - Name:          .data1
71    Type:          SHT_PROGBITS
72    Flags:         [ SHF_ALLOC ]
73    Address:       0x44440000
74    Content:       "4567"
75## An empty section declared after .data1, but placed at the start of .data1.
76## This won't be in the output.
77  - Name:          .empty_at_data1
78    Type:          SHT_PROGBITS
79    Flags:         [ SHF_ALLOC ]
80    Address:       0x44440000
81    Size:          0
82## An empty section that's isolated (by address) from all others. This won't be
83## in the output.
84  - Name:         .empty_isolated
85    Type:         SHT_PROGBITS
86    Flags:        [ SHF_ALLOC ]
87    Address:      0x7FFFFFFF
88    AddressAlign: 0x1
89    Size:         0
90## The sections below are placed into segments of varying configurations.
91## Populated section in its own segment. This is in the output.
92  - Name:          .data2
93    Type:          SHT_PROGBITS
94    Flags:         [ SHF_ALLOC ]
95    Address:       0x77770000
96    Content:       "89AB"
97## Empty section in its own segment. That segment is declared before the .data2
98## segment in the program headers, and placed at an address just behind .data2.
99## This won't be in the output.
100  - Name:          .empty0
101    Type:          SHT_PROGBITS
102    Flags:         [ SHF_ALLOC ]
103    Address:       0x88880000
104    Size:          0
105## Empty section in its own segment. That segment is declared before the .data2
106## segment in the program headers, and placed at the same address as .data2.
107## This won't be in the output.
108  - Name:          .empty1
109    Type:          SHT_PROGBITS
110    Flags:         [ SHF_ALLOC ]
111    Address:       0x99990000
112    Size:          0
113## Empty section in its own segment. That segment is declared after the .data2
114## segment in the program headers, and placed at the same address as .data2.
115## This won't be in the output.
116  - Name:          .empty2
117    Type:          SHT_PROGBITS
118    Flags:         [ SHF_ALLOC ]
119    Address:       0xAAAA0000
120    Size:          0
121## Empty section in its own segment. That segment is declared after the .data2
122## segment in the program headers, and placed at an address just behind .data2.
123## This won't be in the output.
124  - Name:          .empty3
125    Type:          SHT_PROGBITS
126    Flags:         [ SHF_ALLOC ]
127    Address:       0xBBBB0000
128    Size:          0
129ProgramHeaders:
130## .data0 sections, with empty bookends.
131  - Type:          PT_LOAD
132    Flags:         [ PF_R ]
133    PAddr:         0x33330000
134    VAddr:         0x33330000
135    FirstSec:      .empty_at_data0
136    LastSec:       .empty_behind_data0
137## .data1 sections, with empty bookends.
138  - Type:          PT_LOAD
139    Flags:         [ PF_R ]
140    PAddr:         0x44440000
141    VAddr:         0x44440000
142    FirstSec:      .empty_behind_data1
143    LastSec:       .empty_at_data1
144## .empty_isolated section.
145  - Type:          PT_LOAD
146    Flags:         [ PF_R ]
147    PAddr:         0x7FFFFFFF
148    VAddr:         0x7FFFFFFF
149    FirstSec:      .empty_isolated
150    LastSec:       .empty_isolated
151## Segments below include a single empty segment, and are positioned around
152## .data2 in various ways.  Declared before, placed behind .data2 segment.
153  - Type:          PT_LOAD
154    Flags:         [ PF_R ]
155    PAddr:         0x77770002
156    VAddr:         0x77770002
157    FirstSec:      .empty0
158    LastSec:       .empty0
159## Declared before, placed at .data2 segment.
160  - Type:          PT_LOAD
161    Flags:         [ PF_R ]
162    PAddr:         0x77770000
163    VAddr:         0x77770000
164    FirstSec:      .empty1
165    LastSec:       .empty1
166## Segment for .data2.
167  - Type:          PT_LOAD
168    Flags:         [ PF_R ]
169    PAddr:         0x77770000
170    VAddr:         0x77770000
171    FirstSec:      .data2
172    LastSec:       .data2
173## Declared after, placed at .data2 segment.
174  - Type:          PT_LOAD
175    Flags:         [ PF_R ]
176    PAddr:         0x77770000
177    VAddr:         0x77770000
178    FirstSec:      .empty2
179    LastSec:       .empty2
180## Declared after, placed behind .data2 segment.
181  - Type:          PT_LOAD
182    Flags:         [ PF_R ]
183    PAddr:         0x77770002
184    VAddr:         0x77770002
185    FirstSec:      .empty3
186    LastSec:       .empty3
187