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