sys-boot/grub:0 - Properly fix misoptimization by -fcombine-stack-adjustmemts (gcc...
authorIan Stakenvicius <axs@gentoo.org>
Tue, 15 Dec 2015 17:05:11 +0000 (12:05 -0500)
committerIan Stakenvicius <axs@gentoo.org>
Tue, 15 Dec 2015 17:05:36 +0000 (12:05 -0500)
commit9236cac3ad29a31f428157026801827d58c3b8a3
tree7ec9fb6009adccd733c604fe6fc60b8601f5a989
parent0280d4a259b2cb4393da0fb377422a667e611d73
sys-boot/grub:0 - Properly fix misoptimization by -fcombine-stack-adjustmemts (gcc-4.9+)

GCC assumes that it can combine stacks from outer "grub_stage2()"
and inner trampoline "doit()" functions (optimisation -fcombine-stack-adjustments).

But doit() function clobbers %esp in inline assebly statement as:

  asm volatile ("movl %%esp, %0\n\tmovl %1, %%esp\n"
               : "=&r" (realstack) : "r" (simstack));

which tricks gcc into computing invalid local variable offsets from current %esp value.

Fix by hinting gcc about %esp change in clobber list.

Thanks to slyfox for his debugging and patch!  This properly fixes bug 564890, allowing
for the -O0 hack to be removed.

Package-Manager: portage-2.2.24
sys-boot/grub/files/grub-0.97-Add-esp-to-list-of-clobbered-registers.patch [new file with mode: 0644]
sys-boot/grub/grub-0.97-r17.ebuild [new file with mode: 0644]