* H. J. Lu: >> Is it possible to enable stack protector for individual functions if >> !flag_stack_protect? > > I don't think so. We only have > > @cindex @code{no_stack_protector} function attribute > @item no_stack_protector > This attribute prevents stack protection code for the function. > > and > > @cindex @code{stack_protect} function attribute > @item stack_protect > This attribute adds stack protection code to the function if > flags @option{-fstack-protector}, @option{-fstack-protector-strong} > or @option{-fstack-protector-explicit} are set. > > If we add another attribute to enable stack protector for individual functions > without -fstack-protector, I will try to accommodate it.
This already seems to have the effect: int f (void); __attribute__ ((optimize ("stack-protector-all"))) int g (void) { f(); }