From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: gcc-help@gcc.gnu.org
Subject: How to use the -fstack-limit-register option?
Date: Thu, 4 May 2023 18:16:02 +0200 [thread overview]
Message-ID: <2854599b-9ff9-6d4d-f1c9-fb139468784b@embedded-brains.de> (raw)
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/
reply other threads:[~2023-05-04 16:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2854599b-9ff9-6d4d-f1c9-fb139468784b@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).