This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Deliberate padding between static and stack variables?
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: njn25 at cam dot ac dot uk
- Cc: gcc at gcc dot gnu dot org, jeremy at goop dot org, jseward at acm dot org
- Date: Thu, 13 Nov 2003 10:30:03 -0500 (EST)
- Subject: Re: Deliberate padding between static and stack variables?
- References: <Pine.SOL.4.58.0311122230200.12208@red.csi.cam.ac.uk>
> What would be great is some co-operation from the compiler, which is
> usually GCC. Imagine if there was an option --pad-static-vars=N.
> Then Memcheck/Addrcheck could mark all the static variables as
> accessible -- using either symbol information or debugging information
> -- and all the other parts of static memory could be marked as
> inaccessible. (The 'N' could let you choose the redzone size, in
> bytes.) You could have a similar option --pad-stack-vars=N for the
> stack, and Memcheck/Addrcheck would handle those variables similarly.
>
> And voila! Memcheck/Addrcheck could detect static and stack overruns.
> This would be very cool; we just ran a survey of Valgrind users, and
> several people stated that they wanted static and/or stack checking.
>
> N
Take a look at StackGuard, presented at the GCC Summit a few months
ago. It sounds similar to what you want to do. It's designed as a
security measure for buffer overruns rather than programmer error, but
the concept is similar. (They call it a "canary" rather than a
"redzone".)
http://www.linux.org.uk/~ajh/gcc/gccsummit-2003-proceedings.pdf
http://www.immunix.com/~wagle/stackguard.html
Hope this helps,
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu