aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/tools/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/boot/tools/build.c')
-rw-r--r--arch/x86/boot/tools/build.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
index fdc60a0b3c20..4e9bd6bcafa6 100644
--- a/arch/x86/boot/tools/build.c
+++ b/arch/x86/boot/tools/build.c
@@ -135,6 +135,9 @@ static void usage(void)
135 135
136int main(int argc, char ** argv) 136int main(int argc, char ** argv)
137{ 137{
138#ifdef CONFIG_EFI_STUB
139 unsigned int file_sz, pe_header;
140#endif
138 unsigned int i, sz, setup_sectors; 141 unsigned int i, sz, setup_sectors;
139 int c; 142 int c;
140 u32 sys_size; 143 u32 sys_size;
@@ -194,6 +197,42 @@ int main(int argc, char ** argv)
194 buf[0x1f6] = sys_size >> 16; 197 buf[0x1f6] = sys_size >> 16;
195 buf[0x1f7] = sys_size >> 24; 198 buf[0x1f7] = sys_size >> 24;
196 199
200#ifdef CONFIG_EFI_STUB
201 file_sz = sz + i + ((sys_size * 16) - sz);
202
203 pe_header = *(unsigned int *)&buf[0x3c];
204
205 /* Size of code */
206 *(unsigned int *)&buf[pe_header + 0x1c] = file_sz;
207
208 /* Size of image */
209 *(unsigned int *)&buf[pe_header + 0x50] = file_sz;
210
211#ifdef CONFIG_X86_32
212 /* Address of entry point */
213 *(unsigned int *)&buf[pe_header + 0x28] = i;
214
215 /* .text size */
216 *(unsigned int *)&buf[pe_header + 0xb0] = file_sz;
217
218 /* .text size of initialised data */
219 *(unsigned int *)&buf[pe_header + 0xb8] = file_sz;
220#else
221 /*
222 * Address of entry point. startup_32 is at the beginning and
223 * the 64-bit entry point (startup_64) is always 512 bytes
224 * after.
225 */
226 *(unsigned int *)&buf[pe_header + 0x28] = i + 512;
227
228 /* .text size */
229 *(unsigned int *)&buf[pe_header + 0xc0] = file_sz;
230
231 /* .text size of initialised data */
232 *(unsigned int *)&buf[pe_header + 0xc8] = file_sz;
233#endif /* CONFIG_X86_32 */
234#endif /* CONFIG_EFI_STUB */
235
197 crc = partial_crc32(buf, i, crc); 236 crc = partial_crc32(buf, i, crc);
198 if (fwrite(buf, 1, i, stdout) != i) 237 if (fwrite(buf, 1, i, stdout) != i)
199 die("Writing setup failed"); 238 die("Writing setup failed");