Skip to content

Commit d82914c

Browse files
committed
[yaml2obj][obj2yaml] Remove section type range markers from allowed mappings and support hex values
yaml2obj/obj2yaml previously supported SHT_LOOS, SHT_HIOS, and SHT_LOPROC for section types. These are simply values that delineate a range and don't really make sense as valid values. For example if a section has type value 0x70000000, obj2yaml shouldn't print this value as SHT_LOPROC. Additionally, this was missing the three other range markers (SHT_HIPROC, SHT_LOUSER and SHT_HIUSER). This change removes these three range markers. It also adds support for specifying the type as an integer, to allow section types that LLVM doesn't know about. Reviewed by: grimar Differential Revision: https://reviews.llvm.org/D58383 llvm-svn: 354344
1 parent d6add74 commit d82914c

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

llvm/lib/ObjectYAML/ELFYAML.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
446446
ECase(SHT_GROUP);
447447
ECase(SHT_SYMTAB_SHNDX);
448448
ECase(SHT_RELR);
449-
ECase(SHT_LOOS);
450449
ECase(SHT_ANDROID_REL);
451450
ECase(SHT_ANDROID_RELA);
452451
ECase(SHT_ANDROID_RELR);
@@ -459,8 +458,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
459458
ECase(SHT_GNU_verdef);
460459
ECase(SHT_GNU_verneed);
461460
ECase(SHT_GNU_versym);
462-
ECase(SHT_HIOS);
463-
ECase(SHT_LOPROC);
464461
switch (Object->Header.Machine) {
465462
case ELF::EM_ARM:
466463
ECase(SHT_ARM_EXIDX);
@@ -485,6 +482,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
485482
break;
486483
}
487484
#undef ECase
485+
IO.enumFallback<Hex32>(Value);
488486
}
489487

490488
void ScalarBitSetTraits<ELFYAML::ELF_PF>::bitset(IO &IO,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# RUN: yaml2obj %s -o %t
2+
# RUN: obj2yaml %t | FileCheck %s
3+
4+
# CHECK: Sections:
5+
# CHECK-NEXT: - Name: known_type
6+
# CHECK-NEXT: Type: SHT_PROGBITS
7+
# CHECK: - Name: unknown_type
8+
# CHECK-NEXT: Type: 0x0000ABCD
9+
# CHECK: - Name: machine_specific
10+
# CHECK-NEXT: Type: SHT_X86_64_UNWIND
11+
# CHECK: - Name: unknown_machine_specific
12+
# CHECK-NEXT: Type: 0x70000000
13+
14+
--- !ELF
15+
FileHeader:
16+
Class: ELFCLASS64
17+
Data: ELFDATA2LSB
18+
Type: ET_REL
19+
Machine: EM_X86_64
20+
Sections:
21+
- Name: known_type
22+
Type: SHT_PROGBITS
23+
- Name: unknown_type
24+
Type: 0xabcd
25+
- Name: machine_specific
26+
Type: SHT_X86_64_UNWIND
27+
- Name: unknown_machine_specific
28+
Type: 0x70000000
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RUN: yaml2obj %s -o %t
2+
# RUN: llvm-readobj --sections %t | FileCheck %s
3+
4+
# CHECK: Name: enum
5+
# CHECK: Type: SHT_PROGBITS
6+
# CHECK: Name: machine-specific
7+
# CHECK: Type: SHT_X86_64_UNWIND
8+
# CHECK: Name: hex
9+
# CHECK: Type: Unknown (0xABCD)
10+
# CHECK: Name: decimal
11+
# CHECK: Type: Unknown (0x4D2)
12+
13+
--- !ELF
14+
FileHeader:
15+
Class: ELFCLASS64
16+
Data: ELFDATA2LSB
17+
Type: ET_REL
18+
Machine: EM_X86_64
19+
Sections:
20+
- Name: enum
21+
Type: SHT_PROGBITS
22+
- Name: machine-specific
23+
Type: SHT_X86_64_UNWIND
24+
- Name: hex
25+
Type: 0xabcd
26+
- Name: decimal
27+
Type: 1234

0 commit comments

Comments
 (0)