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
6 GCC assumes that it can combine stacks from
11 functions (optimisation -fcombine-stack-adjustments).
13 But doit() function clobbers %esp in inline
16 asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n"
17 : "=&r" (realstack) : "r" (simstack));
19 which tricks gcc into computing invalid local variable
20 offsets from current %esp value.
22 Fix by hinting gcc about %esp change in clobber list.
24 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
26 grub/asmstub.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
29 diff --git a/grub/asmstub.c b/grub/asmstub.c
30 index 6354806..44b056f 100644
33 @@ -174,7 +174,7 @@ grub_stage2 (void)
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");
40 /* Do a setjmp here for the stop command. */
41 if (! setjmp (env_for_exit))
42 @@ -191,7 +191,7 @@ grub_stage2 (void)
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");
50 assert (grub_scratch_mem == 0);