Skip to content

Commit 1052132

Browse files
committed
Allow "[[FLAGS=<none>]]" value in ELF Fileheader Flags
1 parent d876dd4 commit 1052132

28 files changed

+5
-71
lines changed

llvm/include/llvm/ObjectYAML/ELFYAML.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct FileHeader {
117117
llvm::yaml::Hex8 ABIVersion;
118118
ELF_ET Type;
119119
std::optional<ELF_EM> Machine;
120-
std::optional<ELF_EF> Flags;
120+
ELF_EF Flags;
121121
llvm::yaml::Hex64 Entry;
122122
std::optional<StringRef> SectionHeaderStringTable;
123123

llvm/lib/ObjectYAML/ELFEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ void ELFState<ELFT>::writeELFHeader(raw_ostream &OS) {
482482
Header.e_version = EV_CURRENT;
483483
Header.e_entry = Doc.Header.Entry;
484484
if (Doc.Header.Flags)
485-
Header.e_flags = *Doc.Header.Flags;
485+
Header.e_flags = Doc.Header.Flags;
486486
else
487487
Header.e_flags = 0;
488488
Header.e_ehsize = sizeof(Elf_Ehdr);

llvm/lib/ObjectYAML/ELFYAML.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
11581158
IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0));
11591159
IO.mapRequired("Type", FileHdr.Type);
11601160
IO.mapOptional("Machine", FileHdr.Machine);
1161-
IO.mapOptional("Flags", FileHdr.Flags);
1161+
IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
11621162
IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
11631163
IO.mapOptional("SectionHeaderStringTable", FileHdr.SectionHeaderStringTable);
11641164

llvm/test/Object/obj2yaml.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@
556556
# ELF-X86-64-NEXT: OSABI: ELFOSABI_GNU
557557
# ELF-X86-64-NEXT: Type: ET_REL
558558
# ELF-X86-64-NEXT: Machine: EM_X86_64
559-
# ELF-X86-64-NEXT: Flags: [ ]
560559
# ELF-X86-64-NEXT: Sections:
561560
# ELF-X86-64-NEXT: - Name: .text
562561
# ELF-X86-64-NEXT: Type: SHT_PROGBITS

llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# and DWO output.
33
# Note that we don't actually need any DWARF to produce the DWO file.
44

5-
# RUN: yaml2obj -DMACHINE=EM_NONE %s -o %t.o
6-
# RUN: yaml2obj -DMACHINE=EM_AMDGPU -DFLAGS=[EF_AMDGPU_MACH_AMDGCN_GFX900] %s -o %t-amdgpu.o
5+
# RUN: yaml2obj %s -o %t.o
76

87
# Without --output-format, the format should match the input.
98
# RUN: llvm-objcopy %t.o %t.default.o --split-dwo=%t.default.dwo
@@ -122,19 +121,12 @@
122121
# RUN: llvm-readobj --file-headers %t.elf64_s390.o | FileCheck %s --check-prefixes=CHECK,BE,S390X,64,SYSV
123122
# RUN: llvm-readobj --file-headers %t.elf64_s390.dwo | FileCheck %s --check-prefixes=CHECK,BE,S390X,64,SYSV
124123

125-
126-
# RUN: llvm-objcopy %t-amdgpu.o -O elf64-amdgpu %t-amdgpu.elf64_amdgpu.o --split-dwo=%t-amdgpu.elf64_amdgpu.dwo
127-
# RUN: llvm-readobj --file-headers %t-amdgpu.elf64_amdgpu.o | FileCheck %s --check-prefixes=CHECK,LE,AMDGPU,64,SYSV
128-
# RUN: llvm-readobj --file-headers %t-amdgpu.elf64_amdgpu.dwo | FileCheck %s --check-prefixes=CHECK,LE,AMDGPU,64,SYSV
129-
130124
!ELF
131125
FileHeader:
132126
Class: ELFCLASS32
133127
Data: ELFDATA2LSB
134128
Type: ET_EXEC
135129
# Arbitrary values that do not match any value we convert to via --output-format.
136-
Machine: [[MACHINE]]
137-
Flags: [[FLAGS=<none>]]
138130
OSABI: ELFOSABI_STANDALONE
139131
Sections:
140132
- Name: .text
@@ -161,7 +153,6 @@ Symbols:
161153
# I386-SAME: i386
162154
# IAMCU-SAME: iamcu
163155
# AARCH-SAME: aarch64
164-
# AMDGPU-SAME: amdgpu
165156
# ARM-SAME: littlearm
166157
# HEXAGON-SAME: hexagon
167158
# LA32-SAME: loongarch{{$}}
@@ -179,7 +170,6 @@ Symbols:
179170
# I386-NEXT: Arch: i386
180171
# IAMCU-NEXT: Arch: i386
181172
# AARCH-NEXT: Arch: aarch64
182-
# AMDGPU-NEXT: Arch: amdgcn
183173
# ARM-NEXT: Arch: arm
184174
# HEXAGON-NEXT: Arch: hexagon
185175
# LA32-NEXT: Arch: loongarch32
@@ -213,7 +203,6 @@ Symbols:
213203
# DEFAULT: OS/ABI: Standalone (0xFF)
214204

215205
# AARCH: Machine: EM_AARCH64 (0xB7)
216-
# AMDGPU: Machine: EM_AMDGPU (0xE0)
217206
# ARM: Machine: EM_ARM (0x28)
218207
# HEXAGON: Machine: EM_HEXAGON (0xA4)
219208
# I386: Machine: EM_386 (0x3)

llvm/test/tools/obj2yaml/ELF/bb-addr-map-pgo-analysis-map.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# VALID-NEXT: Class: ELFCLASS64
1111
# VALID-NEXT: Data: ELFDATA2LSB
1212
# VALID-NEXT: Type: ET_EXEC
13-
# VALID-NEXT: Flags: [ ]
1413
# VALID-NEXT: Sections:
1514
# VALID-NEXT: - Name: .llvm_bb_addr_map
1615
# VALID-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -123,7 +122,6 @@ Sections:
123122
# MULTI-NEXT: Class: ELFCLASS64
124123
# MULTI-NEXT: Data: ELFDATA2LSB
125124
# MULTI-NEXT: Type: ET_EXEC
126-
# MULTI-NEXT: Flags: [ ]
127125
# MULTI-NEXT: Sections:
128126
# MULTI-NEXT: - Name: .llvm_bb_addr_map
129127
# MULTI-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -196,7 +194,6 @@ Sections:
196194
# INVALID-NEXT: Class: ELFCLASS64
197195
# INVALID-NEXT: Data: ELFDATA2LSB
198196
# INVALID-NEXT: Type: ET_EXEC
199-
# INVALID-NEXT: Flags: [ ]
200197
# INVALID-NEXT: Sections:
201198
# INVALID-NEXT: - Name: .llvm_bb_addr_map
202199
# INVALID-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -228,7 +225,6 @@ Sections:
228225
# MISSING-FEC-NEXT: Class: ELFCLASS64
229226
# MISSING-FEC-NEXT: Data: ELFDATA2LSB
230227
# MISSING-FEC-NEXT: Type: ET_EXEC
231-
# MISSING-FEC-NEXT: Flags: [ ]
232228
# MISSING-FEC-NEXT: Sections:
233229
# MISSING-FEC-NEXT: - Name: .llvm_bb_addr_map
234230
# MISSING-FEC-NEXT: Type: SHT_LLVM_BB_ADDR_MAP

llvm/test/tools/obj2yaml/ELF/bb-addr-map.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# VALID-NEXT: Class: ELFCLASS64
1111
# VALID-NEXT: Data: ELFDATA2LSB
1212
# VALID-NEXT: Type: ET_EXEC
13-
# VALID-NEXT: Flags: [ ]
1413
# VALID-NEXT: Sections:
1514
# VALID-NEXT: - Name: .llvm_bb_addr_map
1615
# VALID-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -90,7 +89,6 @@ Sections:
9089
# EMPTY-NEXT: Class: ELFCLASS64
9190
# EMPTY-NEXT: Data: ELFDATA2LSB
9291
# EMPTY-NEXT: Type: ET_EXEC
93-
# EMPTY-NEXT: Flags: [ ]
9492
# EMPTY-NEXT: Sections:
9593
# EMPTY-NEXT: - Name: .llvm_bb_addr_map
9694
# EMPTY-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -116,7 +114,6 @@ Sections:
116114
# MULTI-NEXT: Class: ELFCLASS64
117115
# MULTI-NEXT: Data: ELFDATA2LSB
118116
# MULTI-NEXT: Type: ET_EXEC
119-
# MULTI-NEXT: Flags: [ ]
120117
# MULTI-NEXT: Sections:
121118
# MULTI-NEXT: - Name: .llvm_bb_addr_map
122119
# MULTI-NEXT: Type: SHT_LLVM_BB_ADDR_MAP
@@ -181,7 +178,6 @@ Sections:
181178
# INVALID-NEXT: Class: ELFCLASS64
182179
# INVALID-NEXT: Data: ELFDATA2LSB
183180
# INVALID-NEXT: Type: ET_EXEC
184-
# INVALID-NEXT: Flags: [ ]
185181
# INVALID-NEXT: Sections:
186182
# INVALID-NEXT: - Name: .llvm_bb_addr_map
187183
# INVALID-NEXT: Type: SHT_LLVM_BB_ADDR_MAP

llvm/test/tools/obj2yaml/ELF/call-graph-profile-section.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Symbols:
4545
# INVALID-NEXT: Class: ELFCLASS32
4646
# INVALID-NEXT: Data: ELFDATA2MSB
4747
# INVALID-NEXT: Type: ET_DYN
48-
# INVALID-NEXT: Flags: [ ]
4948
# INVALID-NEXT: Sections:
5049
# INVALID-NEXT: - Name: .empty
5150
# INVALID-NEXT: Type: SHT_LLVM_CALL_GRAPH_PROFILE

llvm/test/tools/obj2yaml/ELF/duplicate-symbol-and-section-names.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
# CASE1-NEXT: Class: ELFCLASS64
2828
# CASE1-NEXT: Data: ELFDATA2LSB
2929
# CASE1-NEXT: Type: ET_REL
30-
# CASE1-NEXT: Flags: [ ]
3130
# CASE1-NEXT: Sections:
3231
# CASE1-NEXT: - Name: .foo
3332
# CASE1-NEXT: Type: SHT_PROGBITS

llvm/test/tools/obj2yaml/ELF/emachine.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# CHECK-NEXT: Data: ELFDATA2MSB
1212
# CHECK-NEXT: Type: ET_REL
1313
# CHECK-NEXT: Machine: [[MACHINE]]
14-
# CHECK-NEXT: Flags: [ ]
1514

1615
--- !ELF
1716
FileHeader:
@@ -35,5 +34,4 @@ FileHeader:
3534
# DEFAULT-NEXT: Class: ELFCLASS64
3635
# DEFAULT-NEXT: Data: ELFDATA2MSB
3736
# DEFAULT-NEXT: Type: ET_REL
38-
# DEFAULT-NEXT: Flags: [ ]
3937
# DEFAULT-NEXT: ...

0 commit comments

Comments
 (0)