https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128270

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.5

--- Comment #7 from Uroš Bizjak <ubizjak at gmail dot com> ---
The missing .cfi_restore reappears with -mno-red-zone and with ALIGN=128, and
-m32 (no red zone) already emits it.  The same applies to popq %rbp
(-mtune-ctrl=^use_leave) and to mov-saved rbx/r12.

gdb testcase (built with -O2 -g -mforce-drap -fno-omit-frame-pointer
-mtune-ctrl=use_leave,prologue_using_move,epilogue_using_move):

--cut here--
__attribute__((noinline)) void use (void *p)
{ asm volatile ("" :: "r"(p) : "memory"); }

__attribute__((noinline)) int f (void)
{
  char buf[64] __attribute__ ((aligned (32)));
  asm volatile ("" ::: "rbx", "r12");
  use (buf);
  return buf[0];
}

int main (void)
{
  long m = 0x1122334455667788;
  asm volatile ("" : "+b"(m));
  int r = f ();
  asm volatile ("" : "+b"(m));
  return r + (m != 0x1122334455667788);
}
--cut here--

Break at the instruction after leave in f, then "frame 1" and "p/x $rbx":

  unpatched:  $rbx = 0x40037b            (wrong)
  patched:    $rbx = 0x1122334455667788  (correct)

Fixed in gcc-17, will be backported to all active release branches.

Reply via email to