This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Add new warning -Wtrampolines


> This patch add new warning -Wtrampolines for making the compile to warn
> when it generating trampoline in object that requires executable stack.
> Tested on x86_64-unknown-linux-gnu and it have been in the Gentoo GCC
> patchset for long time (2006).

As Andrew pointed out, the wording of the warning isn't correct for all 
platforms (IA-64 for example) so it needs to be rephrased, e.g:

+@item -Wtrampolines
+@opindex Wtrampolines
+@opindex Wno-trampolines
+ Warn about trampolines generated for pointers to nested functions.
+ 
+ A trampoline is a small piece of data or code that is created at run
+ time on the stack when the address of a nested function is taken, and
+ is used to call the nested function indirectly.  For some targets, it
+ is made up of data only and thus requires no special treatment.  But,
+ for most targets, it is made up of code and thus requires the stack
+ to be made executable in order for the program to work properly.

It would be better to issue it from tree-nested.c:convert_tramp_reference_op 
so that it is attached to the token that causes it to be created.  For extra 
points, you could even make it reference the nested function:

p2.adb: In function 'P2':
p2.adb:17:12: warning: trampoline generated for 'P2.F'
p2.adb:26:11: warning: address taken from here

-- 
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]