public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* howto use -fstack-check
@ 2002-04-24  4:49 Scholz Maik (CM-CR/EES3) *
  2002-04-24  5:22 ` Manfred Hollstein
  0 siblings, 1 reply; 4+ messages in thread
From: Scholz Maik (CM-CR/EES3) * @ 2002-04-24  4:49 UTC (permalink / raw)
  To: 'gcc@gcc.gnu.org'

We have an embedded system with a
RTOS without any stack check.

How can I use the gcc build in stack check
"-fstack-check"

Regards

Maik Scholz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: howto use -fstack-check
  2002-04-24  4:49 howto use -fstack-check Scholz Maik (CM-CR/EES3) *
@ 2002-04-24  5:22 ` Manfred Hollstein
  0 siblings, 0 replies; 4+ messages in thread
From: Manfred Hollstein @ 2002-04-24  5:22 UTC (permalink / raw)
  To: Scholz Maik (CM-CR/EES3) *; +Cc: 'gcc@gcc.gnu.org'

Scholz Maik (CM-CR/EES3) * wrote:
> We have an embedded system with a
> RTOS without any stack check.
> 
> How can I use the gcc build in stack check
> "-fstack-check"

 From gcc's info page:

`-fstack-check'
      Generate code to verify that you do not go beyond the boundary of
      the stack.  You should specify this flag if you are running in an
      environment with multiple threads, but only rarely need to specify
      it in a single-threaded environment since stack overflow is
      automatically detected on nearly all systems if there is only one
      stack.

      Note that this switch does not actually cause checking to be done;
      the operating system must do that.  The switch causes generation
      of code to ensure that the operating system sees the stack being
      extended.

This means to me, you try with "-S -fstack-check" when compiling
your code and see how the generated code looks like.

> 
> Regards
> 
> Maik Scholz
> 

HTH.

Cheers.

l8er
manfred

-- 
Manfred Hollstein                         <mailto:manfredh@redhat.com>
Red Hat GmbH
GPG fingerprint:    1D1F 0F5A 32C1 9E2A B8BA  561A E372 AF4C 0581 D831

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: howto use -fstack-check
  2002-04-24  5:51 AW: " Scholz Maik (CM-CR/EES3) *
@ 2002-04-24  6:36 ` Manfred Hollstein
  0 siblings, 0 replies; 4+ messages in thread
From: Manfred Hollstein @ 2002-04-24  6:36 UTC (permalink / raw)
  To: Scholz Maik (CM-CR/EES3) *; +Cc: 'gcc@gcc.gnu.org'

Scholz Maik (CM-CR/EES3) * wrote:
> what is "gccint.info"?

It's the documentation of gcc internals. This is from a current
gcc-3.1 snapshot:

    This manual documents the internals of the GNU compilers, including
how to port them to new targets and some information about how to write
front ends for new languages.  It corresponds to GCC version 3.1.  The
use of the GNU compilers is documented in a separate manual.  *Note
Introduction: (gcc)Top.

    This manual is mainly a reference manual rather than a tutorial.  It
discusses how to contribute to GCC (*note Contributing::), the
characteristics of the machines supported by GCC as hosts and targets
(*note Portability::), how GCC relates to the ABIs on such systems
(*note Interface::), and the characteristics of the languages for which
GCC front ends are written (*note Languages::).  It then describes the
GCC source tree structure and build system, some of the interfaces to
GCC front ends, and how support for a target system is implemented in
GCC.

    Additional tutorial information is linked to from
`http://gcc.gnu.org/readings.html'.


> 
> Regards
> 
> Maik

Cheers.

l8er
manfred

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: howto use -fstack-check
  2002-04-24  5:34 AW: " Scholz Maik (CM-CR/EES3) *
@ 2002-04-24  5:45 ` Manfred Hollstein
  0 siblings, 0 replies; 4+ messages in thread
From: Manfred Hollstein @ 2002-04-24  5:45 UTC (permalink / raw)
  To: Scholz Maik (CM-CR/EES3) *; +Cc: 'gcc@gcc.gnu.org'

Scholz Maik (CM-CR/EES3) * wrote:
> small example:
> foo.c:
> 	void foo2()
> 	{
> 	}
> 
> 	void foo1()
> 	{
> 	  int i;
> 	  i = 1;
> 	  foo2();
> 	}
> 
> miplsisa32-elf -S -fstack-check
> foo.s:
> 	.file	1 "foo.c"
> 	.section	.text
> gcc2_compiled.:
> __gnu_compiled_c:
> 	.text
> 	.align	2
> 	.globl	foo2
> 	.ent	foo2
> foo2:
> 	.frame	$fp,16,$31		# vars= 0, regs= 1/0, args= 0,
> extra= 0
> 	.mask	0x40000000,-16
> 	.fmask	0x00000000,0
> 	subu	$sp,$sp,16
> 	sw	$fp,0($sp)
> 	move	$fp,$sp
> 	move	$sp,$fp
> 	lw	$fp,0($sp)
> 	addu	$sp,$sp,16
> 	j	$31
> 	.end	foo2
> 	.align	2
> 	.globl	foo1
> 	.ent	foo1
> foo1:
> 	.frame	$fp,32,$31		# vars= 16, regs= 2/0, args= 0,
> extra= 0
> 	.mask	0xc0000000,-12
> 	.fmask	0x00000000,0
> 	subu	$sp,$sp,32
> 	sw	$31,20($sp)
> 	sw	$fp,16($sp)
> 	move	$fp,$sp
> added code	|	addu	$2,$sp,-4392
> added code	|	#.set	volatile
> added code	|	sw	$0,0($2)
> added code	|	#.set	novolatile
> 	li	$2,1			# 0x1
> 	sw	$2,0($fp)
> 	jal	foo2
> 	move	$sp,$fp
> 	lw	$31,20($sp)
> 	lw	$fp,16($sp)
> 	addu	$sp,$sp,32
> 	j	$31
> 	.end	foo1

I'm not really MIPS aware, but assuming "addu" means "add unsigned"
and "sw" means "store word" I cannot imagine how those added insns
are of any use.

> 
> Is there any description how to use the 
> "extra generated code".

gccint.info describes three alternatives available to gcc hackers
who want to implement stack checking for their particular port, but
other than that, I'm afraid, no.

> 
> Regards
> 
> Maik
> 

Cheers.

l8er
manfred

-- 
Manfred Hollstein                         <mailto:manfredh@redhat.com>
Red Hat GmbH
GPG fingerprint:    1D1F 0F5A 32C1 9E2A B8BA  561A E372 AF4C 0581 D831

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-04-24 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-24  4:49 howto use -fstack-check Scholz Maik (CM-CR/EES3) *
2002-04-24  5:22 ` Manfred Hollstein
2002-04-24  5:34 AW: " Scholz Maik (CM-CR/EES3) *
2002-04-24  5:45 ` Manfred Hollstein
2002-04-24  5:51 AW: " Scholz Maik (CM-CR/EES3) *
2002-04-24  6:36 ` Manfred Hollstein

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).