blob: e814379c1bb3d1ba5f918f4293e518408a4a7000 [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.
Stefan Reinauer543a6822013-02-04 15:39:13 -080014 */
15
Stefan Reinauere8764182013-02-05 13:46:49 -080016#define DOS_MAGIC 0x5a4d
Stefan Reinauer543a6822013-02-04 15:39:13 -080017typedef struct {
18 uint16_t signature;
19 uint16_t lastsize;
20 uint16_t nblocks;
21 uint16_t nreloc;
22 uint16_t hdrsize;
23 uint16_t minalloc;
24 uint16_t maxalloc;
25 uint16_t ss;
26 uint16_t sp;
27 uint16_t checksum;
28 uint16_t ip;
29 uint16_t cs;
30 uint16_t relocpos;
31 uint16_t noverlay;
32 uint16_t reserved1[4];
33 uint16_t oem_id;
34 uint16_t oem_info;
35 uint16_t reserved2[10];
36 uint32_t e_lfanew;
37} dos_header_t;
38
Stefan Reinauere8764182013-02-05 13:46:49 -080039#define MACHINE_TYPE_X86 0x014c
40#define MACHINE_TYPE_X64 0x8664
Stefan Reinauer543a6822013-02-04 15:39:13 -080041typedef struct {
42 uint8_t signature[4];
43 uint16_t machine;
44 uint16_t num_sections;
45 uint32_t timestamp;
46 uint32_t symboltable;
47 uint32_t num_symbols;
48 uint16_t opt_header_size;
49 uint16_t characteristics;
50} coff_header_t;
51
Stefan Reinauere8764182013-02-05 13:46:49 -080052#define PE_HDR_32_MAGIC 0x10b
Stefan Reinauer543a6822013-02-04 15:39:13 -080053typedef struct {
54 uint16_t signature;
55 uint8_t major_linker_version;
56 uint8_t minor_linker_version;
57 uint32_t code_size;
58 uint32_t data_size;
59 uint32_t bss_size;
60 uint32_t entry_point;
61 uint32_t code_offset;
62 uint32_t data_offset;
63 uint32_t image_addr;
64 uint32_t section_alignment;
65 uint32_t file_alignment;
66 uint16_t major_os_version;
67 uint16_t minor_os_version;
68 uint16_t major_image_version;
69 uint16_t minor_image_version;
70 uint16_t major_subsystem_version;
71 uint16_t minor_subsystem_version;
72 uint32_t reserved;
73 uint32_t image_size;
74 uint32_t header_size;
75 uint32_t checksum;
76 uint16_t subsystem;
77 uint16_t characteristics;
78 uint32_t stack_reserve_size;
79 uint32_t stack_commit_size;
80 uint32_t heap_reserve_size;
81 uint32_t heap_commit_size;
82 uint32_t loader_flags;
83 uint32_t number_of_va_and_sizes;
84 /* data directory not needed */
Stefan Reinauere8764182013-02-05 13:46:49 -080085} pe_opt_header_32_t;
86
87#define PE_HDR_64_MAGIC 0x20b
88typedef struct {
89 uint16_t signature;
90 uint8_t major_linker_version;
91 uint8_t minor_linker_version;
92 uint32_t code_size;
93 uint32_t data_size;
94 uint32_t bss_size;
95 uint32_t entry_point;
96 uint32_t code_offset;
97 uint64_t image_addr;
98 uint32_t section_alignment;
99 uint32_t file_alignment;
100 uint16_t major_os_version;
101 uint16_t minor_os_version;
102 uint16_t major_image_version;
103 uint16_t minor_image_version;
104 uint16_t major_subsystem_version;
105 uint16_t minor_subsystem_version;
106 uint32_t reserved;
107 uint32_t image_size;
108 uint32_t header_size;
109 uint32_t checksum;
110 uint16_t subsystem;
111 uint16_t characteristics;
112 uint64_t stack_reserve_size;
113 uint64_t stack_commit_size;
114 uint64_t heap_reserve_size;
115 uint64_t heap_commit_size;
116 uint32_t loader_flags;
117 uint32_t number_of_va_and_sizes;
118 /* data directory not needed */
119} pe_opt_header_64_t;