[llvm] r178786 - Add back parsing of header charactestics.
Rafael Espindola
rafael.espindola at gmail.com
Thu Apr 4 13:30:52 PDT 2013
Author: rafael
Date: Thu Apr 4 15:30:52 2013
New Revision: 178786
URL: http://llvm.org/viewvc/llvm-project?rev=178786&view=rev
Log:
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.
Added:
llvm/trunk/test/Object/yaml2obj-readobj.test
Modified:
llvm/trunk/test/Object/Inputs/COFF/i386.yaml
llvm/trunk/utils/yaml2obj/yaml2obj.cpp
Modified: llvm/trunk/test/Object/Inputs/COFF/i386.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/COFF/i386.yaml?rev=178786&r1=178785&r2=178786&view=diff
==============================================================================
--- llvm/trunk/test/Object/Inputs/COFF/i386.yaml (original)
+++ llvm/trunk/test/Object/Inputs/COFF/i386.yaml Thu Apr 4 15:30:52 2013
@@ -1,5 +1,6 @@
header: !Header
Machine: IMAGE_FILE_MACHINE_I386 # (0x14c)
+ Characteristics: [ IMAGE_FILE_DEBUG_STRIPPED ]
sections:
- !Section
Added: llvm/trunk/test/Object/yaml2obj-readobj.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-readobj.test?rev=178786&view=auto
==============================================================================
--- llvm/trunk/test/Object/yaml2obj-readobj.test (added)
+++ llvm/trunk/test/Object/yaml2obj-readobj.test Thu Apr 4 15:30:52 2013
@@ -0,0 +1,5 @@
+RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-readobj -file-headers - | FileCheck %s --check-prefix COFF-I386
+
+// COFF-I386: Characteristics [ (0x200)
+// COFF-I386-NEXT: IMAGE_FILE_DEBUG_STRIPPED (0x200)
+// COFF-I386-NEXT: ]
Modified: llvm/trunk/utils/yaml2obj/yaml2obj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/yaml2obj/yaml2obj.cpp?rev=178786&r1=178785&r2=178786&view=diff
==============================================================================
--- llvm/trunk/utils/yaml2obj/yaml2obj.cpp (original)
+++ llvm/trunk/utils/yaml2obj/yaml2obj.cpp Thu Apr 4 15:30:52 2013
@@ -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_ostre
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::Mac
};
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);
}
};
More information about the llvm-commits
mailing list