Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- ELFYAML.h - ELF YAMLIO implementation --------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 10 | /// This file declares classes for handling the YAML representation |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 11 | /// of ELF. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_OBJECTYAML_ELFYAML_H |
| 16 | #define LLVM_OBJECTYAML_ELFYAML_H |
| 17 | |
| 18 | #include "llvm/ADT/StringRef.h" |
| 19 | #include "llvm/ObjectYAML/YAML.h" |
| 20 | #include "llvm/Support/YAMLTraits.h" |
| 21 | #include <cstdint> |
| 22 | #include <memory> |
| 23 | #include <vector> |
| 24 | |
| 25 | namespace llvm { |
| 26 | namespace ELFYAML { |
| 27 | |
| 28 | // These types are invariant across 32/64-bit ELF, so for simplicity just |
| 29 | // directly give them their exact sizes. We don't need to worry about |
| 30 | // endianness because these are just the types in the YAMLIO structures, |
| 31 | // and are appropriately converted to the necessary endianness when |
| 32 | // reading/generating binary object files. |
| 33 | // The naming of these types is intended to be ELF_PREFIX, where PREFIX is |
| 34 | // the common prefix of the respective constants. E.g. ELF_EM corresponds |
| 35 | // to the `e_machine` constants, like `EM_X86_64`. |
| 36 | // In the future, these would probably be better suited by C++11 enum |
| 37 | // class's with appropriate fixed underlying type. |
| 38 | LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_ET) |
| 39 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_PT) |
| 40 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_EM) |
| 41 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS) |
| 42 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA) |
| 43 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI) |
| 44 | // Just use 64, since it can hold 32-bit values too. |
| 45 | LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_EF) |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 46 | // Just use 64, since it can hold 32-bit values too. |
| 47 | LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_DYNTAG) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 48 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_PF) |
| 49 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT) |
| 50 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_REL) |
| 51 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_RSS) |
| 52 | // Just use 64, since it can hold 32-bit values too. |
| 53 | LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF) |
| 54 | LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_SHN) |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 55 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STB) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 56 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STT) |
| 57 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STV) |
| 58 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_STO) |
| 59 | |
| 60 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG) |
| 61 | LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP) |
| 62 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_EXT) |
| 63 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE) |
| 64 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1) |
| 65 | LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_ISA) |
| 66 | |
| 67 | // For now, hardcode 64 bits everywhere that 32 or 64 would be needed |
| 68 | // since 64-bit can hold 32-bit values too. |
| 69 | struct FileHeader { |
| 70 | ELF_ELFCLASS Class; |
| 71 | ELF_ELFDATA Data; |
| 72 | ELF_ELFOSABI OSABI; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 73 | llvm::yaml::Hex8 ABIVersion; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 74 | ELF_ET Type; |
| 75 | ELF_EM Machine; |
| 76 | ELF_EF Flags; |
| 77 | llvm::yaml::Hex64 Entry; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 78 | |
| 79 | Optional<llvm::yaml::Hex16> SHEntSize; |
| 80 | Optional<llvm::yaml::Hex16> SHOffset; |
| 81 | Optional<llvm::yaml::Hex16> SHNum; |
| 82 | Optional<llvm::yaml::Hex16> SHStrNdx; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | struct SectionName { |
| 86 | StringRef Section; |
| 87 | }; |
| 88 | |
| 89 | struct ProgramHeader { |
| 90 | ELF_PT Type; |
| 91 | ELF_PF Flags; |
| 92 | llvm::yaml::Hex64 VAddr; |
| 93 | llvm::yaml::Hex64 PAddr; |
| 94 | Optional<llvm::yaml::Hex64> Align; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 95 | Optional<llvm::yaml::Hex64> FileSize; |
| 96 | Optional<llvm::yaml::Hex64> MemSize; |
| 97 | Optional<llvm::yaml::Hex64> Offset; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 98 | std::vector<SectionName> Sections; |
| 99 | }; |
| 100 | |
| 101 | struct Symbol { |
| 102 | StringRef Name; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 103 | Optional<uint32_t> NameIndex; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 104 | ELF_STT Type; |
| 105 | StringRef Section; |
| 106 | Optional<ELF_SHN> Index; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 107 | ELF_STB Binding; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 108 | llvm::yaml::Hex64 Value; |
| 109 | llvm::yaml::Hex64 Size; |
| 110 | uint8_t Other; |
| 111 | }; |
| 112 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 113 | struct SectionOrType { |
| 114 | StringRef sectionNameOrType; |
| 115 | }; |
| 116 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 117 | struct DynamicEntry { |
| 118 | ELF_DYNTAG Tag; |
| 119 | llvm::yaml::Hex64 Val; |
| 120 | }; |
| 121 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 122 | struct Section { |
| 123 | enum class SectionKind { |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 124 | Dynamic, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 125 | Group, |
| 126 | RawContent, |
| 127 | Relocation, |
| 128 | NoBits, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 129 | Verdef, |
| 130 | Verneed, |
| 131 | Symver, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 132 | MipsABIFlags |
| 133 | }; |
| 134 | SectionKind Kind; |
| 135 | StringRef Name; |
| 136 | ELF_SHT Type; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 137 | Optional<ELF_SHF> Flags; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 138 | llvm::yaml::Hex64 Address; |
| 139 | StringRef Link; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 140 | llvm::yaml::Hex64 AddressAlign; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 141 | Optional<llvm::yaml::Hex64> EntSize; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 142 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 143 | // This can be used to override the sh_offset field. It does not place the |
| 144 | // section data at the offset specified. Useful for creating invalid objects. |
| 145 | Optional<llvm::yaml::Hex64> ShOffset; |
| 146 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 147 | Section(SectionKind Kind) : Kind(Kind) {} |
| 148 | virtual ~Section(); |
| 149 | }; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 150 | |
| 151 | struct DynamicSection : Section { |
| 152 | std::vector<DynamicEntry> Entries; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 153 | Optional<yaml::BinaryRef> Content; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 154 | |
| 155 | DynamicSection() : Section(SectionKind::Dynamic) {} |
| 156 | |
| 157 | static bool classof(const Section *S) { |
| 158 | return S->Kind == SectionKind::Dynamic; |
| 159 | } |
| 160 | }; |
| 161 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 162 | struct RawContentSection : Section { |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 163 | Optional<yaml::BinaryRef> Content; |
| 164 | Optional<llvm::yaml::Hex64> Size; |
| 165 | Optional<llvm::yaml::Hex64> Info; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 166 | |
| 167 | RawContentSection() : Section(SectionKind::RawContent) {} |
| 168 | |
| 169 | static bool classof(const Section *S) { |
| 170 | return S->Kind == SectionKind::RawContent; |
| 171 | } |
| 172 | }; |
| 173 | |
| 174 | struct NoBitsSection : Section { |
| 175 | llvm::yaml::Hex64 Size; |
| 176 | |
| 177 | NoBitsSection() : Section(SectionKind::NoBits) {} |
| 178 | |
| 179 | static bool classof(const Section *S) { |
| 180 | return S->Kind == SectionKind::NoBits; |
| 181 | } |
| 182 | }; |
| 183 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 184 | struct VernauxEntry { |
| 185 | uint32_t Hash; |
| 186 | uint16_t Flags; |
| 187 | uint16_t Other; |
| 188 | StringRef Name; |
| 189 | }; |
| 190 | |
| 191 | struct VerneedEntry { |
| 192 | uint16_t Version; |
| 193 | StringRef File; |
| 194 | std::vector<VernauxEntry> AuxV; |
| 195 | }; |
| 196 | |
| 197 | struct VerneedSection : Section { |
| 198 | std::vector<VerneedEntry> VerneedV; |
| 199 | llvm::yaml::Hex64 Info; |
| 200 | |
| 201 | VerneedSection() : Section(SectionKind::Verneed) {} |
| 202 | |
| 203 | static bool classof(const Section *S) { |
| 204 | return S->Kind == SectionKind::Verneed; |
| 205 | } |
| 206 | }; |
| 207 | |
| 208 | struct SymverSection : Section { |
| 209 | std::vector<uint16_t> Entries; |
| 210 | |
| 211 | SymverSection() : Section(SectionKind::Symver) {} |
| 212 | |
| 213 | static bool classof(const Section *S) { |
| 214 | return S->Kind == SectionKind::Symver; |
| 215 | } |
| 216 | }; |
| 217 | |
| 218 | struct VerdefEntry { |
| 219 | uint16_t Version; |
| 220 | uint16_t Flags; |
| 221 | uint16_t VersionNdx; |
| 222 | uint32_t Hash; |
| 223 | std::vector<StringRef> VerNames; |
| 224 | }; |
| 225 | |
| 226 | struct VerdefSection : Section { |
| 227 | std::vector<VerdefEntry> Entries; |
| 228 | llvm::yaml::Hex64 Info; |
| 229 | |
| 230 | VerdefSection() : Section(SectionKind::Verdef) {} |
| 231 | |
| 232 | static bool classof(const Section *S) { |
| 233 | return S->Kind == SectionKind::Verdef; |
| 234 | } |
| 235 | }; |
| 236 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 237 | struct Group : Section { |
| 238 | // Members of a group contain a flag and a list of section indices |
| 239 | // that are part of the group. |
| 240 | std::vector<SectionOrType> Members; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 241 | StringRef Signature; /* Info */ |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 242 | |
| 243 | Group() : Section(SectionKind::Group) {} |
| 244 | |
| 245 | static bool classof(const Section *S) { |
| 246 | return S->Kind == SectionKind::Group; |
| 247 | } |
| 248 | }; |
| 249 | |
| 250 | struct Relocation { |
| 251 | llvm::yaml::Hex64 Offset; |
| 252 | int64_t Addend; |
| 253 | ELF_REL Type; |
| 254 | Optional<StringRef> Symbol; |
| 255 | }; |
| 256 | |
| 257 | struct RelocationSection : Section { |
| 258 | std::vector<Relocation> Relocations; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 259 | StringRef RelocatableSec; /* Info */ |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 260 | |
| 261 | RelocationSection() : Section(SectionKind::Relocation) {} |
| 262 | |
| 263 | static bool classof(const Section *S) { |
| 264 | return S->Kind == SectionKind::Relocation; |
| 265 | } |
| 266 | }; |
| 267 | |
| 268 | // Represents .MIPS.abiflags section |
| 269 | struct MipsABIFlags : Section { |
| 270 | llvm::yaml::Hex16 Version; |
| 271 | MIPS_ISA ISALevel; |
| 272 | llvm::yaml::Hex8 ISARevision; |
| 273 | MIPS_AFL_REG GPRSize; |
| 274 | MIPS_AFL_REG CPR1Size; |
| 275 | MIPS_AFL_REG CPR2Size; |
| 276 | MIPS_ABI_FP FpABI; |
| 277 | MIPS_AFL_EXT ISAExtension; |
| 278 | MIPS_AFL_ASE ASEs; |
| 279 | MIPS_AFL_FLAGS1 Flags1; |
| 280 | llvm::yaml::Hex32 Flags2; |
| 281 | |
| 282 | MipsABIFlags() : Section(SectionKind::MipsABIFlags) {} |
| 283 | |
| 284 | static bool classof(const Section *S) { |
| 285 | return S->Kind == SectionKind::MipsABIFlags; |
| 286 | } |
| 287 | }; |
| 288 | |
| 289 | struct Object { |
| 290 | FileHeader Header; |
| 291 | std::vector<ProgramHeader> ProgramHeaders; |
| 292 | std::vector<std::unique_ptr<Section>> Sections; |
| 293 | // Although in reality the symbols reside in a section, it is a lot |
| 294 | // cleaner and nicer if we read them from the YAML as a separate |
| 295 | // top-level key, which automatically ensures that invariants like there |
| 296 | // being a single SHT_SYMTAB section are upheld. |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 297 | std::vector<Symbol> Symbols; |
| 298 | std::vector<Symbol> DynamicSymbols; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 299 | }; |
| 300 | |
| 301 | } // end namespace ELFYAML |
| 302 | } // end namespace llvm |
| 303 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 304 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::DynamicEntry) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 305 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::ProgramHeader) |
| 306 | LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::ELFYAML::Section>) |
| 307 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Symbol) |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 308 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerdefEntry) |
| 309 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VernauxEntry) |
| 310 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::VerneedEntry) |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 311 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::Relocation) |
| 312 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionOrType) |
| 313 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ELFYAML::SectionName) |
| 314 | |
| 315 | namespace llvm { |
| 316 | namespace yaml { |
| 317 | |
| 318 | template <> |
| 319 | struct ScalarEnumerationTraits<ELFYAML::ELF_ET> { |
| 320 | static void enumeration(IO &IO, ELFYAML::ELF_ET &Value); |
| 321 | }; |
| 322 | |
| 323 | template <> struct ScalarEnumerationTraits<ELFYAML::ELF_PT> { |
| 324 | static void enumeration(IO &IO, ELFYAML::ELF_PT &Value); |
| 325 | }; |
| 326 | |
| 327 | template <> |
| 328 | struct ScalarEnumerationTraits<ELFYAML::ELF_EM> { |
| 329 | static void enumeration(IO &IO, ELFYAML::ELF_EM &Value); |
| 330 | }; |
| 331 | |
| 332 | template <> |
| 333 | struct ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS> { |
| 334 | static void enumeration(IO &IO, ELFYAML::ELF_ELFCLASS &Value); |
| 335 | }; |
| 336 | |
| 337 | template <> |
| 338 | struct ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA> { |
| 339 | static void enumeration(IO &IO, ELFYAML::ELF_ELFDATA &Value); |
| 340 | }; |
| 341 | |
| 342 | template <> |
| 343 | struct ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI> { |
| 344 | static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value); |
| 345 | }; |
| 346 | |
| 347 | template <> |
| 348 | struct ScalarBitSetTraits<ELFYAML::ELF_EF> { |
| 349 | static void bitset(IO &IO, ELFYAML::ELF_EF &Value); |
| 350 | }; |
| 351 | |
| 352 | template <> struct ScalarBitSetTraits<ELFYAML::ELF_PF> { |
| 353 | static void bitset(IO &IO, ELFYAML::ELF_PF &Value); |
| 354 | }; |
| 355 | |
| 356 | template <> |
| 357 | struct ScalarEnumerationTraits<ELFYAML::ELF_SHT> { |
| 358 | static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value); |
| 359 | }; |
| 360 | |
| 361 | template <> |
| 362 | struct ScalarBitSetTraits<ELFYAML::ELF_SHF> { |
| 363 | static void bitset(IO &IO, ELFYAML::ELF_SHF &Value); |
| 364 | }; |
| 365 | |
| 366 | template <> struct ScalarEnumerationTraits<ELFYAML::ELF_SHN> { |
| 367 | static void enumeration(IO &IO, ELFYAML::ELF_SHN &Value); |
| 368 | }; |
| 369 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 370 | template <> struct ScalarEnumerationTraits<ELFYAML::ELF_STB> { |
| 371 | static void enumeration(IO &IO, ELFYAML::ELF_STB &Value); |
| 372 | }; |
| 373 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 374 | template <> |
| 375 | struct ScalarEnumerationTraits<ELFYAML::ELF_STT> { |
| 376 | static void enumeration(IO &IO, ELFYAML::ELF_STT &Value); |
| 377 | }; |
| 378 | |
| 379 | template <> |
| 380 | struct ScalarEnumerationTraits<ELFYAML::ELF_STV> { |
| 381 | static void enumeration(IO &IO, ELFYAML::ELF_STV &Value); |
| 382 | }; |
| 383 | |
| 384 | template <> |
| 385 | struct ScalarBitSetTraits<ELFYAML::ELF_STO> { |
| 386 | static void bitset(IO &IO, ELFYAML::ELF_STO &Value); |
| 387 | }; |
| 388 | |
| 389 | template <> |
| 390 | struct ScalarEnumerationTraits<ELFYAML::ELF_REL> { |
| 391 | static void enumeration(IO &IO, ELFYAML::ELF_REL &Value); |
| 392 | }; |
| 393 | |
| 394 | template <> |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 395 | struct ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG> { |
| 396 | static void enumeration(IO &IO, ELFYAML::ELF_DYNTAG &Value); |
| 397 | }; |
| 398 | |
| 399 | template <> |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 400 | struct ScalarEnumerationTraits<ELFYAML::ELF_RSS> { |
| 401 | static void enumeration(IO &IO, ELFYAML::ELF_RSS &Value); |
| 402 | }; |
| 403 | |
| 404 | template <> |
| 405 | struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG> { |
| 406 | static void enumeration(IO &IO, ELFYAML::MIPS_AFL_REG &Value); |
| 407 | }; |
| 408 | |
| 409 | template <> |
| 410 | struct ScalarEnumerationTraits<ELFYAML::MIPS_ABI_FP> { |
| 411 | static void enumeration(IO &IO, ELFYAML::MIPS_ABI_FP &Value); |
| 412 | }; |
| 413 | |
| 414 | template <> |
| 415 | struct ScalarEnumerationTraits<ELFYAML::MIPS_AFL_EXT> { |
| 416 | static void enumeration(IO &IO, ELFYAML::MIPS_AFL_EXT &Value); |
| 417 | }; |
| 418 | |
| 419 | template <> |
| 420 | struct ScalarEnumerationTraits<ELFYAML::MIPS_ISA> { |
| 421 | static void enumeration(IO &IO, ELFYAML::MIPS_ISA &Value); |
| 422 | }; |
| 423 | |
| 424 | template <> |
| 425 | struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_ASE> { |
| 426 | static void bitset(IO &IO, ELFYAML::MIPS_AFL_ASE &Value); |
| 427 | }; |
| 428 | |
| 429 | template <> |
| 430 | struct ScalarBitSetTraits<ELFYAML::MIPS_AFL_FLAGS1> { |
| 431 | static void bitset(IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value); |
| 432 | }; |
| 433 | |
| 434 | template <> |
| 435 | struct MappingTraits<ELFYAML::FileHeader> { |
| 436 | static void mapping(IO &IO, ELFYAML::FileHeader &FileHdr); |
| 437 | }; |
| 438 | |
| 439 | template <> struct MappingTraits<ELFYAML::ProgramHeader> { |
| 440 | static void mapping(IO &IO, ELFYAML::ProgramHeader &FileHdr); |
| 441 | }; |
| 442 | |
| 443 | template <> |
| 444 | struct MappingTraits<ELFYAML::Symbol> { |
| 445 | static void mapping(IO &IO, ELFYAML::Symbol &Symbol); |
| 446 | static StringRef validate(IO &IO, ELFYAML::Symbol &Symbol); |
| 447 | }; |
| 448 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 449 | template <> struct MappingTraits<ELFYAML::DynamicEntry> { |
| 450 | static void mapping(IO &IO, ELFYAML::DynamicEntry &Rel); |
| 451 | }; |
| 452 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 453 | template <> struct MappingTraits<ELFYAML::VerdefEntry> { |
| 454 | static void mapping(IO &IO, ELFYAML::VerdefEntry &E); |
| 455 | }; |
| 456 | |
| 457 | template <> struct MappingTraits<ELFYAML::VerneedEntry> { |
| 458 | static void mapping(IO &IO, ELFYAML::VerneedEntry &E); |
| 459 | }; |
| 460 | |
| 461 | template <> struct MappingTraits<ELFYAML::VernauxEntry> { |
| 462 | static void mapping(IO &IO, ELFYAML::VernauxEntry &E); |
| 463 | }; |
| 464 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 465 | template <> struct MappingTraits<ELFYAML::Relocation> { |
| 466 | static void mapping(IO &IO, ELFYAML::Relocation &Rel); |
| 467 | }; |
| 468 | |
| 469 | template <> |
| 470 | struct MappingTraits<std::unique_ptr<ELFYAML::Section>> { |
| 471 | static void mapping(IO &IO, std::unique_ptr<ELFYAML::Section> &Section); |
| 472 | static StringRef validate(IO &io, std::unique_ptr<ELFYAML::Section> &Section); |
| 473 | }; |
| 474 | |
| 475 | template <> |
| 476 | struct MappingTraits<ELFYAML::Object> { |
| 477 | static void mapping(IO &IO, ELFYAML::Object &Object); |
| 478 | }; |
| 479 | |
| 480 | template <> struct MappingTraits<ELFYAML::SectionOrType> { |
| 481 | static void mapping(IO &IO, ELFYAML::SectionOrType §ionOrType); |
| 482 | }; |
| 483 | |
| 484 | template <> struct MappingTraits<ELFYAML::SectionName> { |
| 485 | static void mapping(IO &IO, ELFYAML::SectionName §ionName); |
| 486 | }; |
| 487 | |
| 488 | } // end namespace yaml |
| 489 | } // end namespace llvm |
| 490 | |
| 491 | #endif // LLVM_OBJECTYAML_ELFYAML_H |