LLVM  14.0.0git
XCOFFYAML.cpp
Go to the documentation of this file.
1 //===-- XCOFFYAML.cpp - XCOFF YAMLIO implementation -------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines classes for handling the YAML representation of XCOFF.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 #include <string.h>
16 
17 namespace llvm {
18 namespace XCOFFYAML {
19 
20 Object::Object() { memset(&Header, 0, sizeof(Header)); }
21 
22 } // namespace XCOFFYAML
23 
24 namespace yaml {
25 
27  IO &IO, XCOFF::SectionTypeFlags &Value) {
28 #define ECase(X) IO.bitSetCase(Value, #X, XCOFF::X)
29  ECase(STYP_PAD);
33  ECase(STYP_BSS);
42 #undef ECase
43 }
44 
46  IO &IO, XCOFF::StorageClass &Value) {
47 #define ECase(X) IO.enumCase(Value, #X, XCOFF::X)
48  ECase(C_NULL);
49  ECase(C_AUTO);
50  ECase(C_EXT);
51  ECase(C_STAT);
52  ECase(C_REG);
53  ECase(C_EXTDEF);
54  ECase(C_LABEL);
55  ECase(C_ULABEL);
56  ECase(C_MOS);
57  ECase(C_ARG);
58  ECase(C_STRTAG);
59  ECase(C_MOU);
60  ECase(C_UNTAG);
61  ECase(C_TPDEF);
63  ECase(C_ENTAG);
64  ECase(C_MOE);
66  ECase(C_FIELD);
67  ECase(C_BLOCK);
68  ECase(C_FCN);
69  ECase(C_EOS);
70  ECase(C_FILE);
71  ECase(C_LINE);
72  ECase(C_ALIAS);
73  ECase(C_HIDDEN);
74  ECase(C_HIDEXT);
75  ECase(C_BINCL);
76  ECase(C_EINCL);
77  ECase(C_INFO);
79  ECase(C_DWARF);
80  ECase(C_GSYM);
81  ECase(C_LSYM);
82  ECase(C_PSYM);
83  ECase(C_RSYM);
84  ECase(C_RPSYM);
85  ECase(C_STSYM);
86  ECase(C_TCSYM);
87  ECase(C_BCOMM);
88  ECase(C_ECOML);
89  ECase(C_ECOMM);
90  ECase(C_DECL);
91  ECase(C_ENTRY);
92  ECase(C_FUN);
93  ECase(C_BSTAT);
94  ECase(C_ESTAT);
95  ECase(C_GTLS);
96  ECase(C_STTLS);
97  ECase(C_EFCN);
98 #undef ECase
99 }
100 
102  NSectionFlags(IO &) : Flags(XCOFF::SectionTypeFlags(0)) {}
104 
105  uint32_t denormalize(IO &) { return Flags; }
106 
108 };
109 
111  IO &IO, XCOFFYAML::FileHeader &FileHdr) {
112  IO.mapOptional("MagicNumber", FileHdr.Magic);
113  IO.mapOptional("NumberOfSections", FileHdr.NumberOfSections);
114  IO.mapOptional("CreationTime", FileHdr.TimeStamp);
115  IO.mapOptional("OffsetToSymbolTable", FileHdr.SymbolTableOffset);
116  IO.mapOptional("EntriesInSymbolTable", FileHdr.NumberOfSymTableEntries);
117  IO.mapOptional("AuxiliaryHeaderSize", FileHdr.AuxHeaderSize);
118  IO.mapOptional("Flags", FileHdr.Flags);
119 }
120 
123  IO.mapOptional("Address", R.VirtualAddress);
124  IO.mapOptional("Symbol", R.SymbolIndex);
125  IO.mapOptional("Info", R.Info);
126  IO.mapOptional("Type", R.Type);
127 }
128 
130  XCOFFYAML::Section &Sec) {
131  MappingNormalization<NSectionFlags, uint32_t> NC(IO, Sec.Flags);
132  IO.mapOptional("Name", Sec.SectionName);
133  IO.mapOptional("Address", Sec.Address);
134  IO.mapOptional("Size", Sec.Size);
135  IO.mapOptional("FileOffsetToData", Sec.FileOffsetToData);
136  IO.mapOptional("FileOffsetToRelocations", Sec.FileOffsetToRelocations);
137  IO.mapOptional("FileOffsetToLineNumbers", Sec.FileOffsetToLineNumbers);
138  IO.mapOptional("NumberOfRelocations", Sec.NumberOfRelocations);
139  IO.mapOptional("NumberOfLineNumbers", Sec.NumberOfLineNumbers);
140  IO.mapOptional("Flags", NC->Flags);
141  IO.mapOptional("SectionData", Sec.SectionData);
142  IO.mapOptional("Relocations", Sec.Relocations);
143 }
144 
146  IO.mapOptional("Name", S.SymbolName);
147  IO.mapOptional("Value", S.Value);
148  IO.mapOptional("Section", S.SectionName);
149  IO.mapOptional("SectionIndex", S.SectionIndex);
150  IO.mapOptional("Type", S.Type);
151  IO.mapOptional("StorageClass", S.StorageClass);
152  IO.mapOptional("NumberOfAuxEntries", S.NumberOfAuxEntries);
153 }
154 
156  IO.mapOptional("ContentSize", Str.ContentSize);
157  IO.mapOptional("Length", Str.Length);
158  IO.mapOptional("Strings", Str.Strings);
159  IO.mapOptional("RawContent", Str.RawContent);
160 }
161 
163  IO.mapTag("!XCOFF", true);
164  IO.mapRequired("FileHeader", Obj.Header);
165  IO.mapOptional("Sections", Obj.Sections);
166  IO.mapOptional("Symbols", Obj.Symbols);
167  IO.mapOptional("StringTable", Obj.StrTbl);
168 }
169 
170 } // namespace yaml
171 } // namespace llvm
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::XCOFF::C_EOS
@ C_EOS
Definition: XCOFF.h:170
llvm::XCOFF::C_DWARF
@ C_DWARF
Definition: XCOFF.h:129
llvm::XCOFFYAML::FileHeader
Definition: XCOFFYAML.h:22
llvm::XCOFFYAML::Section::FileOffsetToRelocations
llvm::yaml::Hex64 FileOffsetToRelocations
Definition: XCOFFYAML.h:44
llvm::XCOFF::STYP_EXCEPT
@ STYP_EXCEPT
Definition: XCOFF.h:83
llvm::XCOFF::C_EXTDEF
@ C_EXTDEF
Definition: XCOFF.h:156
llvm::XCOFF::C_USTATIC
@ C_USTATIC
Definition: XCOFF.h:165
llvm::XCOFF::STYP_BSS
@ STYP_BSS
Definition: XCOFF.h:82
llvm::XCOFF::C_ECOML
@ C_ECOML
Definition: XCOFF.h:136
llvm::XCOFF::STYP_TYPCHK
@ STYP_TYPCHK
Definition: XCOFF.h:89
llvm::yaml::ScalarEnumerationTraits< XCOFF::StorageClass >::enumeration
static void enumeration(IO &IO, XCOFF::StorageClass &Value)
Definition: XCOFFYAML.cpp:45
llvm::XCOFF::C_FILE
@ C_FILE
Definition: XCOFF.h:115
llvm::XCOFFYAML::Object::Sections
std::vector< Section > Sections
Definition: XCOFFYAML.h:73
llvm::XCOFF::C_FIELD
@ C_FIELD
Definition: XCOFF.h:169
llvm::XCOFF::C_ESTAT
@ C_ESTAT
Definition: XCOFF.h:124
llvm::XCOFF::C_TCSYM
@ C_TCSYM
Definition: XCOFF.h:177
llvm::XCOFFYAML::FileHeader::Magic
llvm::yaml::Hex16 Magic
Definition: XCOFFYAML.h:23
llvm::XCOFFYAML::Section::FileOffsetToData
llvm::yaml::Hex64 FileOffsetToData
Definition: XCOFFYAML.h:43
llvm::yaml::ScalarBitSetTraits< XCOFF::SectionTypeFlags >::bitset
static void bitset(IO &IO, XCOFF::SectionTypeFlags &Value)
Definition: XCOFFYAML.cpp:26
llvm::XCOFF::C_ALIAS
@ C_ALIAS
Definition: XCOFF.h:172
llvm::XCOFF::C_ULABEL
@ C_ULABEL
Definition: XCOFF.h:158
llvm::XCOFF::C_NULL
@ C_NULL
Definition: XCOFF.h:145
llvm::yaml::NSectionFlags::Flags
XCOFF::SectionTypeFlags Flags
Definition: XCOFFYAML.cpp:107
llvm::XCOFF::C_ENTRY
@ C_ENTRY
Definition: XCOFF.h:122
llvm::XCOFFYAML::Object::StrTbl
StringTable StrTbl
Definition: XCOFFYAML.h:75
llvm::XCOFF::STYP_LOADER
@ STYP_LOADER
Definition: XCOFF.h:87
llvm::XCOFF::C_EFCN
@ C_EFCN
Definition: XCOFF.h:174
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:52
llvm::XCOFF::C_BLOCK
@ C_BLOCK
Definition: XCOFF.h:147
llvm::yaml::NSectionFlags::denormalize
uint32_t denormalize(IO &)
Definition: XCOFFYAML.cpp:105
llvm::XCOFFYAML::Relocation
Definition: XCOFFYAML.h:32
llvm::XCOFFYAML::StringTable
Definition: XCOFFYAML.h:63
llvm::XCOFF::STYP_PAD
@ STYP_PAD
Definition: XCOFF.h:78
llvm::XCOFFYAML::FileHeader::TimeStamp
int32_t TimeStamp
Definition: XCOFFYAML.h:25
llvm::XCOFF::C_HIDDEN
@ C_HIDDEN
Definition: XCOFF.h:173
llvm::XCOFF::STYP_DWARF
@ STYP_DWARF
Definition: XCOFF.h:79
XCOFF.h
llvm::XCOFF::C_STSYM
@ C_STSYM
Definition: XCOFF.h:119
llvm::XCOFF::C_FUN
@ C_FUN
Definition: XCOFF.h:137
llvm::XCOFF::C_REGPARM
@ C_REGPARM
Definition: XCOFF.h:168
llvm::XCOFF::C_UNTAG
@ C_UNTAG
Definition: XCOFF.h:163
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::XCOFF::C_STTLS
@ C_STTLS
Definition: XCOFF.h:126
llvm::XCOFFYAML::FileHeader::Flags
llvm::yaml::Hex16 Flags
Definition: XCOFFYAML.h:29
llvm::XCOFF::C_FCN
@ C_FCN
Definition: XCOFF.h:148
llvm::XCOFF::C_STAT
@ C_STAT
Definition: XCOFF.h:146
llvm::XCOFFYAML::FileHeader::SymbolTableOffset
llvm::yaml::Hex64 SymbolTableOffset
Definition: XCOFFYAML.h:26
llvm::XCOFF::C_BINCL
@ C_BINCL
Definition: XCOFF.h:116
llvm::XCOFF::C_MOU
@ C_MOU
Definition: XCOFF.h:162
llvm::XCOFFYAML::Section::Flags
uint32_t Flags
Definition: XCOFFYAML.h:48
llvm::XCOFF::C_ECOMM
@ C_ECOMM
Definition: XCOFF.h:121
llvm::XCOFF::C_LINE
@ C_LINE
Definition: XCOFF.h:171
llvm::XCOFF::C_EXT
@ C_EXT
Definition: XCOFF.h:141
llvm::XCOFF::C_LABEL
@ C_LABEL
Definition: XCOFF.h:157
llvm::XCOFF::STYP_TDATA
@ STYP_TDATA
Definition: XCOFF.h:85
llvm::XCOFF::StorageClass
StorageClass
Definition: XCOFF.h:113
llvm::XCOFF::C_BSTAT
@ C_BSTAT
Definition: XCOFF.h:123
llvm::XCOFF::STYP_INFO
@ STYP_INFO
Definition: XCOFF.h:84
llvm::yaml::NSectionFlags
Definition: XCOFFYAML.cpp:101
llvm::XCOFF::C_RSYM
@ C_RSYM
Definition: XCOFF.h:134
llvm::XCOFF::STYP_OVRFLO
@ STYP_OVRFLO
Definition: XCOFF.h:90
llvm::XCOFF::C_STRTAG
@ C_STRTAG
Definition: XCOFF.h:161
llvm::XCOFF::C_ENTAG
@ C_ENTAG
Definition: XCOFF.h:166
llvm::XCOFF::C_MOE
@ C_MOE
Definition: XCOFF.h:167
llvm::XCOFF::C_TPDEF
@ C_TPDEF
Definition: XCOFF.h:164
llvm::XCOFF::C_INFO
@ C_INFO
Definition: XCOFF.h:150
llvm::XCOFFYAML::FileHeader::NumberOfSections
uint16_t NumberOfSections
Definition: XCOFFYAML.h:24
llvm::XCOFFYAML::Section::NumberOfRelocations
llvm::yaml::Hex16 NumberOfRelocations
Definition: XCOFFYAML.h:46
llvm::XCOFF::C_RPSYM
@ C_RPSYM
Definition: XCOFF.h:135
llvm::XCOFF::C_HIDEXT
@ C_HIDEXT
Definition: XCOFF.h:149
llvm::XCOFFYAML::Object::Symbols
std::vector< Symbol > Symbols
Definition: XCOFFYAML.h:74
llvm::XCOFFYAML::Object
Definition: XCOFFYAML.h:71
llvm::XCOFF::C_BCOMM
@ C_BCOMM
Definition: XCOFF.h:120
llvm::XCOFFYAML::Section
Definition: XCOFFYAML.h:39
llvm::XCOFFYAML::Object::Object
Object()
Definition: XCOFFYAML.cpp:20
llvm::yaml::NSectionFlags::NSectionFlags
NSectionFlags(IO &, uint32_t C)
Definition: XCOFFYAML.cpp:103
llvm::XCOFF::C_WEAKEXT
@ C_WEAKEXT
Definition: XCOFF.h:142
uint32_t
llvm::XCOFF::SectionTypeFlags
SectionTypeFlags
Definition: XCOFF.h:77
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
XCOFFYAML.h
llvm::XCOFF::C_GSYM
@ C_GSYM
Definition: XCOFF.h:118
llvm::XCOFFYAML::Object::Header
FileHeader Header
Definition: XCOFFYAML.h:72
llvm::XCOFF::C_LSYM
@ C_LSYM
Definition: XCOFF.h:132
llvm::XCOFFYAML::Section::Size
llvm::yaml::Hex64 Size
Definition: XCOFFYAML.h:42
NC
#define NC
Definition: regutils.h:42
llvm::XCOFF::STYP_DEBUG
@ STYP_DEBUG
Definition: XCOFF.h:88
llvm::XCOFFYAML::Section::FileOffsetToLineNumbers
llvm::yaml::Hex64 FileOffsetToLineNumbers
Definition: XCOFFYAML.h:45
llvm::XCOFF::C_REG
@ C_REG
Definition: XCOFF.h:155
ECase
#define ECase(X)
llvm::XCOFF::C_MOS
@ C_MOS
Definition: XCOFF.h:159
llvm::XCOFFYAML::Section::NumberOfLineNumbers
llvm::yaml::Hex16 NumberOfLineNumbers
Definition: XCOFFYAML.h:47
llvm::XCOFFYAML::FileHeader::AuxHeaderSize
uint16_t AuxHeaderSize
Definition: XCOFFYAML.h:28
llvm::XCOFF::STYP_DATA
@ STYP_DATA
Definition: XCOFF.h:81
llvm::XCOFFYAML::Section::Address
llvm::yaml::Hex64 Address
Definition: XCOFFYAML.h:41
llvm::XCOFF::STYP_TEXT
@ STYP_TEXT
Definition: XCOFF.h:80
llvm::XCOFF::C_PSYM
@ C_PSYM
Definition: XCOFF.h:133
llvm::yaml::NSectionFlags::NSectionFlags
NSectionFlags(IO &)
Definition: XCOFFYAML.cpp:102
llvm::XCOFFYAML::Section::SectionData
yaml::BinaryRef SectionData
Definition: XCOFFYAML.h:49
llvm::XCOFFYAML::FileHeader::NumberOfSymTableEntries
uint32_t NumberOfSymTableEntries
Definition: XCOFFYAML.h:27
llvm::XCOFFYAML::Section::Relocations
std::vector< Relocation > Relocations
Definition: XCOFFYAML.h:50
llvm::XCOFF::STYP_TBSS
@ STYP_TBSS
Definition: XCOFF.h:86
llvm::XCOFF::C_EINCL
@ C_EINCL
Definition: XCOFF.h:117
llvm::XCOFF::C_DECL
@ C_DECL
Definition: XCOFF.h:151
llvm::XCOFF::C_GTLS
@ C_GTLS
Definition: XCOFF.h:125
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::XCOFFYAML::Symbol
Definition: XCOFFYAML.h:53
llvm::XCOFFYAML::Section::SectionName
StringRef SectionName
Definition: XCOFFYAML.h:40
llvm::XCOFF::C_ARG
@ C_ARG
Definition: XCOFF.h:160
llvm::XCOFF::C_AUTO
@ C_AUTO
Definition: XCOFF.h:154