On 15/02/2023 9:17 am, Andrew Cooper wrote:
On 26/01/2023 8:08 pm, Ammar Faizi wrote:
On Mon, Jan 23, 2023 at 05:40:23PM -0800, H. Peter Anvin wrote:
So as per Andrew's comment, add:
register void * rsp asm("%rsp");
...
"+r" (rsp) /* clobber the redzone */
... as the right way to avoid redzone problems.
I played with this more. I found something wrong with this. This doesn't work for me. The compiler still uses red zone despite I use "+r" (rsp).
What did I do wrong?
Well this is a fine mess...
https://godbolt.org/z/MaPM7s8qr does the right thing, but is now contrary to the prior discussion regarding calls in asm, which concluded that the "+r"(rsp) was the way to go.
Furthermore GCC regressed in 9.0 and emits:
warning: listing the stack pointer register 'rsp' in a clobber list is deprecated [-Wdeprecated]
which might be the intention of the developers, but is wrong seeing as this is the only way to say "I modify the redzone" to the compiler...
I've opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108799
~Andrew