diff options
Diffstat (limited to 'include/llvm/ObjectYAML')
| -rw-r--r-- | include/llvm/ObjectYAML/COFFYAML.h | 12 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/CodeViewYAMLTypeHashing.h | 62 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/CodeViewYAMLTypes.h | 12 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/ELFYAML.h | 44 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/MachOYAML.h | 6 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/WasmYAML.h | 46 | ||||
| -rw-r--r-- | include/llvm/ObjectYAML/YAML.h | 2 |
7 files changed, 168 insertions, 16 deletions
diff --git a/include/llvm/ObjectYAML/COFFYAML.h b/include/llvm/ObjectYAML/COFFYAML.h index bbceefac3d947..8794eaa6d59a8 100644 --- a/include/llvm/ObjectYAML/COFFYAML.h +++ b/include/llvm/ObjectYAML/COFFYAML.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/COFF.h" #include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h" +#include "llvm/ObjectYAML/CodeViewYAMLTypeHashing.h" #include "llvm/ObjectYAML/CodeViewYAMLTypes.h" #include "llvm/ObjectYAML/YAML.h" #include <cstdint> @@ -66,6 +67,7 @@ struct Section { yaml::BinaryRef SectionData; std::vector<CodeViewYAML::YAMLDebugSubsection> DebugS; std::vector<CodeViewYAML::LeafRecord> DebugT; + Optional<CodeViewYAML::DebugHSection> DebugH; std::vector<Relocation> Relocations; StringRef Name; @@ -158,6 +160,16 @@ struct ScalarEnumerationTraits<COFF::RelocationTypeAMD64> { }; template <> +struct ScalarEnumerationTraits<COFF::RelocationTypesARM> { + static void enumeration(IO &IO, COFF::RelocationTypesARM &Value); +}; + +template <> +struct ScalarEnumerationTraits<COFF::RelocationTypesARM64> { + static void enumeration(IO &IO, COFF::RelocationTypesARM64 &Value); +}; + +template <> struct ScalarEnumerationTraits<COFF::WindowsSubsystem> { static void enumeration(IO &IO, COFF::WindowsSubsystem &Value); }; diff --git a/include/llvm/ObjectYAML/CodeViewYAMLTypeHashing.h b/include/llvm/ObjectYAML/CodeViewYAMLTypeHashing.h new file mode 100644 index 0000000000000..4f0d9efb963bf --- /dev/null +++ b/include/llvm/ObjectYAML/CodeViewYAMLTypeHashing.h @@ -0,0 +1,62 @@ +//==- CodeViewYAMLTypeHashing.h - CodeView YAMLIO Type hashing ----*- C++-*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines classes for handling the YAML representation of CodeView +// Debug Info. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECTYAML_CODEVIEWYAMLTYPEHASHING_H +#define LLVM_OBJECTYAML_CODEVIEWYAMLTYPEHASHING_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/DebugInfo/CodeView/TypeHashing.h" +#include "llvm/ObjectYAML/YAML.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/YAMLTraits.h" +#include <cstdint> +#include <memory> +#include <vector> + +namespace llvm { + +namespace CodeViewYAML { + +struct GlobalHash { + GlobalHash() = default; + explicit GlobalHash(StringRef S) : Hash(S) { + assert(S.size() == 20 && "Invalid hash size!"); + } + explicit GlobalHash(ArrayRef<uint8_t> S) : Hash(S) { + assert(S.size() == 20 && "Invalid hash size!"); + } + yaml::BinaryRef Hash; +}; + +struct DebugHSection { + uint32_t Magic; + uint16_t Version; + uint16_t HashAlgorithm; + std::vector<GlobalHash> Hashes; +}; + +DebugHSection fromDebugH(ArrayRef<uint8_t> DebugT); +ArrayRef<uint8_t> toDebugH(const DebugHSection &DebugH, + BumpPtrAllocator &Alloc); + +} // end namespace CodeViewYAML + +} // end namespace llvm + +LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::DebugHSection) +LLVM_YAML_DECLARE_SCALAR_TRAITS(CodeViewYAML::GlobalHash, QuotingType::None) +LLVM_YAML_IS_SEQUENCE_VECTOR(CodeViewYAML::GlobalHash) + +#endif // LLVM_OBJECTYAML_CODEVIEWYAMLTYPES_H diff --git a/include/llvm/ObjectYAML/CodeViewYAMLTypes.h b/include/llvm/ObjectYAML/CodeViewYAMLTypes.h index 88a5668f0a14f..bc3b5567c2f9c 100644 --- a/include/llvm/ObjectYAML/CodeViewYAMLTypes.h +++ b/include/llvm/ObjectYAML/CodeViewYAMLTypes.h @@ -27,10 +27,8 @@ namespace llvm { namespace codeview { - -class TypeTableBuilder; - -} // end namespace codeview +class AppendingTypeTableBuilder; +} namespace CodeViewYAML { @@ -48,8 +46,8 @@ struct MemberRecord { struct LeafRecord { std::shared_ptr<detail::LeafRecordBase> Leaf; - codeview::CVType toCodeViewRecord(BumpPtrAllocator &Allocator) const; - codeview::CVType toCodeViewRecord(codeview::TypeTableBuilder &TS) const; + codeview::CVType + toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const; static Expected<LeafRecord> fromCodeViewRecord(codeview::CVType Type); }; @@ -60,7 +58,7 @@ ArrayRef<uint8_t> toDebugT(ArrayRef<LeafRecord>, BumpPtrAllocator &Alloc); } // end namespace llvm -LLVM_YAML_DECLARE_SCALAR_TRAITS(codeview::GUID, true) +LLVM_YAML_DECLARE_SCALAR_TRAITS(codeview::GUID, QuotingType::Single) LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::LeafRecord) LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::MemberRecord) diff --git a/include/llvm/ObjectYAML/ELFYAML.h b/include/llvm/ObjectYAML/ELFYAML.h index ed455311696ea..7ba83967330eb 100644 --- a/include/llvm/ObjectYAML/ELFYAML.h +++ b/include/llvm/ObjectYAML/ELFYAML.h @@ -37,17 +37,20 @@ namespace ELFYAML { // In the future, these would probably be better suited by C++11 enum // class's with appropriate fixed underlying type. LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_ET) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_PT) LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_EM) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI) // Just use 64, since it can hold 32-bit values too. LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_EF) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_PF) LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT) LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_REL) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_RSS) // Just use 64, since it can hold 32-bit values too. LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF) +LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_SHN) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STT) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STV) LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STO) @@ -71,10 +74,24 @@ struct FileHeader { llvm::yaml::Hex64 Entry; }; +struct SectionName { + StringRef Section; +}; + +struct ProgramHeader { + ELF_PT Type; + ELF_PF Flags; + llvm::yaml::Hex64 VAddr; + llvm::yaml::Hex64 PAddr; + Optional<llvm::yaml::Hex64> Align; + std::vector<SectionName> Sections; +}; + struct Symbol { StringRef Name; ELF_STT Type; StringRef Section; + Optional<ELF_SHN> Index; llvm::yaml::Hex64 Value; llvm::yaml::Hex64 Size; uint8_t Other; @@ -147,7 +164,7 @@ struct Relocation { llvm::yaml::Hex64 Offset; int64_t Addend; ELF_REL Type; - StringRef Symbol; + Optional<StringRef> Symbol; }; struct RelocationSection : Section { @@ -183,21 +200,25 @@ struct MipsABIFlags : Section { struct Object { FileHeader Header; + std::vector<ProgramHeader> ProgramHeaders; std::vector<std::unique_ptr<Section>> Sections; // Although in reality the symbols reside in a section, it is a lot // cleaner and nicer if we read them from the YAML as a separate // top-level key, which automatically ensures that invariants like there // being a single SHT_SYMTAB section are upheld. LocalGlobalWeakSymbols Symbols; + LocalGlobalWeakSymbols DynamicSymbols; }; } // end namespace ELFYAML } // end namespace llvm +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ProgramHeader) LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::ELFYAML::Section>) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Symbol) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Relocation) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionOrType) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionName) namespace llvm { namespace yaml { @@ -207,6 +228,10 @@ struct ScalarEnumerationTraits<ELFYAML::ELF_ET> { static void enumeration(IO &IO, ELFYAML::ELF_ET &Value); }; +template <> struct ScalarEnumerationTraits<ELFYAML::ELF_PT> { + static void enumeration(IO &IO, ELFYAML::ELF_PT &Value); +}; + template <> struct ScalarEnumerationTraits<ELFYAML::ELF_EM> { static void enumeration(IO &IO, ELFYAML::ELF_EM &Value); @@ -232,6 +257,10 @@ struct ScalarBitSetTraits<ELFYAML::ELF_EF> { static void bitset(IO &IO, ELFYAML::ELF_EF &Value); }; +template <> struct ScalarBitSetTraits<ELFYAML::ELF_PF> { + static void bitset(IO &IO, ELFYAML::ELF_PF &Value); +}; + template <> struct ScalarEnumerationTraits<ELFYAML::ELF_SHT> { static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value); @@ -242,6 +271,10 @@ struct ScalarBitSetTraits<ELFYAML::ELF_SHF> { static void bitset(IO &IO, ELFYAML::ELF_SHF &Value); }; +template <> struct ScalarEnumerationTraits<ELFYAML::ELF_SHN> { + static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value); +}; + template <> struct ScalarEnumerationTraits<ELFYAML::ELF_STT> { static void enumeration(IO &IO, ELFYAML::ELF_STT &Value); @@ -302,9 +335,14 @@ struct MappingTraits<ELFYAML::FileHeader> { static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr); }; +template <> struct MappingTraits<ELFYAML::ProgramHeader> { + static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr); +}; + template <> struct MappingTraits<ELFYAML::Symbol> { static void mapping(IO &IO, ELFYAML::Symbol &Symbol); + static StringRef validate(IO &IO, ELFYAML::Symbol &Symbol); }; template <> @@ -331,6 +369,10 @@ template <> struct MappingTraits<ELFYAML::SectionOrType> { static void mapping(IO &IO, ELFYAML::SectionOrType §ionOrType); }; +template <> struct MappingTraits<ELFYAML::SectionName> { + static void mapping(IO &IO, ELFYAML::SectionName §ionName); +}; + } // end namespace yaml } // end namespace llvm diff --git a/include/llvm/ObjectYAML/MachOYAML.h b/include/llvm/ObjectYAML/MachOYAML.h index 305497b6aa6a6..1fa8f92e516a7 100644 --- a/include/llvm/ObjectYAML/MachOYAML.h +++ b/include/llvm/ObjectYAML/MachOYAML.h @@ -261,17 +261,17 @@ using char_16 = char[16]; template <> struct ScalarTraits<char_16> { static void output(const char_16 &Val, void *, raw_ostream &Out); static StringRef input(StringRef Scalar, void *, char_16 &Val); - static bool mustQuote(StringRef S); + static QuotingType mustQuote(StringRef S); }; // This trait is used for UUIDs. It reads and writes them matching otool's // formatting style. -using uuid_t = uint8_t[16]; +using uuid_t = raw_ostream::uuid_t; template <> struct ScalarTraits<uuid_t> { static void output(const uuid_t &Val, void *, raw_ostream &Out); static StringRef input(StringRef Scalar, void *, uuid_t &Val); - static bool mustQuote(StringRef S); + static QuotingType mustQuote(StringRef S); }; // Load Command struct mapping traits diff --git a/include/llvm/ObjectYAML/WasmYAML.h b/include/llvm/ObjectYAML/WasmYAML.h index 709ad8ec3b776..188ce8e444919 100644 --- a/include/llvm/ObjectYAML/WasmYAML.h +++ b/include/llvm/ObjectYAML/WasmYAML.h @@ -34,13 +34,16 @@ LLVM_YAML_STRONG_TYPEDEF(int32_t, SignatureForm) LLVM_YAML_STRONG_TYPEDEF(uint32_t, ExportKind) LLVM_YAML_STRONG_TYPEDEF(uint32_t, Opcode) LLVM_YAML_STRONG_TYPEDEF(uint32_t, RelocType) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, SymbolFlags) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, SegmentFlags) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, LimitFlags) struct FileHeader { yaml::Hex32 Version; }; struct Limits { - yaml::Hex32 Flags; + LimitFlags Flags; yaml::Hex32 Initial; yaml::Hex32 Maximum; }; @@ -109,6 +112,13 @@ struct NameEntry { StringRef Name; }; +struct SegmentInfo { + uint32_t Index; + StringRef Name; + uint32_t Alignment; + SegmentFlags Flags; +}; + struct Signature { uint32_t Index; SignatureForm Form = wasm::WASM_TYPE_FUNC; @@ -118,7 +128,12 @@ struct Signature { struct SymbolInfo { StringRef Name; - uint32_t Flags; + SymbolFlags Flags; +}; + +struct InitFunction { + uint32_t Priority; + uint32_t FunctionIndex; }; struct Section { @@ -160,9 +175,10 @@ struct LinkingSection : CustomSection { return C && C->Name == "linking"; } - std::vector<SymbolInfo> SymbolInfos; uint32_t DataSize; - uint32_t DataAlignment; + std::vector<SymbolInfo> SymbolInfos; + std::vector<SegmentInfo> SegmentInfos; + std::vector<InitFunction> InitFunctions; }; struct TypeSection : Section { @@ -297,7 +313,9 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Function) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SegmentInfo) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo) +LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::InitFunction) namespace llvm { namespace yaml { @@ -326,6 +344,18 @@ template <> struct MappingTraits<WasmYAML::Global> { static void mapping(IO &IO, WasmYAML::Global &Global); }; +template <> struct ScalarBitSetTraits<WasmYAML::LimitFlags> { + static void bitset(IO &IO, WasmYAML::LimitFlags &Value); +}; + +template <> struct ScalarBitSetTraits<WasmYAML::SymbolFlags> { + static void bitset(IO &IO, WasmYAML::SymbolFlags &Value); +}; + +template <> struct ScalarBitSetTraits<WasmYAML::SegmentFlags> { + static void bitset(IO &IO, WasmYAML::SegmentFlags &Value); +}; + template <> struct ScalarEnumerationTraits<WasmYAML::SectionType> { static void enumeration(IO &IO, WasmYAML::SectionType &Type); }; @@ -354,6 +384,10 @@ template <> struct MappingTraits<WasmYAML::NameEntry> { static void mapping(IO &IO, WasmYAML::NameEntry &NameEntry); }; +template <> struct MappingTraits<WasmYAML::SegmentInfo> { + static void mapping(IO &IO, WasmYAML::SegmentInfo &SegmentInfo); +}; + template <> struct MappingTraits<WasmYAML::LocalDecl> { static void mapping(IO &IO, WasmYAML::LocalDecl &LocalDecl); }; @@ -374,6 +408,10 @@ template <> struct MappingTraits<WasmYAML::SymbolInfo> { static void mapping(IO &IO, WasmYAML::SymbolInfo &Info); }; +template <> struct MappingTraits<WasmYAML::InitFunction> { + static void mapping(IO &IO, WasmYAML::InitFunction &Init); +}; + template <> struct ScalarEnumerationTraits<WasmYAML::ValueType> { static void enumeration(IO &IO, WasmYAML::ValueType &Type); }; diff --git a/include/llvm/ObjectYAML/YAML.h b/include/llvm/ObjectYAML/YAML.h index 29151a269df09..93266dd67f1af 100644 --- a/include/llvm/ObjectYAML/YAML.h +++ b/include/llvm/ObjectYAML/YAML.h @@ -107,7 +107,7 @@ inline bool operator==(const BinaryRef &LHS, const BinaryRef &RHS) { template <> struct ScalarTraits<BinaryRef> { static void output(const BinaryRef &, void *, raw_ostream &); static StringRef input(StringRef, void *, BinaryRef &); - static bool mustQuote(StringRef S) { return needsQuotes(S); } + static QuotingType mustQuote(StringRef S) { return needsQuotes(S); } }; } // end namespace yaml |
