LCOV - code coverage report
Current view: top level - lib/ObjectYAML - COFFYAML.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 259 354 73.2 %
Date: 2017-09-14 15:23:50 Functions: 20 28 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- COFFYAML.cpp - COFF YAMLIO implementation --------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file defines classes for handling the YAML representation of COFF.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/ObjectYAML/COFFYAML.h"
      15             : #include "llvm/ADT/StringRef.h"
      16             : #include "llvm/Support/YAMLTraits.h"
      17             : #include <cstdint>
      18             : #include <cstring>
      19             : 
      20             : #define ECase(X) IO.enumCase(Value, #X, COFF::X);
      21             : 
      22             : namespace llvm {
      23             : 
      24             : namespace COFFYAML {
      25             : 
      26        2382 : Section::Section() { memset(&Header, 0, sizeof(COFF::section)); }
      27        6864 : Symbol::Symbol() { memset(&Header, 0, sizeof(COFF::symbol)); }
      28         704 : Object::Object() { memset(&Header, 0, sizeof(COFF::header)); }
      29             : 
      30             : } // end namespace COFFYAML
      31             : 
      32             : namespace yaml {
      33             : 
      34          45 : void ScalarEnumerationTraits<COFFYAML::COMDATType>::enumeration(
      35             :     IO &IO, COFFYAML::COMDATType &Value) {
      36          45 :   IO.enumCase(Value, "0", 0);
      37          45 :   ECase(IMAGE_COMDAT_SELECT_NODUPLICATES);
      38          45 :   ECase(IMAGE_COMDAT_SELECT_ANY);
      39          45 :   ECase(IMAGE_COMDAT_SELECT_SAME_SIZE);
      40          45 :   ECase(IMAGE_COMDAT_SELECT_EXACT_MATCH);
      41          45 :   ECase(IMAGE_COMDAT_SELECT_ASSOCIATIVE);
      42          45 :   ECase(IMAGE_COMDAT_SELECT_LARGEST);
      43          45 :   ECase(IMAGE_COMDAT_SELECT_NEWEST);
      44          45 : }
      45             : 
      46             : void
      47           6 : ScalarEnumerationTraits<COFFYAML::WeakExternalCharacteristics>::enumeration(
      48             :     IO &IO, COFFYAML::WeakExternalCharacteristics &Value) {
      49           6 :   IO.enumCase(Value, "0", 0);
      50           6 :   ECase(IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY);
      51           6 :   ECase(IMAGE_WEAK_EXTERN_SEARCH_LIBRARY);
      52           6 :   ECase(IMAGE_WEAK_EXTERN_SEARCH_ALIAS);
      53           6 : }
      54             : 
      55           0 : void ScalarEnumerationTraits<COFFYAML::AuxSymbolType>::enumeration(
      56             :     IO &IO, COFFYAML::AuxSymbolType &Value) {
      57           0 :   ECase(IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF);
      58           0 : }
      59             : 
      60         176 : void ScalarEnumerationTraits<COFF::MachineTypes>::enumeration(
      61             :     IO &IO, COFF::MachineTypes &Value) {
      62         176 :   ECase(IMAGE_FILE_MACHINE_UNKNOWN);
      63         176 :   ECase(IMAGE_FILE_MACHINE_AM33);
      64         176 :   ECase(IMAGE_FILE_MACHINE_AMD64);
      65         176 :   ECase(IMAGE_FILE_MACHINE_ARM);
      66         176 :   ECase(IMAGE_FILE_MACHINE_ARMNT);
      67         176 :   ECase(IMAGE_FILE_MACHINE_ARM64);
      68         176 :   ECase(IMAGE_FILE_MACHINE_EBC);
      69         176 :   ECase(IMAGE_FILE_MACHINE_I386);
      70         176 :   ECase(IMAGE_FILE_MACHINE_IA64);
      71         176 :   ECase(IMAGE_FILE_MACHINE_M32R);
      72         176 :   ECase(IMAGE_FILE_MACHINE_MIPS16);
      73         176 :   ECase(IMAGE_FILE_MACHINE_MIPSFPU);
      74         176 :   ECase(IMAGE_FILE_MACHINE_MIPSFPU16);
      75         176 :   ECase(IMAGE_FILE_MACHINE_POWERPC);
      76         176 :   ECase(IMAGE_FILE_MACHINE_POWERPCFP);
      77         176 :   ECase(IMAGE_FILE_MACHINE_R4000);
      78         176 :   ECase(IMAGE_FILE_MACHINE_SH3);
      79         176 :   ECase(IMAGE_FILE_MACHINE_SH3DSP);
      80         176 :   ECase(IMAGE_FILE_MACHINE_SH4);
      81         176 :   ECase(IMAGE_FILE_MACHINE_SH5);
      82         176 :   ECase(IMAGE_FILE_MACHINE_THUMB);
      83         176 :   ECase(IMAGE_FILE_MACHINE_WCEMIPSV2);
      84         176 : }
      85             : 
      86         858 : void ScalarEnumerationTraits<COFF::SymbolBaseType>::enumeration(
      87             :     IO &IO, COFF::SymbolBaseType &Value) {
      88         858 :   ECase(IMAGE_SYM_TYPE_NULL);
      89         858 :   ECase(IMAGE_SYM_TYPE_VOID);
      90         858 :   ECase(IMAGE_SYM_TYPE_CHAR);
      91         858 :   ECase(IMAGE_SYM_TYPE_SHORT);
      92         858 :   ECase(IMAGE_SYM_TYPE_INT);
      93         858 :   ECase(IMAGE_SYM_TYPE_LONG);
      94         858 :   ECase(IMAGE_SYM_TYPE_FLOAT);
      95         858 :   ECase(IMAGE_SYM_TYPE_DOUBLE);
      96         858 :   ECase(IMAGE_SYM_TYPE_STRUCT);
      97         858 :   ECase(IMAGE_SYM_TYPE_UNION);
      98         858 :   ECase(IMAGE_SYM_TYPE_ENUM);
      99         858 :   ECase(IMAGE_SYM_TYPE_MOE);
     100         858 :   ECase(IMAGE_SYM_TYPE_BYTE);
     101         858 :   ECase(IMAGE_SYM_TYPE_WORD);
     102         858 :   ECase(IMAGE_SYM_TYPE_UINT);
     103         858 :   ECase(IMAGE_SYM_TYPE_DWORD);
     104         858 : }
     105             : 
     106         858 : void ScalarEnumerationTraits<COFF::SymbolStorageClass>::enumeration(
     107             :     IO &IO, COFF::SymbolStorageClass &Value) {
     108         858 :   ECase(IMAGE_SYM_CLASS_END_OF_FUNCTION);
     109         858 :   ECase(IMAGE_SYM_CLASS_NULL);
     110         858 :   ECase(IMAGE_SYM_CLASS_AUTOMATIC);
     111         858 :   ECase(IMAGE_SYM_CLASS_EXTERNAL);
     112         858 :   ECase(IMAGE_SYM_CLASS_STATIC);
     113         858 :   ECase(IMAGE_SYM_CLASS_REGISTER);
     114         858 :   ECase(IMAGE_SYM_CLASS_EXTERNAL_DEF);
     115         858 :   ECase(IMAGE_SYM_CLASS_LABEL);
     116         858 :   ECase(IMAGE_SYM_CLASS_UNDEFINED_LABEL);
     117         858 :   ECase(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT);
     118         858 :   ECase(IMAGE_SYM_CLASS_ARGUMENT);
     119         858 :   ECase(IMAGE_SYM_CLASS_STRUCT_TAG);
     120         858 :   ECase(IMAGE_SYM_CLASS_MEMBER_OF_UNION);
     121         858 :   ECase(IMAGE_SYM_CLASS_UNION_TAG);
     122         858 :   ECase(IMAGE_SYM_CLASS_TYPE_DEFINITION);
     123         858 :   ECase(IMAGE_SYM_CLASS_UNDEFINED_STATIC);
     124         858 :   ECase(IMAGE_SYM_CLASS_ENUM_TAG);
     125         858 :   ECase(IMAGE_SYM_CLASS_MEMBER_OF_ENUM);
     126         858 :   ECase(IMAGE_SYM_CLASS_REGISTER_PARAM);
     127         858 :   ECase(IMAGE_SYM_CLASS_BIT_FIELD);
     128         858 :   ECase(IMAGE_SYM_CLASS_BLOCK);
     129         858 :   ECase(IMAGE_SYM_CLASS_FUNCTION);
     130         858 :   ECase(IMAGE_SYM_CLASS_END_OF_STRUCT);
     131         858 :   ECase(IMAGE_SYM_CLASS_FILE);
     132         858 :   ECase(IMAGE_SYM_CLASS_SECTION);
     133         858 :   ECase(IMAGE_SYM_CLASS_WEAK_EXTERNAL);
     134         858 :   ECase(IMAGE_SYM_CLASS_CLR_TOKEN);
     135         858 : }
     136             : 
     137         858 : void ScalarEnumerationTraits<COFF::SymbolComplexType>::enumeration(
     138             :     IO &IO, COFF::SymbolComplexType &Value) {
     139         858 :   ECase(IMAGE_SYM_DTYPE_NULL);
     140         858 :   ECase(IMAGE_SYM_DTYPE_POINTER);
     141         858 :   ECase(IMAGE_SYM_DTYPE_FUNCTION);
     142         858 :   ECase(IMAGE_SYM_DTYPE_ARRAY);
     143         858 : }
     144             : 
     145         107 : void ScalarEnumerationTraits<COFF::RelocationTypeI386>::enumeration(
     146             :     IO &IO, COFF::RelocationTypeI386 &Value) {
     147         107 :   ECase(IMAGE_REL_I386_ABSOLUTE);
     148         107 :   ECase(IMAGE_REL_I386_DIR16);
     149         107 :   ECase(IMAGE_REL_I386_REL16);
     150         107 :   ECase(IMAGE_REL_I386_DIR32);
     151         107 :   ECase(IMAGE_REL_I386_DIR32NB);
     152         107 :   ECase(IMAGE_REL_I386_SEG12);
     153         107 :   ECase(IMAGE_REL_I386_SECTION);
     154         107 :   ECase(IMAGE_REL_I386_SECREL);
     155         107 :   ECase(IMAGE_REL_I386_TOKEN);
     156         107 :   ECase(IMAGE_REL_I386_SECREL7);
     157         107 :   ECase(IMAGE_REL_I386_REL32);
     158         107 : }
     159             : 
     160         280 : void ScalarEnumerationTraits<COFF::RelocationTypeAMD64>::enumeration(
     161             :     IO &IO, COFF::RelocationTypeAMD64 &Value) {
     162         280 :   ECase(IMAGE_REL_AMD64_ABSOLUTE);
     163         280 :   ECase(IMAGE_REL_AMD64_ADDR64);
     164         280 :   ECase(IMAGE_REL_AMD64_ADDR32);
     165         280 :   ECase(IMAGE_REL_AMD64_ADDR32NB);
     166         280 :   ECase(IMAGE_REL_AMD64_REL32);
     167         280 :   ECase(IMAGE_REL_AMD64_REL32_1);
     168         280 :   ECase(IMAGE_REL_AMD64_REL32_2);
     169         280 :   ECase(IMAGE_REL_AMD64_REL32_3);
     170         280 :   ECase(IMAGE_REL_AMD64_REL32_4);
     171         280 :   ECase(IMAGE_REL_AMD64_REL32_5);
     172         280 :   ECase(IMAGE_REL_AMD64_SECTION);
     173         280 :   ECase(IMAGE_REL_AMD64_SECREL);
     174         280 :   ECase(IMAGE_REL_AMD64_SECREL7);
     175         280 :   ECase(IMAGE_REL_AMD64_TOKEN);
     176         280 :   ECase(IMAGE_REL_AMD64_SREL32);
     177         280 :   ECase(IMAGE_REL_AMD64_PAIR);
     178         280 :   ECase(IMAGE_REL_AMD64_SSPAN32);
     179         280 : }
     180             : 
     181           0 : void ScalarEnumerationTraits<COFF::WindowsSubsystem>::enumeration(
     182             :     IO &IO, COFF::WindowsSubsystem &Value) {
     183           0 :   ECase(IMAGE_SUBSYSTEM_UNKNOWN);
     184           0 :   ECase(IMAGE_SUBSYSTEM_NATIVE);
     185           0 :   ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI);
     186           0 :   ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI);
     187           0 :   ECase(IMAGE_SUBSYSTEM_OS2_CUI);
     188           0 :   ECase(IMAGE_SUBSYSTEM_POSIX_CUI);
     189           0 :   ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS);
     190           0 :   ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI);
     191           0 :   ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION);
     192           0 :   ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
     193           0 :   ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER);
     194           0 :   ECase(IMAGE_SUBSYSTEM_EFI_ROM);
     195           0 :   ECase(IMAGE_SUBSYSTEM_XBOX);
     196           0 :   ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION);
     197           0 : }
     198             : #undef ECase
     199             : 
     200             : #define BCase(X) IO.bitSetCase(Value, #X, COFF::X);
     201         174 : void ScalarBitSetTraits<COFF::Characteristics>::bitset(
     202             :     IO &IO, COFF::Characteristics &Value) {
     203         174 :   BCase(IMAGE_FILE_RELOCS_STRIPPED);
     204         174 :   BCase(IMAGE_FILE_EXECUTABLE_IMAGE);
     205         174 :   BCase(IMAGE_FILE_LINE_NUMS_STRIPPED);
     206         174 :   BCase(IMAGE_FILE_LOCAL_SYMS_STRIPPED);
     207         174 :   BCase(IMAGE_FILE_AGGRESSIVE_WS_TRIM);
     208         174 :   BCase(IMAGE_FILE_LARGE_ADDRESS_AWARE);
     209         174 :   BCase(IMAGE_FILE_BYTES_REVERSED_LO);
     210         174 :   BCase(IMAGE_FILE_32BIT_MACHINE);
     211         174 :   BCase(IMAGE_FILE_DEBUG_STRIPPED);
     212         174 :   BCase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP);
     213         174 :   BCase(IMAGE_FILE_NET_RUN_FROM_SWAP);
     214         174 :   BCase(IMAGE_FILE_SYSTEM);
     215         174 :   BCase(IMAGE_FILE_DLL);
     216         174 :   BCase(IMAGE_FILE_UP_SYSTEM_ONLY);
     217         174 :   BCase(IMAGE_FILE_BYTES_REVERSED_HI);
     218         174 : }
     219             : 
     220         397 : void ScalarBitSetTraits<COFF::SectionCharacteristics>::bitset(
     221             :     IO &IO, COFF::SectionCharacteristics &Value) {
     222         397 :   BCase(IMAGE_SCN_TYPE_NOLOAD);
     223         397 :   BCase(IMAGE_SCN_TYPE_NO_PAD);
     224         397 :   BCase(IMAGE_SCN_CNT_CODE);
     225         397 :   BCase(IMAGE_SCN_CNT_INITIALIZED_DATA);
     226         397 :   BCase(IMAGE_SCN_CNT_UNINITIALIZED_DATA);
     227         397 :   BCase(IMAGE_SCN_LNK_OTHER);
     228         397 :   BCase(IMAGE_SCN_LNK_INFO);
     229         397 :   BCase(IMAGE_SCN_LNK_REMOVE);
     230         397 :   BCase(IMAGE_SCN_LNK_COMDAT);
     231         397 :   BCase(IMAGE_SCN_GPREL);
     232         397 :   BCase(IMAGE_SCN_MEM_PURGEABLE);
     233         397 :   BCase(IMAGE_SCN_MEM_16BIT);
     234         397 :   BCase(IMAGE_SCN_MEM_LOCKED);
     235         397 :   BCase(IMAGE_SCN_MEM_PRELOAD);
     236         397 :   BCase(IMAGE_SCN_LNK_NRELOC_OVFL);
     237         397 :   BCase(IMAGE_SCN_MEM_DISCARDABLE);
     238         397 :   BCase(IMAGE_SCN_MEM_NOT_CACHED);
     239         397 :   BCase(IMAGE_SCN_MEM_NOT_PAGED);
     240         397 :   BCase(IMAGE_SCN_MEM_SHARED);
     241         397 :   BCase(IMAGE_SCN_MEM_EXECUTE);
     242         397 :   BCase(IMAGE_SCN_MEM_READ);
     243         397 :   BCase(IMAGE_SCN_MEM_WRITE);
     244         397 : }
     245             : 
     246           0 : void ScalarBitSetTraits<COFF::DLLCharacteristics>::bitset(
     247             :     IO &IO, COFF::DLLCharacteristics &Value) {
     248           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA);
     249           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE);
     250           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY);
     251           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_NX_COMPAT);
     252           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION);
     253           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_NO_SEH);
     254           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_NO_BIND);
     255           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_APPCONTAINER);
     256           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER);
     257           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_GUARD_CF);
     258           0 :   BCase(IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE);
     259           0 : }
     260             : #undef BCase
     261             : 
     262             : namespace {
     263             : 
     264             : struct NSectionSelectionType {
     265             :   NSectionSelectionType(IO &)
     266         720 :       : SelectionType(COFFYAML::COMDATType(0)) {}
     267             :   NSectionSelectionType(IO &, uint8_t C)
     268          54 :       : SelectionType(COFFYAML::COMDATType(C)) {}
     269             : 
     270         360 :   uint8_t denormalize(IO &) { return SelectionType; }
     271             : 
     272             :   COFFYAML::COMDATType SelectionType;
     273             : };
     274             : 
     275             : struct NWeakExternalCharacteristics {
     276             :   NWeakExternalCharacteristics(IO &)
     277          10 :       : Characteristics(COFFYAML::WeakExternalCharacteristics(0)) {}
     278             :   NWeakExternalCharacteristics(IO &, uint32_t C)
     279           2 :       : Characteristics(COFFYAML::WeakExternalCharacteristics(C)) {}
     280             : 
     281           5 :   uint32_t denormalize(IO &) { return Characteristics; }
     282             : 
     283             :   COFFYAML::WeakExternalCharacteristics Characteristics;
     284             : };
     285             : 
     286             : struct NSectionCharacteristics {
     287             :   NSectionCharacteristics(IO &)
     288         380 :       : Characteristics(COFF::SectionCharacteristics(0)) {}
     289             :   NSectionCharacteristics(IO &, uint32_t C)
     290          17 :       : Characteristics(COFF::SectionCharacteristics(C)) {}
     291             : 
     292         380 :   uint32_t denormalize(IO &) { return Characteristics; }
     293             : 
     294             :   COFF::SectionCharacteristics Characteristics;
     295             : };
     296             : 
     297             : struct NAuxTokenType {
     298             :   NAuxTokenType(IO &)
     299           0 :       : AuxType(COFFYAML::AuxSymbolType(0)) {}
     300             :   NAuxTokenType(IO &, uint8_t C)
     301           0 :       : AuxType(COFFYAML::AuxSymbolType(C)) {}
     302             : 
     303           0 :   uint32_t denormalize(IO &) { return AuxType; }
     304             : 
     305             :   COFFYAML::AuxSymbolType AuxType;
     306             : };
     307             : 
     308             : struct NStorageClass {
     309         815 :   NStorageClass(IO &) : StorageClass(COFF::SymbolStorageClass(0)) {}
     310          43 :   NStorageClass(IO &, uint8_t S) : StorageClass(COFF::SymbolStorageClass(S)) {}
     311             : 
     312         815 :   uint8_t denormalize(IO &) { return StorageClass; }
     313             : 
     314             :   COFF::SymbolStorageClass StorageClass;
     315             : };
     316             : 
     317             : struct NMachine {
     318         168 :   NMachine(IO &) : Machine(COFF::MachineTypes(0)) {}
     319           8 :   NMachine(IO &, uint16_t M) : Machine(COFF::MachineTypes(M)) {}
     320             : 
     321         168 :   uint16_t denormalize(IO &) { return Machine; }
     322             : 
     323             :   COFF::MachineTypes Machine;
     324             : };
     325             : 
     326             : struct NHeaderCharacteristics {
     327         168 :   NHeaderCharacteristics(IO &) : Characteristics(COFF::Characteristics(0)) {}
     328             :   NHeaderCharacteristics(IO &, uint16_t C)
     329           8 :       : Characteristics(COFF::Characteristics(C)) {}
     330             : 
     331         168 :   uint16_t denormalize(IO &) { return Characteristics; }
     332             : 
     333             :   COFF::Characteristics Characteristics;
     334             : };
     335             : 
     336             : template <typename RelocType>
     337             : struct NType {
     338         370 :   NType(IO &) : Type(RelocType(0)) {}
     339          17 :   NType(IO &, uint16_t T) : Type(RelocType(T)) {}
     340             : 
     341         370 :   uint16_t denormalize(IO &) { return Type; }
     342             : 
     343             :   RelocType Type;
     344             : };
     345             : 
     346             : struct NWindowsSubsystem {
     347           0 :   NWindowsSubsystem(IO &) : Subsystem(COFF::WindowsSubsystem(0)) {}
     348           0 :   NWindowsSubsystem(IO &, uint16_t C) : Subsystem(COFF::WindowsSubsystem(C)) {}
     349             : 
     350           0 :   uint16_t denormalize(IO &) { return Subsystem; }
     351             : 
     352             :   COFF::WindowsSubsystem Subsystem;
     353             : };
     354             : 
     355             : struct NDLLCharacteristics {
     356           0 :   NDLLCharacteristics(IO &) : Characteristics(COFF::DLLCharacteristics(0)) {}
     357             :   NDLLCharacteristics(IO &, uint16_t C)
     358           0 :       : Characteristics(COFF::DLLCharacteristics(C)) {}
     359             : 
     360           0 :   uint16_t denormalize(IO &) { return Characteristics; }
     361             : 
     362             :   COFF::DLLCharacteristics Characteristics;
     363             : };
     364             : 
     365             : } // end anonymous namespace
     366             : 
     367         428 : void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO,
     368             :                                                   COFFYAML::Relocation &Rel) {
     369         856 :   IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
     370         856 :   IO.mapRequired("SymbolName", Rel.SymbolName);
     371             : 
     372         428 :   COFF::header &H = *static_cast<COFF::header *>(IO.getContext());
     373         428 :   if (H.Machine == COFF::IMAGE_FILE_MACHINE_I386) {
     374             :     MappingNormalization<NType<COFF::RelocationTypeI386>, uint16_t> NT(
     375         321 :         IO, Rel.Type);
     376         214 :     IO.mapRequired("Type", NT->Type);
     377         321 :   } else if (H.Machine == COFF::IMAGE_FILE_MACHINE_AMD64) {
     378             :     MappingNormalization<NType<COFF::RelocationTypeAMD64>, uint16_t> NT(
     379         840 :         IO, Rel.Type);
     380         560 :     IO.mapRequired("Type", NT->Type);
     381             :   } else {
     382          41 :     IO.mapRequired("Type", Rel.Type);
     383             :   }
     384         428 : }
     385             : 
     386           0 : void MappingTraits<COFF::DataDirectory>::mapping(IO &IO,
     387             :                                                  COFF::DataDirectory &DD) {
     388           0 :   IO.mapRequired("RelativeVirtualAddress", DD.RelativeVirtualAddress);
     389           0 :   IO.mapRequired("Size", DD.Size);
     390           0 : }
     391             : 
     392           0 : void MappingTraits<COFFYAML::PEHeader>::mapping(IO &IO,
     393             :                                                 COFFYAML::PEHeader &PH) {
     394             :   MappingNormalization<NWindowsSubsystem, uint16_t> NWS(IO,
     395           0 :                                                         PH.Header.Subsystem);
     396             :   MappingNormalization<NDLLCharacteristics, uint16_t> NDC(
     397           0 :       IO, PH.Header.DLLCharacteristics);
     398             : 
     399           0 :   IO.mapRequired("AddressOfEntryPoint", PH.Header.AddressOfEntryPoint);
     400           0 :   IO.mapRequired("ImageBase", PH.Header.ImageBase);
     401           0 :   IO.mapRequired("SectionAlignment", PH.Header.SectionAlignment);
     402           0 :   IO.mapRequired("FileAlignment", PH.Header.FileAlignment);
     403           0 :   IO.mapRequired("MajorOperatingSystemVersion",
     404             :                  PH.Header.MajorOperatingSystemVersion);
     405           0 :   IO.mapRequired("MinorOperatingSystemVersion",
     406             :                  PH.Header.MinorOperatingSystemVersion);
     407           0 :   IO.mapRequired("MajorImageVersion", PH.Header.MajorImageVersion);
     408           0 :   IO.mapRequired("MinorImageVersion", PH.Header.MinorImageVersion);
     409           0 :   IO.mapRequired("MajorSubsystemVersion", PH.Header.MajorSubsystemVersion);
     410           0 :   IO.mapRequired("MinorSubsystemVersion", PH.Header.MinorSubsystemVersion);
     411           0 :   IO.mapRequired("Subsystem", NWS->Subsystem);
     412           0 :   IO.mapRequired("DLLCharacteristics", NDC->Characteristics);
     413           0 :   IO.mapRequired("SizeOfStackReserve", PH.Header.SizeOfStackReserve);
     414           0 :   IO.mapRequired("SizeOfStackCommit", PH.Header.SizeOfStackCommit);
     415           0 :   IO.mapRequired("SizeOfHeapReserve", PH.Header.SizeOfHeapReserve);
     416           0 :   IO.mapRequired("SizeOfHeapCommit", PH.Header.SizeOfHeapCommit);
     417             : 
     418           0 :   IO.mapOptional("ExportTable", PH.DataDirectories[COFF::EXPORT_TABLE]);
     419           0 :   IO.mapOptional("ImportTable", PH.DataDirectories[COFF::IMPORT_TABLE]);
     420           0 :   IO.mapOptional("ResourceTable", PH.DataDirectories[COFF::RESOURCE_TABLE]);
     421           0 :   IO.mapOptional("ExceptionTable", PH.DataDirectories[COFF::EXCEPTION_TABLE]);
     422           0 :   IO.mapOptional("CertificateTable", PH.DataDirectories[COFF::CERTIFICATE_TABLE]);
     423           0 :   IO.mapOptional("BaseRelocationTable",
     424             :                  PH.DataDirectories[COFF::BASE_RELOCATION_TABLE]);
     425           0 :   IO.mapOptional("Debug", PH.DataDirectories[COFF::DEBUG_DIRECTORY]);
     426           0 :   IO.mapOptional("Architecture", PH.DataDirectories[COFF::ARCHITECTURE]);
     427           0 :   IO.mapOptional("GlobalPtr", PH.DataDirectories[COFF::GLOBAL_PTR]);
     428           0 :   IO.mapOptional("TlsTable", PH.DataDirectories[COFF::TLS_TABLE]);
     429           0 :   IO.mapOptional("LoadConfigTable",
     430             :                  PH.DataDirectories[COFF::LOAD_CONFIG_TABLE]);
     431           0 :   IO.mapOptional("BoundImport", PH.DataDirectories[COFF::BOUND_IMPORT]);
     432           0 :   IO.mapOptional("IAT", PH.DataDirectories[COFF::IAT]);
     433           0 :   IO.mapOptional("DelayImportDescriptor",
     434             :                  PH.DataDirectories[COFF::DELAY_IMPORT_DESCRIPTOR]);
     435           0 :   IO.mapOptional("ClrRuntimeHeader",
     436             :                  PH.DataDirectories[COFF::CLR_RUNTIME_HEADER]);
     437           0 : }
     438             : 
     439         176 : void MappingTraits<COFF::header>::mapping(IO &IO, COFF::header &H) {
     440         528 :   MappingNormalization<NMachine, uint16_t> NM(IO, H.Machine);
     441             :   MappingNormalization<NHeaderCharacteristics, uint16_t> NC(IO,
     442         528 :                                                             H.Characteristics);
     443             : 
     444         352 :   IO.mapRequired("Machine", NM->Machine);
     445         352 :   IO.mapOptional("Characteristics", NC->Characteristics);
     446         176 :   IO.setContext(static_cast<void *>(&H));
     447         176 : }
     448             : 
     449           0 : void MappingTraits<COFF::AuxiliaryFunctionDefinition>::mapping(
     450             :     IO &IO, COFF::AuxiliaryFunctionDefinition &AFD) {
     451           0 :   IO.mapRequired("TagIndex", AFD.TagIndex);
     452           0 :   IO.mapRequired("TotalSize", AFD.TotalSize);
     453           0 :   IO.mapRequired("PointerToLinenumber", AFD.PointerToLinenumber);
     454           0 :   IO.mapRequired("PointerToNextFunction", AFD.PointerToNextFunction);
     455           0 : }
     456             : 
     457           0 : void MappingTraits<COFF::AuxiliarybfAndefSymbol>::mapping(
     458             :     IO &IO, COFF::AuxiliarybfAndefSymbol &AAS) {
     459           0 :   IO.mapRequired("Linenumber", AAS.Linenumber);
     460           0 :   IO.mapRequired("PointerToNextFunction", AAS.PointerToNextFunction);
     461           0 : }
     462             : 
     463           6 : void MappingTraits<COFF::AuxiliaryWeakExternal>::mapping(
     464             :     IO &IO, COFF::AuxiliaryWeakExternal &AWE) {
     465             :   MappingNormalization<NWeakExternalCharacteristics, uint32_t> NWEC(
     466          18 :       IO, AWE.Characteristics);
     467          12 :   IO.mapRequired("TagIndex", AWE.TagIndex);
     468          12 :   IO.mapRequired("Characteristics", NWEC->Characteristics);
     469           6 : }
     470             : 
     471         387 : void MappingTraits<COFF::AuxiliarySectionDefinition>::mapping(
     472             :     IO &IO, COFF::AuxiliarySectionDefinition &ASD) {
     473             :   MappingNormalization<NSectionSelectionType, uint8_t> NSST(
     474        1161 :       IO, ASD.Selection);
     475             : 
     476         774 :   IO.mapRequired("Length", ASD.Length);
     477         774 :   IO.mapRequired("NumberOfRelocations", ASD.NumberOfRelocations);
     478         774 :   IO.mapRequired("NumberOfLinenumbers", ASD.NumberOfLinenumbers);
     479         774 :   IO.mapRequired("CheckSum", ASD.CheckSum);
     480         774 :   IO.mapRequired("Number", ASD.Number);
     481         774 :   IO.mapOptional("Selection", NSST->SelectionType, COFFYAML::COMDATType(0));
     482         387 : }
     483             : 
     484           0 : void MappingTraits<COFF::AuxiliaryCLRToken>::mapping(
     485             :     IO &IO, COFF::AuxiliaryCLRToken &ACT) {
     486           0 :   MappingNormalization<NAuxTokenType, uint8_t> NATT(IO, ACT.AuxType);
     487           0 :   IO.mapRequired("AuxType", NATT->AuxType);
     488           0 :   IO.mapRequired("SymbolTableIndex", ACT.SymbolTableIndex);
     489           0 : }
     490             : 
     491         858 : void MappingTraits<COFFYAML::Symbol>::mapping(IO &IO, COFFYAML::Symbol &S) {
     492        2574 :   MappingNormalization<NStorageClass, uint8_t> NS(IO, S.Header.StorageClass);
     493             : 
     494        1716 :   IO.mapRequired("Name", S.Name);
     495        1716 :   IO.mapRequired("Value", S.Header.Value);
     496        1716 :   IO.mapRequired("SectionNumber", S.Header.SectionNumber);
     497        1716 :   IO.mapRequired("SimpleType", S.SimpleType);
     498        1716 :   IO.mapRequired("ComplexType", S.ComplexType);
     499        1716 :   IO.mapRequired("StorageClass", NS->StorageClass);
     500        1716 :   IO.mapOptional("FunctionDefinition", S.FunctionDefinition);
     501        1716 :   IO.mapOptional("bfAndefSymbol", S.bfAndefSymbol);
     502        1716 :   IO.mapOptional("WeakExternal", S.WeakExternal);
     503        1716 :   IO.mapOptional("File", S.File, StringRef());
     504        1716 :   IO.mapOptional("SectionDefinition", S.SectionDefinition);
     505        1716 :   IO.mapOptional("CLRToken", S.CLRToken);
     506         858 : }
     507             : 
     508         397 : void MappingTraits<COFFYAML::Section>::mapping(IO &IO, COFFYAML::Section &Sec) {
     509             :   MappingNormalization<NSectionCharacteristics, uint32_t> NC(
     510        1191 :       IO, Sec.Header.Characteristics);
     511         794 :   IO.mapRequired("Name", Sec.Name);
     512         794 :   IO.mapRequired("Characteristics", NC->Characteristics);
     513         794 :   IO.mapOptional("VirtualAddress", Sec.Header.VirtualAddress, 0U);
     514         794 :   IO.mapOptional("VirtualSize", Sec.Header.VirtualSize, 0U);
     515         794 :   IO.mapOptional("Alignment", Sec.Alignment, 0U);
     516             : 
     517             :   // If this is a .debug$S or .debug$T section parse the semantic representation
     518             :   // of the symbols/types.  If it is any other kind of section, just deal in raw
     519             :   // bytes.
     520         794 :   IO.mapOptional("SectionData", Sec.SectionData);
     521         432 :   if (Sec.Name == ".debug$S")
     522          35 :     IO.mapOptional("Subsections", Sec.DebugS);
     523         389 :   else if (Sec.Name == ".debug$T")
     524          27 :     IO.mapOptional("Types", Sec.DebugT);
     525             : 
     526         794 :   IO.mapOptional("Relocations", Sec.Relocations);
     527         397 : }
     528             : 
     529         176 : void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) {
     530         352 :   IO.mapTag("!COFF", true);
     531         352 :   IO.mapOptional("OptionalHeader", Obj.OptionalHeader);
     532         352 :   IO.mapRequired("header", Obj.Header);
     533         352 :   IO.mapRequired("sections", Obj.Sections);
     534         352 :   IO.mapRequired("symbols", Obj.Symbols);
     535         176 : }
     536             : 
     537             : } // end namespace yaml
     538             : 
     539             : } // end namespace llvm

Generated by: LCOV version 1.13