diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 20:30:52 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-04 20:30:52 +0000 |
commit | 5152e4fb06cbf45d8f0758542fddfdb21e4026e0 (patch) | |
tree | 5a828e91dc250d6bc0fe3eba983d4c78b42a3aa2 /utils | |
parent | e50faa754b946d5240c1d4e84e64b7e84d4e27b1 (diff) | |
download | external_llvm-5152e4fb06cbf45d8f0758542fddfdb21e4026e0.zip external_llvm-5152e4fb06cbf45d8f0758542fddfdb21e4026e0.tar.gz external_llvm-5152e4fb06cbf45d8f0758542fddfdb21e4026e0.tar.bz2 |
Add back parsing of header charactestics.
It had been dropped during the switch to yaml::IO. Also add a test going
from yaml2obj to llvm-readobj. It can be extended as we add more
fields/formats to yaml2obj.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/yaml2obj/yaml2obj.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/utils/yaml2obj/yaml2obj.cpp b/utils/yaml2obj/yaml2obj.cpp index 2f01d19..17b65ae 100644 --- a/utils/yaml2obj/yaml2obj.cpp +++ b/utils/yaml2obj/yaml2obj.cpp @@ -129,6 +129,7 @@ namespace COFFYAML { struct Header { COFF::MachineTypes Machine; + std::vector<COFF::Characteristics> Characteristics; }; struct Symbol { @@ -159,6 +160,18 @@ struct COFFParser { StringTable.append(4, 0); } + void parseHeader() { + Header.Machine = Obj.HeaderData.Machine; + + const std::vector<COFF::Characteristics> &Characteristics = + Obj.HeaderData.Characteristics; + for (std::vector<COFF::Characteristics>::const_iterator I = + Characteristics.begin(), E = Characteristics.end(); I != E; ++I) { + uint16_t Characteristic = *I; + Header.Characteristics |= Characteristic; + } + } + bool parseSections() { for (std::vector<COFFYAML::Section>::iterator i = Obj.Sections.begin(), e = Obj.Sections.end(); i != e; ++i) { @@ -239,7 +252,7 @@ struct COFFParser { } bool parse() { - Header.Machine = Obj.HeaderData.Machine; + parseHeader(); if (!parseSections()) return false; if (!parseSymbols()) @@ -409,6 +422,7 @@ void writeCOFF(COFFParser &CP, raw_ostream &OS) { LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Relocation) LLVM_YAML_IS_SEQUENCE_VECTOR(COFF::SectionCharacteristics) +LLVM_YAML_IS_SEQUENCE_VECTOR(COFF::Characteristics) LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Section) LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Symbol) @@ -511,6 +525,27 @@ struct ScalarEnumerationTraits<COFF::MachineTypes> { }; template <> +struct ScalarEnumerationTraits<COFF::Characteristics> { + static void enumeration(IO &IO, COFF::Characteristics &Value) { + ECase(IMAGE_FILE_RELOCS_STRIPPED); + ECase(IMAGE_FILE_EXECUTABLE_IMAGE); + ECase(IMAGE_FILE_LINE_NUMS_STRIPPED); + ECase(IMAGE_FILE_LOCAL_SYMS_STRIPPED); + ECase(IMAGE_FILE_AGGRESSIVE_WS_TRIM); + ECase(IMAGE_FILE_LARGE_ADDRESS_AWARE); + ECase(IMAGE_FILE_BYTES_REVERSED_LO); + ECase(IMAGE_FILE_32BIT_MACHINE); + ECase(IMAGE_FILE_DEBUG_STRIPPED); + ECase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP); + ECase(IMAGE_FILE_NET_RUN_FROM_SWAP); + ECase(IMAGE_FILE_SYSTEM); + ECase(IMAGE_FILE_DLL); + ECase(IMAGE_FILE_UP_SYSTEM_ONLY); + ECase(IMAGE_FILE_BYTES_REVERSED_HI); + } +}; + +template <> struct ScalarEnumerationTraits<COFF::SectionCharacteristics> { static void enumeration(IO &IO, COFF::SectionCharacteristics &Value) { ECase(IMAGE_SCN_TYPE_NO_PAD); @@ -605,6 +640,7 @@ template <> struct MappingTraits<COFFYAML::Header> { static void mapping(IO &IO, COFFYAML::Header &H) { IO.mapRequired("Machine", H.Machine); + IO.mapOptional("Characteristics", H.Characteristics); } }; |