1 //===- ELFYAML.h - ELF YAMLIO implementation --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file declares classes for handling the YAML representation
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_OBJECT_ELFYAML_H
17 #define LLVM_OBJECT_ELFYAML_H
19 #include "llvm/Object/YAML.h"
20 #include "llvm/Support/ELF.h"
25 // These types are invariant across 32/64-bit ELF, so for simplicity just
26 // directly give them their exact sizes. We don't need to worry about
27 // endianness because these are just the types in the YAMLIO structures,
28 // and are appropriately converted to the necessary endianness when
29 // reading/generating binary object files.
30 // The naming of these types is intended to be ELF_PREFIX, where PREFIX is
31 // the common prefix of the respective constants. E.g. ELF_EM corresponds
32 // to the `e_machine` constants, like `EM_X86_64`.
33 // In the future, these would probably be better suited by C++11 enum
34 // class's with appropriate fixed underlying type.
35 LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_ET)
36 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_EM)
37 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS)
38 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
39 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
40 // Just use 64, since it can hold 32-bit values too.
41 LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
43 // For now, hardcode 64 bits everywhere that 32 or 64 would be needed
44 // since 64-bit can hold 32-bit values too.
50 llvm::yaml::Hex64 Entry;
59 llvm::yaml::Hex64 Address;
60 object::yaml::BinaryRef Content;
62 llvm::yaml::Hex64 AddressAlign;
63 // For SHT_SYMTAB; should be empty otherwise.
64 std::vector<Symbol> Symbols;
68 std::vector<Section> Sections;
71 } // end namespace ELFYAML
72 } // end namespace llvm
74 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Section)
75 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Symbol)
81 struct ScalarEnumerationTraits<ELFYAML::ELF_ET> {
82 static void enumeration(IO &IO, ELFYAML::ELF_ET &Value);
86 struct ScalarEnumerationTraits<ELFYAML::ELF_EM> {
87 static void enumeration(IO &IO, ELFYAML::ELF_EM &Value);
91 struct ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS> {
92 static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value);
96 struct ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA> {
97 static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value);
101 struct ScalarEnumerationTraits<ELFYAML::ELF_SHT> {
102 static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
106 struct ScalarBitSetTraits<ELFYAML::ELF_SHF> {
107 static void bitset(IO &IO, ELFYAML::ELF_SHF &Value);
111 struct MappingTraits<ELFYAML::FileHeader> {
112 static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr);
116 struct MappingTraits<ELFYAML::Symbol> {
117 static void mapping(IO &IO, ELFYAML::Symbol &Symbol);
121 struct MappingTraits<ELFYAML::Section> {
122 static void mapping(IO &IO, ELFYAML::Section &Section);
126 struct MappingTraits<ELFYAML::Object> {
127 static void mapping(IO &IO, ELFYAML::Object &Object);
130 } // end namespace yaml
131 } // end namespace llvm