What is the use of -fno-stack-protector?

前端 未结 5 1667
[愿得一人]
[愿得一人] 2020-12-29 04:08

I have written an application in C, and I\'m trying to understand what is the purpose of the -fno-stack-protector command when compiling. For my specific applic

5条回答
  •  一向
    一向 (楼主)
    2020-12-29 04:12

    Times when an option that matches a default compiler setting can be useful include:

    • when you're using a build system that may have a complex configuration that you want to tweak. Instead of figuring out where in a maze of makefiles it might be choosing to use fstack-protector (for example), it may let you easily pass in additional options that simply get tacked on to the end of the list of options. If GCC sees both fstack-protector and fno-stack-protector in the set of options, the last one on the command line is the one that takes effect.

    • the other time this kind of thing might be handy (which doesn't seem to apply to -fstack-protector, however) is when you have an option that turns on a bunch of 'sub-options'. For example, setting -O2 turns on a slew of -fxxx optimization options,and you may want to use -O2 for the most part but don't want GCC's strict aliasing optimizations. So you can specify -fno-strict-aliasing to set that particular option back to its default setting. (Note: this case is really equivalent to the case above)

提交回复
热议问题