[yaml2obj]Allow number for ELF symbol type

yaml2obj previously only recognised standard STT_* names, and didn't
allow arbitrary numbers. This change allows the user to specify a number
for the type instead. It also adds a test to verify the existing
behaviour for obj2yaml for unkown symbol types.

Reviewed by: grimar

Differential Revision: https://reviews.llvm.org/D57822

llvm-svn: 353315
This commit is contained in:
James Henderson 2019-02-06 17:16:33 +00:00
parent 33dbcbb2bc
commit c836e48841
3 changed files with 66 additions and 0 deletions

View File

@ -572,6 +572,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_STT>::enumeration(
ECase(STT_TLS);
ECase(STT_GNU_IFUNC);
#undef ECase
IO.enumFallback<Hex8>(Value);
}
void ScalarEnumerationTraits<ELFYAML::ELF_STV>::enumeration(

View File

@ -0,0 +1,22 @@
# RUN: yaml2obj %s > %t
# RUN: obj2yaml %t | FileCheck %s
# CHECK: Symbols:
# CHECK-NEXT: Global:
# CHECK-NEXT: - Name: a_known_type
# CHECK-NEXT: Type: STT_OBJECT
# CHECK-NEXT: - Name: an_unknown_type
# CHECK-NEXT: Type: 0x07
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Symbols:
Global:
- Name: a_known_type
Type: STT_OBJECT
- Name: an_unknown_type
Type: 0x7

View File

@ -0,0 +1,43 @@
# RUN: yaml2obj %s > %t
# RUN: llvm-readobj --symbols %t | FileCheck %s
# CHECK: Name: notype
# CHECK: Type: None
# CHECK: Name: normal_type
# CHECK: Type: Object
# CHECK: Name: .text
# CHECK: Type: Section
# CHECK: Name: known_hex
# CHECK: Type: Object
# CHECK: Name: unknown_hex
# CHECK: Type: 0xB
# CHECK: Name: known_int
# CHECK: Type: Object
# CHECK: Name: unknown_int
# CHECK: Type: 0xB
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Symbols:
Global:
- Name: notype
Type: STT_NOTYPE
- Name: normal_type
Type: STT_OBJECT
- Name: .text
Type: STT_SECTION
- Name: known_hex
Type: 0x1
- Name: unknown_hex
Type: 0xb
- Name: known_int
Type: 1
- Name: unknown_int
Type: 11