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

--- Comment #1 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
I can reproduce the issue with the trunk cross compiler.
It seems that openproc function in proc/readproc.c is miscompiled
with -fstack-protector-strong.  Here is a reduced test case:

--
int t;
struct s {};
int bar (void);
int baz (int, struct s *);

int
foo (int x)
{
  struct s sbuf;
  static int d;
  int val = bar ();

  if (d)
    {
      t = baz (x, &sbuf);
      d = 1;
    }

  return val;
}
--

It turned out that the fix for PR65249 causes this problem.
The codes for stack protect can be inserted after some function
call returning a value.  That return value in R0 register could
be clobbered with the fix for PR65249.
I thought that stack_chk_guard thingy is inserted at the head
of the function.  It's not the case, unfortunately.
I think that the wrong code is worse than the ICE.  I'd like
to revert the patches of PR65249 and reopen that PR.

Reply via email to