1 yaml2obj 2 ======== 3 4 yaml2obj takes a YAML description of an object file and converts it to a binary 5 file. 6 7 $ yaml2obj input-file 8 9 .. program:: yaml2obj 10 11 Outputs the binary to stdout. 12 13 COFF Syntax 14 ----------- 15 16 Here's a sample COFF file. 17 18 .. code-block:: yaml 19 20 header: 21 Machine: IMAGE_FILE_MACHINE_I386 # (0x14C) 22 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 33 symbols: 34 - Name: .text 35 Value: 0 36 SectionNumber: 1 37 SimpleType: IMAGE_SYM_TYPE_NULL # (0) 38 ComplexType: IMAGE_SYM_DTYPE_NULL # (0) 39 StorageClass: IMAGE_SYM_CLASS_STATIC # (3) 40 NumberOfAuxSymbols: 1 41 AuxillaryData: 42 "\x24\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00" # |$.................| 43 44 - Name: _main 45 Value: 0 46 SectionNumber: 1 47 SimpleType: IMAGE_SYM_TYPE_NULL # (0) 48 ComplexType: IMAGE_SYM_DTYPE_NULL # (0) 49 StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2) 50 51 Here's a simplified Kwalify_ schema with an extension to allow alternate types. 52 53 .. _Kwalify: http://www.kuwata-lab.com/kwalify/ruby/users-guide.html 54 55 .. code-block:: yaml 56 57 type: map 58 mapping: 59 header: 60 type: map 61 mapping: 62 Machine: [ {type: str, enum: 63 [ IMAGE_FILE_MACHINE_UNKNOWN 64 , IMAGE_FILE_MACHINE_AM33 65 , IMAGE_FILE_MACHINE_AMD64 66 , IMAGE_FILE_MACHINE_ARM 67 , IMAGE_FILE_MACHINE_ARMV7 68 , IMAGE_FILE_MACHINE_EBC 69 , IMAGE_FILE_MACHINE_I386 70 , IMAGE_FILE_MACHINE_IA64 71 , IMAGE_FILE_MACHINE_M32R 72 , IMAGE_FILE_MACHINE_MIPS16 73 , IMAGE_FILE_MACHINE_MIPSFPU 74 , IMAGE_FILE_MACHINE_MIPSFPU16 75 , IMAGE_FILE_MACHINE_POWERPC 76 , IMAGE_FILE_MACHINE_POWERPCFP 77 , IMAGE_FILE_MACHINE_R4000 78 , IMAGE_FILE_MACHINE_SH3 79 , IMAGE_FILE_MACHINE_SH3DSP 80 , IMAGE_FILE_MACHINE_SH4 81 , IMAGE_FILE_MACHINE_SH5 82 , IMAGE_FILE_MACHINE_THUMB 83 , IMAGE_FILE_MACHINE_WCEMIPSV2 84 ]} 85 , {type: int} 86 ] 87 Characteristics: 88 - type: seq 89 sequence: 90 - type: str 91 enum: [ IMAGE_FILE_RELOCS_STRIPPED 92 , IMAGE_FILE_EXECUTABLE_IMAGE 93 , IMAGE_FILE_LINE_NUMS_STRIPPED 94 , IMAGE_FILE_LOCAL_SYMS_STRIPPED 95 , IMAGE_FILE_AGGRESSIVE_WS_TRIM 96 , IMAGE_FILE_LARGE_ADDRESS_AWARE 97 , IMAGE_FILE_BYTES_REVERSED_LO 98 , IMAGE_FILE_32BIT_MACHINE 99 , IMAGE_FILE_DEBUG_STRIPPED 100 , IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 101 , IMAGE_FILE_NET_RUN_FROM_SWAP 102 , IMAGE_FILE_SYSTEM 103 , IMAGE_FILE_DLL 104 , IMAGE_FILE_UP_SYSTEM_ONLY 105 , IMAGE_FILE_BYTES_REVERSED_HI 106 ] 107 - type: int 108 sections: 109 type: seq 110 sequence: 111 - type: map 112 mapping: 113 Name: {type: str} 114 Characteristics: 115 - type: seq 116 sequence: 117 - type: str 118 enum: [ IMAGE_SCN_TYPE_NO_PAD 119 , IMAGE_SCN_CNT_CODE 120 , IMAGE_SCN_CNT_INITIALIZED_DATA 121 , IMAGE_SCN_CNT_UNINITIALIZED_DATA 122 , IMAGE_SCN_LNK_OTHER 123 , IMAGE_SCN_LNK_INFO 124 , IMAGE_SCN_LNK_REMOVE 125 , IMAGE_SCN_LNK_COMDAT 126 , IMAGE_SCN_GPREL 127 , IMAGE_SCN_MEM_PURGEABLE 128 , IMAGE_SCN_MEM_16BIT 129 , IMAGE_SCN_MEM_LOCKED 130 , IMAGE_SCN_MEM_PRELOAD 131 , IMAGE_SCN_ALIGN_1BYTES 132 , IMAGE_SCN_ALIGN_2BYTES 133 , IMAGE_SCN_ALIGN_4BYTES 134 , IMAGE_SCN_ALIGN_8BYTES 135 , IMAGE_SCN_ALIGN_16BYTES 136 , IMAGE_SCN_ALIGN_32BYTES 137 , IMAGE_SCN_ALIGN_64BYTES 138 , IMAGE_SCN_ALIGN_128BYTES 139 , IMAGE_SCN_ALIGN_256BYTES 140 , IMAGE_SCN_ALIGN_512BYTES 141 , IMAGE_SCN_ALIGN_1024BYTES 142 , IMAGE_SCN_ALIGN_2048BYTES 143 , IMAGE_SCN_ALIGN_4096BYTES 144 , IMAGE_SCN_ALIGN_8192BYTES 145 , IMAGE_SCN_LNK_NRELOC_OVFL 146 , IMAGE_SCN_MEM_DISCARDABLE 147 , IMAGE_SCN_MEM_NOT_CACHED 148 , IMAGE_SCN_MEM_NOT_PAGED 149 , IMAGE_SCN_MEM_SHARED 150 , IMAGE_SCN_MEM_EXECUTE 151 , IMAGE_SCN_MEM_READ 152 , IMAGE_SCN_MEM_WRITE 153 ] 154 - type: int 155 SectionData: {type: str} 156 symbols: 157 type: seq 158 sequence: 159 - type: map 160 mapping: 161 Name: {type: str} 162 Value: {type: int} 163 SectionNumber: {type: int} 164 SimpleType: [ {type: str, enum: [ IMAGE_SYM_TYPE_NULL 165 , IMAGE_SYM_TYPE_VOID 166 , IMAGE_SYM_TYPE_CHAR 167 , IMAGE_SYM_TYPE_SHORT 168 , IMAGE_SYM_TYPE_INT 169 , IMAGE_SYM_TYPE_LONG 170 , IMAGE_SYM_TYPE_FLOAT 171 , IMAGE_SYM_TYPE_DOUBLE 172 , IMAGE_SYM_TYPE_STRUCT 173 , IMAGE_SYM_TYPE_UNION 174 , IMAGE_SYM_TYPE_ENUM 175 , IMAGE_SYM_TYPE_MOE 176 , IMAGE_SYM_TYPE_BYTE 177 , IMAGE_SYM_TYPE_WORD 178 , IMAGE_SYM_TYPE_UINT 179 , IMAGE_SYM_TYPE_DWORD 180 ]} 181 , {type: int} 182 ] 183 ComplexType: [ {type: str, enum: [ IMAGE_SYM_DTYPE_NULL 184 , IMAGE_SYM_DTYPE_POINTER 185 , IMAGE_SYM_DTYPE_FUNCTION 186 , IMAGE_SYM_DTYPE_ARRAY 187 ]} 188 , {type: int} 189 ] 190 StorageClass: [ {type: str, enum: 191 [ IMAGE_SYM_CLASS_END_OF_FUNCTION 192 , IMAGE_SYM_CLASS_NULL 193 , IMAGE_SYM_CLASS_AUTOMATIC 194 , IMAGE_SYM_CLASS_EXTERNAL 195 , IMAGE_SYM_CLASS_STATIC 196 , IMAGE_SYM_CLASS_REGISTER 197 , IMAGE_SYM_CLASS_EXTERNAL_DEF 198 , IMAGE_SYM_CLASS_LABEL 199 , IMAGE_SYM_CLASS_UNDEFINED_LABEL 200 , IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 201 , IMAGE_SYM_CLASS_ARGUMENT 202 , IMAGE_SYM_CLASS_STRUCT_TAG 203 , IMAGE_SYM_CLASS_MEMBER_OF_UNION 204 , IMAGE_SYM_CLASS_UNION_TAG 205 , IMAGE_SYM_CLASS_TYPE_DEFINITION 206 , IMAGE_SYM_CLASS_UNDEFINED_STATIC 207 , IMAGE_SYM_CLASS_ENUM_TAG 208 , IMAGE_SYM_CLASS_MEMBER_OF_ENUM 209 , IMAGE_SYM_CLASS_REGISTER_PARAM 210 , IMAGE_SYM_CLASS_BIT_FIELD 211 , IMAGE_SYM_CLASS_BLOCK 212 , IMAGE_SYM_CLASS_FUNCTION 213 , IMAGE_SYM_CLASS_END_OF_STRUCT 214 , IMAGE_SYM_CLASS_FILE 215 , IMAGE_SYM_CLASS_SECTION 216 , IMAGE_SYM_CLASS_WEAK_EXTERNAL 217 , IMAGE_SYM_CLASS_CLR_TOKEN 218 ]} 219 , {type: int} 220 ] 221