tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Local procedures


From: Rob Landley
Subject: Re: [Tinycc-devel] Local procedures
Date: Tue, 11 Sep 2007 15:33:45 -0500
User-agent: KMail/1.9.6

On Tuesday 11 September 2007 2:11:14 pm Peter Lund wrote:
> 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.

If it was a normal function it couldn't access the caller's local variables.

> The only really funky thing about is the trampoline technique used to
> make them work with function pointers.

That and it's accessing some local variables with a negative offset...

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

I'm really not motivated to do any work to add this feature myself.  If 
somebody wants to send me a patch, I'll look at it...

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.




reply via email to

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