[M3devel] function pointers and comparison to nil? mis-typed function pointers?

Rodney M. Bates rodney.bates at wichita.edu
Mon May 26 22:47:53 CEST 2008



Jay wrote:
> It stinks either way imho.
> The portability is handled, somehow or another, by gcc's support for 
> nested functions.
> For example on OpenBSD, they call mprotect to make the trampoline 
> executable -- expensive! and leaves a bit of a security hole.
> On Linux you can sometimes mark the .exe as needing an executable stack 
> or not. Similarly on Windows, linker has /nxcompat, /nxcompat:no switch.
> ATL on Windows puts trampolines in the heap and specifically makes them 
> executable -- since the heap isn't necessarily executable either.
> The -1 marker is also a bit of a portability problem but I guess in 
> practise it works out.

Using trampolines would make this problem worse, perhaps much worse.
Mistaking the function's real code for a closure is a lot less likely
than mistaking the function's real code for a trampoline.  A trampoline
is, after all, always valid machine code on the executing processor.
Not necessarily so for -1.

> I'd be curious to see how it decodes on various processors.
>  
>  - Jay
>
-- 
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu



More information about the M3devel mailing list