File: ihex-writer-empty-sections.test

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (186 lines) | stat: -rw-r--r-- 6,498 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
## Evaluates the hex writer behavior with empty sections and segments.
##
## Show that the presence of an empty section placed at the same address of a
## filled section doesn't affect the hex output. Also, show that the presence of
## an empty section placed behind the filled section doesn't affect the hex
## output. And, show that this happens regardless of the section ordering in the
## section header table. (Two filled sections, and four empty sections, to
## realize this test.)
##
## Then, show the same kind of behaviors for segments. (One filled section, four
## empty sections, each in a single segment.)

# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -O ihex %t - | FileCheck %s --implicit-check-not={{.}}

## .data0 address
# CHECK:         :02000004333394
## .data0 offset, contents, checksum
# CHECK-NEXT:    :020000000123DA

## .data1 address
# CHECK-NEXT:    :02000004444472
## .data1 offset, contents, checksum
# CHECK-NEXT:    :02000000456752

## .data2 address
# CHECK-NEXT:    :0200000477770C
## .data2 offset, contents, checksum
# CHECK-NEXT:    :0200000089ABCA

## End of file
# CHECK-NEXT:    :00000001FF

--- !ELF
FileHeader:
  Class:           ELFCLASS32
  Data:            ELFDATA2LSB
  Type:            ET_EXEC
  Machine:         EM_ARM
Sections:
## An empty section that's placed at the same address as a populated section.
## This won't be in the output. It also won't affect how the subsequent section
## is written.
  - Name:          .empty_at_data0
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x33330000
    Size:          0
## A section populated with data. This is in the output.
  - Name:          .data0
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x33330000
    Content:       "0123"
## An empty section that's placed at the end of .data0. This won't be in the
## output.
  - Name:          .empty_behind_data0
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x33330002
    Size:          0
## An empty section declared before .data1, but placed behind .data1. This
## won't be in the output.
  - Name:          .empty_behind_data1
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x44440002
    Size:          0
## A section populated with data. This is in the output.
  - Name:          .data1
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x44440000
    Content:       "4567"
## An empty section declared after .data1, but placed at the start of .data1.
## This won't be in the output.
  - Name:          .empty_at_data1
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x44440000
    Size:          0
## An empty section that's isolated (by address) from all others. This won't be
## in the output.
  - Name:         .empty_isolated
    Type:         SHT_PROGBITS
    Flags:        [ SHF_ALLOC ]
    Address:      0x7FFFFFFF
    AddressAlign: 0x1
    Size:         0
## The sections below are placed into segments of varying configurations.
## Populated section in its own segment. This is in the output.
  - Name:          .data2
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x77770000
    Content:       "89AB"
## Empty section in its own segment. That segment is declared before the .data2
## segment in the program headers, and placed at an address just behind .data2.
## This won't be in the output.
  - Name:          .empty0
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x88880000
    Size:          0
## Empty section in its own segment. That segment is declared before the .data2
## segment in the program headers, and placed at the same address as .data2.
## This won't be in the output.
  - Name:          .empty1
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0x99990000
    Size:          0
## Empty section in its own segment. That segment is declared after the .data2
## segment in the program headers, and placed at the same address as .data2.
## This won't be in the output.
  - Name:          .empty2
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0xAAAA0000
    Size:          0
## Empty section in its own segment. That segment is declared after the .data2
## segment in the program headers, and placed at an address just behind .data2.
## This won't be in the output.
  - Name:          .empty3
    Type:          SHT_PROGBITS
    Flags:         [ SHF_ALLOC ]
    Address:       0xBBBB0000
    Size:          0
ProgramHeaders:
## .data0 sections, with empty bookends.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x33330000
    VAddr:         0x33330000
    FirstSec:      .empty_at_data0
    LastSec:       .empty_behind_data0
## .data1 sections, with empty bookends.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x44440000
    VAddr:         0x44440000
    FirstSec:      .empty_behind_data1
    LastSec:       .empty_at_data1
## .empty_isolated section.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x7FFFFFFF
    VAddr:         0x7FFFFFFF
    FirstSec:      .empty_isolated
    LastSec:       .empty_isolated
## Segments below include a single empty segment, and are positioned around
## .data2 in various ways.  Declared before, placed behind .data2 segment.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x77770002
    VAddr:         0x77770002
    FirstSec:      .empty0
    LastSec:       .empty0
## Declared before, placed at .data2 segment.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x77770000
    VAddr:         0x77770000
    FirstSec:      .empty1
    LastSec:       .empty1
## Segment for .data2.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x77770000
    VAddr:         0x77770000
    FirstSec:      .data2
    LastSec:       .data2
## Declared after, placed at .data2 segment.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x77770000
    VAddr:         0x77770000
    FirstSec:      .empty2
    LastSec:       .empty2
## Declared after, placed behind .data2 segment.
  - Type:          PT_LOAD
    Flags:         [ PF_R ]
    PAddr:         0x77770002
    VAddr:         0x77770002
    FirstSec:      .empty3
    LastSec:       .empty3