[ELFYAML] Group ELF section type flags to target specific blocks.

Recognize only flags which correspond to the current target.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2014-07-12 18:25:08 +00:00
parent 452bd5f9c6
commit dafce2c9a6
3 changed files with 31 additions and 9 deletions

View File

@ -298,6 +298,8 @@ void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
IO &IO, ELFYAML::ELF_SHT &Value) {
const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
assert(Object && "The IO context is not initialized");
#define ECase(X) IO.enumCase(Value, #X, ELF::X);
ECase(SHT_NULL)
ECase(SHT_PROGBITS)
@ -325,15 +327,27 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
ECase(SHT_GNU_versym)
ECase(SHT_HIOS)
ECase(SHT_LOPROC)
ECase(SHT_ARM_EXIDX)
ECase(SHT_ARM_PREEMPTMAP)
ECase(SHT_ARM_ATTRIBUTES)
ECase(SHT_ARM_DEBUGOVERLAY)
ECase(SHT_ARM_OVERLAYSECTION)
ECase(SHT_HEX_ORDERED)
ECase(SHT_X86_64_UNWIND)
ECase(SHT_MIPS_REGINFO)
ECase(SHT_MIPS_OPTIONS)
switch (Object->Header.Machine) {
case ELF::EM_ARM:
ECase(SHT_ARM_EXIDX)
ECase(SHT_ARM_PREEMPTMAP)
ECase(SHT_ARM_ATTRIBUTES)
ECase(SHT_ARM_DEBUGOVERLAY)
ECase(SHT_ARM_OVERLAYSECTION)
break;
case ELF::EM_HEXAGON:
ECase(SHT_HEX_ORDERED)
break;
case ELF::EM_X86_64:
ECase(SHT_X86_64_UNWIND)
break;
case ELF::EM_MIPS:
ECase(SHT_MIPS_REGINFO)
ECase(SHT_MIPS_OPTIONS)
default:
// Nothing to do.
break;
}
#undef ECase
}

Binary file not shown.

View File

@ -3,6 +3,8 @@ RUN: obj2yaml %p/Inputs/trivial-object-test.coff-x86-64 | FileCheck %s --check-p
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mipsel | FileCheck %s --check-prefix ELF-MIPSEL
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-mips64el | FileCheck %s --check-prefix ELF-MIPS64EL
RUN: obj2yaml %p/Inputs/trivial-object-test.elf-x86-64 | FileCheck %s --check-prefix ELF-X86-64
RUN: obj2yaml %p/Inputs/unwind-section.elf-x86-64 \
RUN: | FileCheck %s --check-prefix ELF-X86-64-UNWIND
COFF-I386: header:
COFF-I386-NEXT: Machine: IMAGE_FILE_MACHINE_I386
@ -405,3 +407,9 @@ ELF-X86-64-NEXT: Section: .text
ELF-X86-64-NEXT: Size: 0x0000000000000026
ELF-X86-64-NEXT: - Name: SomeOtherFunction
ELF-X86-64-NEXT: - Name: puts
ELF-X86-64-UNWIND: - Name: .eh_frame
ELF-X86-64-UNWIND-NEXT: Type: SHT_X86_64_UNWIND
ELF-X86-64-UNWIND-NEXT: Flags: [ SHF_ALLOC ]
ELF-X86-64-UNWIND-NEXT: AddressAlign: 0x0000000000000001
ELF-X86-64-UNWIND-NEXT: Content: ''