summaryrefslogtreecommitdiff
path: root/include/llvm/Object
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-05-17 22:58:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-05-17 22:58:42 +0000
commit2bbe3781471936fa0c37ad738fa86b72997c6831 (patch)
tree0e7d69e9fec0df4d123d3188b742542d033be7c5 /include/llvm/Object
parenteee6cdd7819b66e0d95a7a18337569b981374937 (diff)
downloadllvm-2bbe3781471936fa0c37ad738fa86b72997c6831.tar.gz
llvm-2bbe3781471936fa0c37ad738fa86b72997c6831.tar.bz2
llvm-2bbe3781471936fa0c37ad738fa86b72997c6831.tar.xz
Convert obj2yaml to use yamlio.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182169 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object')
-rw-r--r--include/llvm/Object/COFFYaml.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/include/llvm/Object/COFFYaml.h b/include/llvm/Object/COFFYaml.h
new file mode 100644
index 0000000000..08cbab428c
--- /dev/null
+++ b/include/llvm/Object/COFFYaml.h
@@ -0,0 +1,136 @@
+//===- COFFYAML.h - COFF YAMLIO implementation ------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares classes for handling the YAML representation of COFF.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OBJECT_COFFYAML_H
+#define LLVM_OBJECT_COFFYAML_H
+
+
+#include "llvm/Support/COFF.h"
+#include "llvm/Support/YAMLTraits.h"
+
+namespace llvm {
+
+namespace COFF {
+inline Characteristics operator|(Characteristics a, Characteristics b) {
+ uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
+ return static_cast<Characteristics>(Ret);
+}
+
+inline SectionCharacteristics operator|(SectionCharacteristics a,
+ SectionCharacteristics b) {
+ uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
+ return static_cast<SectionCharacteristics>(Ret);
+}
+}
+
+// The structure of the yaml files is not an exact 1:1 match to COFF. In order
+// to use yaml::IO, we use these structures which are closer to the source.
+namespace COFFYAML {
+ struct Section {
+ COFF::section Header;
+ unsigned Alignment;
+ StringRef SectionData;
+ std::vector<COFF::relocation> Relocations;
+ StringRef Name;
+ Section();
+ };
+
+ struct Symbol {
+ COFF::symbol Header;
+ COFF::SymbolBaseType SimpleType;
+ COFF::SymbolComplexType ComplexType;
+ StringRef AuxiliaryData;
+ StringRef Name;
+ Symbol();
+ };
+
+ struct Object {
+ COFF::header Header;
+ std::vector<Section> Sections;
+ std::vector<Symbol> Symbols;
+ Object();
+ };
+}
+}
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Section)
+LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Symbol)
+LLVM_YAML_IS_SEQUENCE_VECTOR(COFF::relocation)
+
+namespace llvm {
+namespace yaml {
+
+template <>
+struct ScalarEnumerationTraits<COFF::MachineTypes> {
+ static void enumeration(IO &IO, COFF::MachineTypes &Value);
+};
+
+template <>
+struct ScalarEnumerationTraits<COFF::SymbolBaseType> {
+ static void enumeration(IO &IO, COFF::SymbolBaseType &Value);
+};
+
+template <>
+struct ScalarEnumerationTraits<COFF::SymbolStorageClass> {
+ static void enumeration(IO &IO, COFF::SymbolStorageClass &Value);
+};
+
+template <>
+struct ScalarEnumerationTraits<COFF::SymbolComplexType> {
+ static void enumeration(IO &IO, COFF::SymbolComplexType &Value);
+};
+
+template <>
+struct ScalarEnumerationTraits<COFF::RelocationTypeX86> {
+ static void enumeration(IO &IO, COFF::RelocationTypeX86 &Value);
+};
+
+template <>
+struct ScalarBitSetTraits<COFF::Characteristics> {
+ static void bitset(IO &IO, COFF::Characteristics &Value);
+};
+
+template <>
+struct ScalarBitSetTraits<COFF::SectionCharacteristics> {
+ static void bitset(IO &IO, COFF::SectionCharacteristics &Value);
+};
+
+template <>
+struct MappingTraits<COFF::relocation> {
+ static void mapping(IO &IO, COFF::relocation &Rel);
+};
+
+template <>
+struct MappingTraits<COFF::header> {
+ static void mapping(IO &IO, COFF::header &H);
+};
+
+template <>
+struct MappingTraits<COFFYAML::Symbol> {
+ static void mapping(IO &IO, COFFYAML::Symbol &S);
+};
+
+template <>
+struct MappingTraits<COFFYAML::Section> {
+ static void mapping(IO &IO, COFFYAML::Section &Sec);
+};
+
+template <>
+struct MappingTraits<COFFYAML::Object> {
+ static void mapping(IO &IO, COFFYAML::Object &Obj);
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+#endif