public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to use the -fstack-limit-register option?
@ 2023-05-04 16:16 Sebastian Huber
  0 siblings, 0 replies; only message in thread
From: Sebastian Huber @ 2023-05-04 16:16 UTC (permalink / raw)
  To: gcc-help

Hello,

GCC has a -fstack-limit-register option

https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fstack-limit-register

If the ABI has no dedicated register for the stack limit, I guess this 
needs to be combined for example with -ffixed-reg. For example on ARM, 
we get this code for

int g(void);

int f(void)
{
	return g() + g();
}

gcc -O2 -fstack-limit-register=r4 -ffixed-r4 -S -o - test.c

f:
         push    {r5, lr}
         bl      g
         mov     r5, r0
         bl      g
         add     r0, r5, r0
         pop     {r5, lr}
         bx      lr

The -ffixed-r4 seems to work, but I don't see that the stack limit is 
checked. The documentation says: "Generate code to ensure that the stack 
does not grow beyond a certain value, either the value of a register or 
the address of a symbol."

How is this option supposed to work?

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-04 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 16:16 How to use the -fstack-limit-register option? Sebastian Huber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).