blob: 0720c15ac06436a587ddb8ef067b2f938ed7cd10 [file] [log] [blame]
Stefan Reinauer543a6822013-02-04 15:39:13 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
Stefan Reinauere8764182013-02-05 13:46:49 -080020#define DOS_MAGIC 0x5a4d
Stefan Reinauer543a6822013-02-04 15:39:13 -080021typedef struct {
22 uint16_t signature;
23 uint16_t lastsize;
24 uint16_t nblocks;
25 uint16_t nreloc;
26 uint16_t hdrsize;
27 uint16_t minalloc;
28 uint16_t maxalloc;
29 uint16_t ss;
30 uint16_t sp;
31 uint16_t checksum;
32 uint16_t ip;
33 uint16_t cs;
34 uint16_t relocpos;
35 uint16_t noverlay;
36 uint16_t reserved1[4];
37 uint16_t oem_id;
38 uint16_t oem_info;
39 uint16_t reserved2[10];
40 uint32_t e_lfanew;
41} dos_header_t;
42
Stefan Reinauere8764182013-02-05 13:46:49 -080043#define MACHINE_TYPE_X86 0x014c
44#define MACHINE_TYPE_X64 0x8664
Stefan Reinauer543a6822013-02-04 15:39:13 -080045typedef struct {
46 uint8_t signature[4];
47 uint16_t machine;
48 uint16_t num_sections;
49 uint32_t timestamp;
50 uint32_t symboltable;
51 uint32_t num_symbols;
52 uint16_t opt_header_size;
53 uint16_t characteristics;
54} coff_header_t;
55
Stefan Reinauere8764182013-02-05 13:46:49 -080056#define PE_HDR_32_MAGIC 0x10b
Stefan Reinauer543a6822013-02-04 15:39:13 -080057typedef struct {
58 uint16_t signature;
59 uint8_t major_linker_version;
60 uint8_t minor_linker_version;
61 uint32_t code_size;
62 uint32_t data_size;
63 uint32_t bss_size;
64 uint32_t entry_point;
65 uint32_t code_offset;
66 uint32_t data_offset;
67 uint32_t image_addr;
68 uint32_t section_alignment;
69 uint32_t file_alignment;
70 uint16_t major_os_version;
71 uint16_t minor_os_version;
72 uint16_t major_image_version;
73 uint16_t minor_image_version;
74 uint16_t major_subsystem_version;
75 uint16_t minor_subsystem_version;
76 uint32_t reserved;
77 uint32_t image_size;
78 uint32_t header_size;
79 uint32_t checksum;
80 uint16_t subsystem;
81 uint16_t characteristics;
82 uint32_t stack_reserve_size;
83 uint32_t stack_commit_size;
84 uint32_t heap_reserve_size;
85 uint32_t heap_commit_size;
86 uint32_t loader_flags;
87 uint32_t number_of_va_and_sizes;
88 /* data directory not needed */
Stefan Reinauere8764182013-02-05 13:46:49 -080089} pe_opt_header_32_t;
90
91#define PE_HDR_64_MAGIC 0x20b
92typedef struct {
93 uint16_t signature;
94 uint8_t major_linker_version;
95 uint8_t minor_linker_version;
96 uint32_t code_size;
97 uint32_t data_size;
98 uint32_t bss_size;
99 uint32_t entry_point;
100 uint32_t code_offset;
101 uint64_t image_addr;
102 uint32_t section_alignment;
103 uint32_t file_alignment;
104 uint16_t major_os_version;
105 uint16_t minor_os_version;
106 uint16_t major_image_version;
107 uint16_t minor_image_version;
108 uint16_t major_subsystem_version;
109 uint16_t minor_subsystem_version;
110 uint32_t reserved;
111 uint32_t image_size;
112 uint32_t header_size;
113 uint32_t checksum;
114 uint16_t subsystem;
115 uint16_t characteristics;
116 uint64_t stack_reserve_size;
117 uint64_t stack_commit_size;
118 uint64_t heap_reserve_size;
119 uint64_t heap_commit_size;
120 uint32_t loader_flags;
121 uint32_t number_of_va_and_sizes;
122 /* data directory not needed */
123} pe_opt_header_64_t;
Stefan Reinauer543a6822013-02-04 15:39:13 -0800124