This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Add new warning -Wtrampolines
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Magnus Granberg <zorry at gentoo dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 6 May 2010 09:24:46 +0200
- Subject: Re: [patch] Add new warning -Wtrampolines
- References: <201005060146.34151.zorry@gentoo.org>
> 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