netdoger 发表于 2012-04-17 20:18

请问gcc的选项的说明

比如我想问-fno-stack-protector的意义,
因为没有找到,后来EricFisher版主
给我的是-fstack-protector,我想
-fno-stack-protector应该就是
-fstack-protector的相反意思吧,
所以我想知道:
我们怎样才能快速的找到需要的选项
(因为gcc的选项太多了)

EricFisher 发表于 2012-04-18 08:55

多看看gcc手册就成了,呵呵。另外,手册中将选项做了分类,比如优化相关的,调试相关的等等。

OpeNCore 发表于 2012-04-19 12:41

本帖最后由 OpeNCore 于 2012-04-19 12:47 编辑

回复 1# netdoger


-fstack-protector
Emit extra code to check for buffer overflows, such as stack smashing attacks. This is done by adding a guard variable to functions with vulnerable objects. This includes functions that call alloca, and functions with buffers larger than 8 bytes. The guards are initialized when a function is entered and then checked when the function exits. If a guard check fails, an error message is printed and the program exits.
-fstack-protector-all
Like -fstack-protector except that all functions are protected.


gcc选项列表,你可以直接搜索:
http://gcc.gnu.org/onlinedocs/gcc/Option-Index.html#Option-Index
   
gcc选项汇总,按版主说的分类了:
http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html#Option-Summary

gcc选项的简要说明:
http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC

The gcc program accepts options and file names as operands. Many options have multi-letter names; therefore multiple single-letter options may not be grouped: -dv is very different from `-d -v'. (选项不能组合着用,-dv 不同于 -d -v)
You can mix options and other arguments. For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified. Also, the placement of the -l option is significant.
(一般的选项顺序不重要,不影响,但是-L和-l涉及到链接的选项顺序就很重要。)
Many options have long names starting with `-f' or with `-W'—for example, -fmove-loop-invariants, -Wformat and so on.
(很多选项除了有短的(单字母的),还有长的名字,如用-f,-W带出来的)

Most of these have both positive and negative forms; the negative form of -ffoo is -fno-foo.
This manual documents only one of these two forms, whichever one is not the default.

其中包含你想问的,大部分选项有两种模式,-fno-foo是对-ffoo的取反。文档中一般只描述其中一种,非默认的那种。






页: [1]
查看完整版本: 请问gcc的选项的说明