[RISCV] Regenerate autogen test to remove spurious diff
[llvm-project.git] / llvm / docs / yaml2obj.rst
blobf58fdd4f398eafc6b318be70f9759b0b229acd46
1 yaml2obj
2 ========
4 yaml2obj takes a YAML description of an object file and converts it to a binary
5 file.
7     $ yaml2obj input-file
9 .. program:: yaml2obj
11 Outputs the binary to stdout.
13 COFF Syntax
14 -----------
16 Here's a sample COFF file.
18 .. code-block:: yaml
20   header:
21     Machine: IMAGE_FILE_MACHINE_I386 # (0x14C)
23   sections:
24     - Name: .text
25       Characteristics: [ IMAGE_SCN_CNT_CODE
26                        , IMAGE_SCN_ALIGN_16BYTES
27                        , IMAGE_SCN_MEM_EXECUTE
28                        , IMAGE_SCN_MEM_READ
29                        ] # 0x60500020
30       SectionData:
31         "\x83\xEC\x0C\xC7\x44\x24\x08\x00\x00\x00\x00\xC7\x04\x24\x00\x00\x00\x00\xE8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x8B\x44\x24\x08\x83\xC4\x0C\xC3" # |....D$.......$...............D$.....|
32     - Name: .rdata
33       Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
34       StructuredData:
35         - Binary: {type: str}
36         - UInt32: {type: int}
37         - LoadConfig:
38           Size: {type: int}
39           TimeDateStamp: {type: int}
40           MajorVersion: {type: int}
41           MinorVersion: {type: int}
42           GlobalFlagsClear: {type: int}
43           GlobalFlagsSet: {type: int}
44           CriticalSectionDefaultTimeout: {type: int}
45           DeCommitFreeBlockThreshold: {type: int}
46           DeCommitTotalFreeThreshold: {type: int}
47           LockPrefixTable: {type: int}
48           MaximumAllocationSize: {type: int}
49           VirtualMemoryThreshold: {type: int}
50           ProcessAffinityMask: {type: int}
51           ProcessHeapFlags: {type: int}
52           CSDVersion: {type: int}
53           DependentLoadFlags: {type: int}
54           EditList: {type: int}
55           SecurityCookie: {type: int}
56           SEHandlerTable: {type: int}
57           SEHandlerCount: {type: int}
58           GuardCFCheckFunction: {type: int}
59           GuardCFCheckDispatch: {type: int}
60           GuardCFFunctionTable: {type: int}
61           GuardCFFunctionCount: {type: int}
62           GuardFlags: {type: int}
63           CodeIntegrity:
64             Flags: {type: int}
65             Catalog: {type: int}
66             CatalogOffset: {type: int}
67           GuardAddressTakenIatEntryTable: {type: int}
68           GuardAddressTakenIatEntryCount: {type: int}
69           GuardLongJumpTargetTable: {type: int}
70           GuardLongJumpTargetCount: {type: int}
71           DynamicValueRelocTable: {type: int}
72           CHPEMetadataPointer: {type: int}
73           GuardRFFailureRoutine: {type: int}
74           GuardRFFailureRoutineFunctionPointer: {type: int}
75           DynamicValueRelocTableOffset: {type: int}
76           DynamicValueRelocTableSection: {type: int}
77           GuardRFVerifyStackPointerFunctionPointer: {type: int}
78           HotPatchTableOffset: {type: int}
79           EnclaveConfigurationPointer: {type: int}
80           VolatileMetadataPointer: {type: int}
81           GuardEHContinuationTable: {type: int}
82           GuardEHContinuationCount: {type: int}
83           GuardXFGCheckFunctionPointer: {type: int}
84           GuardXFGDispatchFunctionPointer: {type: int}
85           GuardXFGTableDispatchFunctionPointer: {type: int}
86           CastGuardOsDeterminedFailureMode: {type: int}
88   symbols:
89     - Name: .text
90       Value: 0
91       SectionNumber: 1
92       SimpleType: IMAGE_SYM_TYPE_NULL # (0)
93       ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
94       StorageClass: IMAGE_SYM_CLASS_STATIC # (3)
95       NumberOfAuxSymbols: 1
96       AuxiliaryData:
97         "\x24\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00" # |$.................|
99     - Name: _main
100       Value: 0
101       SectionNumber: 1
102       SimpleType: IMAGE_SYM_TYPE_NULL # (0)
103       ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
104       StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)
106 Here's a simplified Kwalify_ schema with an extension to allow alternate types.
108 .. _Kwalify: http://www.kuwata-lab.com/kwalify/ruby/users-guide.html
110 .. code-block:: yaml
112   type: map
113     mapping:
114       header:
115         type: map
116         mapping:
117           Machine: [ {type: str, enum:
118                                  [ IMAGE_FILE_MACHINE_UNKNOWN
119                                  , IMAGE_FILE_MACHINE_AM33
120                                  , IMAGE_FILE_MACHINE_AMD64
121                                  , IMAGE_FILE_MACHINE_ARM
122                                  , IMAGE_FILE_MACHINE_ARMNT
123                                  , IMAGE_FILE_MACHINE_ARM64
124                                  , IMAGE_FILE_MACHINE_EBC
125                                  , IMAGE_FILE_MACHINE_I386
126                                  , IMAGE_FILE_MACHINE_IA64
127                                  , IMAGE_FILE_MACHINE_M32R
128                                  , IMAGE_FILE_MACHINE_MIPS16
129                                  , IMAGE_FILE_MACHINE_MIPSFPU
130                                  , IMAGE_FILE_MACHINE_MIPSFPU16
131                                  , IMAGE_FILE_MACHINE_POWERPC
132                                  , IMAGE_FILE_MACHINE_POWERPCFP
133                                  , IMAGE_FILE_MACHINE_R4000
134                                  , IMAGE_FILE_MACHINE_SH3
135                                  , IMAGE_FILE_MACHINE_SH3DSP
136                                  , IMAGE_FILE_MACHINE_SH4
137                                  , IMAGE_FILE_MACHINE_SH5
138                                  , IMAGE_FILE_MACHINE_THUMB
139                                  , IMAGE_FILE_MACHINE_WCEMIPSV2
140                                  ]}
141                    , {type: int}
142                    ]
143           Characteristics:
144             - type: seq
145               sequence:
146                 - type: str
147                   enum: [ IMAGE_FILE_RELOCS_STRIPPED
148                         , IMAGE_FILE_EXECUTABLE_IMAGE
149                         , IMAGE_FILE_LINE_NUMS_STRIPPED
150                         , IMAGE_FILE_LOCAL_SYMS_STRIPPED
151                         , IMAGE_FILE_AGGRESSIVE_WS_TRIM
152                         , IMAGE_FILE_LARGE_ADDRESS_AWARE
153                         , IMAGE_FILE_BYTES_REVERSED_LO
154                         , IMAGE_FILE_32BIT_MACHINE
155                         , IMAGE_FILE_DEBUG_STRIPPED
156                         , IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP
157                         , IMAGE_FILE_NET_RUN_FROM_SWAP
158                         , IMAGE_FILE_SYSTEM
159                         , IMAGE_FILE_DLL
160                         , IMAGE_FILE_UP_SYSTEM_ONLY
161                         , IMAGE_FILE_BYTES_REVERSED_HI
162                         ]
163             - type: int
164       sections:
165         type: seq
166         sequence:
167           - type: map
168             mapping:
169               Name: {type: str}
170               Characteristics:
171                 - type: seq
172                   sequence:
173                     - type: str
174                       enum: [ IMAGE_SCN_TYPE_NO_PAD
175                             , IMAGE_SCN_CNT_CODE
176                             , IMAGE_SCN_CNT_INITIALIZED_DATA
177                             , IMAGE_SCN_CNT_UNINITIALIZED_DATA
178                             , IMAGE_SCN_LNK_OTHER
179                             , IMAGE_SCN_LNK_INFO
180                             , IMAGE_SCN_LNK_REMOVE
181                             , IMAGE_SCN_LNK_COMDAT
182                             , IMAGE_SCN_GPREL
183                             , IMAGE_SCN_MEM_PURGEABLE
184                             , IMAGE_SCN_MEM_16BIT
185                             , IMAGE_SCN_MEM_LOCKED
186                             , IMAGE_SCN_MEM_PRELOAD
187                             , IMAGE_SCN_ALIGN_1BYTES
188                             , IMAGE_SCN_ALIGN_2BYTES
189                             , IMAGE_SCN_ALIGN_4BYTES
190                             , IMAGE_SCN_ALIGN_8BYTES
191                             , IMAGE_SCN_ALIGN_16BYTES
192                             , IMAGE_SCN_ALIGN_32BYTES
193                             , IMAGE_SCN_ALIGN_64BYTES
194                             , IMAGE_SCN_ALIGN_128BYTES
195                             , IMAGE_SCN_ALIGN_256BYTES
196                             , IMAGE_SCN_ALIGN_512BYTES
197                             , IMAGE_SCN_ALIGN_1024BYTES
198                             , IMAGE_SCN_ALIGN_2048BYTES
199                             , IMAGE_SCN_ALIGN_4096BYTES
200                             , IMAGE_SCN_ALIGN_8192BYTES
201                             , IMAGE_SCN_LNK_NRELOC_OVFL
202                             , IMAGE_SCN_MEM_DISCARDABLE
203                             , IMAGE_SCN_MEM_NOT_CACHED
204                             , IMAGE_SCN_MEM_NOT_PAGED
205                             , IMAGE_SCN_MEM_SHARED
206                             , IMAGE_SCN_MEM_EXECUTE
207                             , IMAGE_SCN_MEM_READ
208                             , IMAGE_SCN_MEM_WRITE
209                             ]
210                 - type: int
211               SectionData: {type: str}
212       symbols:
213         type: seq
214         sequence:
215           - type: map
216             mapping:
217               Name: {type: str}
218               Value: {type: int}
219               SectionNumber: {type: int}
220               SimpleType: [ {type: str, enum: [ IMAGE_SYM_TYPE_NULL
221                                               , IMAGE_SYM_TYPE_VOID
222                                               , IMAGE_SYM_TYPE_CHAR
223                                               , IMAGE_SYM_TYPE_SHORT
224                                               , IMAGE_SYM_TYPE_INT
225                                               , IMAGE_SYM_TYPE_LONG
226                                               , IMAGE_SYM_TYPE_FLOAT
227                                               , IMAGE_SYM_TYPE_DOUBLE
228                                               , IMAGE_SYM_TYPE_STRUCT
229                                               , IMAGE_SYM_TYPE_UNION
230                                               , IMAGE_SYM_TYPE_ENUM
231                                               , IMAGE_SYM_TYPE_MOE
232                                               , IMAGE_SYM_TYPE_BYTE
233                                               , IMAGE_SYM_TYPE_WORD
234                                               , IMAGE_SYM_TYPE_UINT
235                                               , IMAGE_SYM_TYPE_DWORD
236                                               ]}
237                           , {type: int}
238                           ]
239               ComplexType: [ {type: str, enum: [ IMAGE_SYM_DTYPE_NULL
240                                                , IMAGE_SYM_DTYPE_POINTER
241                                                , IMAGE_SYM_DTYPE_FUNCTION
242                                                , IMAGE_SYM_DTYPE_ARRAY
243                                                ]}
244                            , {type: int}
245                            ]
246               StorageClass: [ {type: str, enum:
247                                           [ IMAGE_SYM_CLASS_END_OF_FUNCTION
248                                           , IMAGE_SYM_CLASS_NULL
249                                           , IMAGE_SYM_CLASS_AUTOMATIC
250                                           , IMAGE_SYM_CLASS_EXTERNAL
251                                           , IMAGE_SYM_CLASS_STATIC
252                                           , IMAGE_SYM_CLASS_REGISTER
253                                           , IMAGE_SYM_CLASS_EXTERNAL_DEF
254                                           , IMAGE_SYM_CLASS_LABEL
255                                           , IMAGE_SYM_CLASS_UNDEFINED_LABEL
256                                           , IMAGE_SYM_CLASS_MEMBER_OF_STRUCT
257                                           , IMAGE_SYM_CLASS_ARGUMENT
258                                           , IMAGE_SYM_CLASS_STRUCT_TAG
259                                           , IMAGE_SYM_CLASS_MEMBER_OF_UNION
260                                           , IMAGE_SYM_CLASS_UNION_TAG
261                                           , IMAGE_SYM_CLASS_TYPE_DEFINITION
262                                           , IMAGE_SYM_CLASS_UNDEFINED_STATIC
263                                           , IMAGE_SYM_CLASS_ENUM_TAG
264                                           , IMAGE_SYM_CLASS_MEMBER_OF_ENUM
265                                           , IMAGE_SYM_CLASS_REGISTER_PARAM
266                                           , IMAGE_SYM_CLASS_BIT_FIELD
267                                           , IMAGE_SYM_CLASS_BLOCK
268                                           , IMAGE_SYM_CLASS_FUNCTION
269                                           , IMAGE_SYM_CLASS_END_OF_STRUCT
270                                           , IMAGE_SYM_CLASS_FILE
271                                           , IMAGE_SYM_CLASS_SECTION
272                                           , IMAGE_SYM_CLASS_WEAK_EXTERNAL
273                                           , IMAGE_SYM_CLASS_CLR_TOKEN
274                                           ]}
275                             , {type: int}
276                             ]