On 10/10/20 2:49 PM, Bruno Haible wrote:
gcc -fstack-clash-protection -m32 -O2 stackish.c fixes this issue.
Yes. However, the GCC manual says this about -fstack-clash-protection:
Most targets do not fully support stack clash protection. However,
on those targets '-fstack-clash-protection' will protect dynamic
stack allocations. '-fstack-clash-protection' may also provide
limited protection for static stack allocations if the target
supports '-fstack-check=specific'.
which is not as close to "it should just work" as I'd like, especially when I go
read the section on -fstack-check. I suppose I need to look at the output of gcc
-S -fstack-clash-protection on my platform (and understand what the OS does) to
know whether stack overflow is detected reliably.
That being said, it does look like a reliability win if we start using
-fstack-clash-protection on platforms like Fedora x86-64 that support it and do
not enable it by default. Perhaps we should have a Gnulib or Autoconf macro that
does that.