tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Local procedures


From: Peter Lund
Subject: Re: [Tinycc-devel] Local procedures
Date: Tue, 11 Sep 2007 21:11:14 +0200

On Tue, 2007-09-11 at 13:53 -0500, Rob Landley wrote:
> On Tuesday 11 September 2007 6:24:53 am address@hidden wrote:
> > What are the chances of tcc having support for local procedures sometime in
> > the near future?
> 
> Ok, back to the original question, I think you're asking for this:
> http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
> 
> Which seems somewhere between an inline function and a macro.

No.  It is an ordinary function in a function-local namespace.
The only really funky thing about is the trampoline technique used to
make them work with function pointers.

There's nothing macro like about it.  And nothing "inline-like" about it
either.  In fact, that would be a bit weird when passing around pointers
to it -- unless maybe if the entire compilation unit is translated and
optimized at once.

> And although I'm not averse to merging a patch for this, I'm not too 
> interested in doing the work myself at the moment because I'm focused on 
> getting tcc to compile existing programs (like busybox, uClibc, and the Linux 
> kernel).  I don't know of any existing programs that make use of this.  I'm 
> guessing you have an example? :)

There used to be some but the trampolines depend (depended?) on putting
a small piece of code on the stack and then executing it.  This did not
play nice with various security hardening measures ;)

I think this ended up with: 1) environment variables to allow executing
from the stack for the few programs that need it and 2) the code was
changed to not rely on this feature.  Furthermore, 3) there is a way to
specificy now in the ELF file that this program expects to be able to
run code from the stack.  Maybe also 4) that gcc was changed to use a
different solution.  Or maybe they just discussed that and dropped it
because the feature is so little used.

-Peter






reply via email to

[Prev in Thread] Current Thread [Next in Thread]