add deprecated sys-boot/grub:0
[portage-squeep] / sys-boot / grub / files / grub-0.97-Add-esp-to-list-of-clobbered-registers.patch
1 From 5a52ee4b5cd152fa4ccd1c1f938ce2eba652af52 Mon Sep 17 00:00:00 2001
2 From: Sergei Trofimovich <slyfox@gentoo.org>
3 Date: Mon, 14 Dec 2015 23:59:17 +0000
4 Subject: [PATCH] Add %esp to list of clobbered registers
5
6 GCC assumes that it can combine stacks from
7 outer
8 grub_stage2()
9 and inner
10 trampoline doit()
11 functions (optimisation -fcombine-stack-adjustments).
12
13 But doit() function clobbers %esp in inline
14 assebly statement as:
15
16 asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n"
17 : "=&r" (realstack) : "r" (simstack));
18
19 which tricks gcc into computing invalid local variable
20 offsets from current %esp value.
21
22 Fix by hinting gcc about %esp change in clobber list.
23
24 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
25 ---
26 grub/asmstub.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
28
29 diff --git a/grub/asmstub.c b/grub/asmstub.c
30 index 6354806..44b056f 100644
31 --- a/grub/asmstub.c
32 +++ b/grub/asmstub.c
33 @@ -174,7 +174,7 @@ grub_stage2 (void)
34 {
35 /* Make sure our stack lives in the simulated memory area. */
36 asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n"
37 - : "=&r" (realstack) : "r" (simstack));
38 + : "=&r" (realstack) : "r" (simstack) : "%esp");
39
40 /* Do a setjmp here for the stop command. */
41 if (! setjmp (env_for_exit))
42 @@ -191,7 +191,7 @@ grub_stage2 (void)
43 }
44
45 /* Replace our stack before we use any local variables. */
46 - asm volatile ("movl %0, %%esp\n" : : "r" (realstack));
47 + asm volatile ("movl %0, %%esp\n" : : "r" (realstack) : "%esp");
48 }
49
50 assert (grub_scratch_mem == 0);
51 --
52 2.6.3
53