https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88088
--- Comment #9 from Mark Wielaard <mark at gcc dot gnu.org> --- (In reply to Segher Boessenkool from comment #5) > The documentation currently says > > '-Wtrampolines' > 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. > > This isn't true if the trampoline is just data, if your reading in comment 2 > is correct. The documentation can be improved for sure. It doesn't make explicit that the warning is only when a trampoline is generated that is code placed on the stack (which might require the stack to be made executable on some targets). But a strict reading might suggest that it also warns in other cases. Lets just improve the documentation. > This isn't something to warn about (or at least not in -Wall or -W) if > executable code on the stack does not open up security concerns. > > For how to detect it, you can start at varasm.c:file_end_indicate_exec_stack > , > which isn't exactly what is needed, but you can start there. Or perhaps > builtins,c:expand_builtin_init_trampoline is better. You mean move the warning to some later point? I am not sure that is a good idea because then you loose the diagnostic location of the code. In general I do agree with comment #6. If at all possible we should make the warning generic. Generating code on the stack is a bad thing in general whether or not the stack is already executable or not IMHO. It would be helpful if you could show a concrete example of -Wtrampolines giving a warning where it is wrong to warn. What specific target are you concerned about?