From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21260 invoked by alias); 24 Apr 2002 12:22:24 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 20881 invoked from network); 24 Apr 2002 12:19:49 -0000 Received: from unknown (HELO gwa2.fe.bosch.de) (194.39.218.2) by sources.redhat.com with SMTP; 24 Apr 2002 12:19:49 -0000 Received: (from uucp@localhost) by gwa2.fe.bosch.de (8.10.2/8.10.2) id g3OCLtF22554 for ; Wed, 24 Apr 2002 14:21:55 +0200 (MET DST) X-Authentication-Warning: gwa2.fe.bosch.de: uucp set sender to using -f Received: from fez8019.fe.internet.bosch.com(virus-out.fe.internet.bosch.de 10.4.4.19) by gwa2.fe.bosch.de via smap (V2.1) id xma021970; Wed, 24 Apr 02 14:21:33 +0200 Received: from 128.15.0.202 by fez8019.fe.internet.bosch.com (InterScan E-Mail VirusWall NT); Wed, 24 Apr 2002 13:56:23 +0200 Received: by fez7202.de.bosch.com with Internet Mail Service (5.5.2653.19) id ; Wed, 24 Apr 2002 14:19:19 +0200 Message-ID: From: "Scholz Maik (CM-CR/EES3) *" To: "'Manfred Hollstein'" Cc: "'gcc@gcc.gnu.org'" Subject: AW: howto use -fstack-check Date: Wed, 24 Apr 2002 05:34:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2002-04/txt/msg01234.txt.bz2 small example: foo.c: void foo2() { } void foo1() { int i; i =3D 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=3D 0, regs=3D 1/0, args=3D 0, extra=3D 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=3D 16, regs=3D 2/0, args=3D 0, extra=3D 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 Is there any description how to use the=20 "extra generated code". Regards Maik -----Urspr=FCngliche Nachricht----- Von: Manfred Hollstein [mailto:manfredh@redhat.com] Gesendet: Mittwoch, 24. April 2002 13:49 An: Scholz Maik (CM-CR/EES3) * Cc: 'gcc@gcc.gnu.org' Betreff: Re: howto use -fstack-check Scholz Maik (CM-CR/EES3) * wrote: > We have an embedded system with a > RTOS without any stack check. >=20 > 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. >=20 > Regards >=20 > Maik Scholz >=20 HTH. Cheers. l8er manfred --=20 Manfred Hollstein Red Hat GmbH GPG fingerprint: 1D1F 0F5A 32C1 9E2A B8BA 561A E372 AF4C 0581 D831