1.
-
CFLAGS = -Wall $(INCLUDE) -c -m32 -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes -nostdinc
-
-
-fno-builtin:
-
Don't recognize built-in functions that do not begin with __builtin_ as prefix
-
-
printf中用到了 va_start这个函数,如果不加-fno-builtin则用的是系统自带的va_start,加上这个-fno-builtin则用的是自己写的va_start
-
-
-Wstrict-prototypes (C and Objective-C only)
-
Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permitted without a warning if preceded by a declaration that specifies the argument types.)
-
-
-
-Wmissing-prototypes (C and Objective-C only)
-
Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. Use this option to detect global functions that do not have a matching prototype declaration in a header file. This option is not valid for C++ because all function declarations provide prototypes and a non-matching declaration will declare an overload rather than conflict with an earlier declaration. Use -Wmissing-declarations to detect missing declarations in C++.
2. -nostdinc
-
-nostdinc++
-
Do not search for header files in the standard directories specific to C++, but do still search the other standard directories. (This option is used when building the C++ library.)
-
不要在标准系统目录中寻找头文件.只搜索`-I’选项指定的目录(以及当前目录,如果合适).
结合使用`-nostdinc’和`-I-’选项,你可以把包含文件搜索限制在显式指定的目录.
为了避免系统中己存在的头文件的干扰加上-nostdinc
3.
-fno-stack-protector
-
-fno-stack-protector
-
-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.
在链接阶段出现: undefined reference to "__stack_chk_fail"时,加上-fno-stack-protector
4.
CFLAGS =-Wall -m32 -O0 -g -fstrength-reduce -fomit-frame-pointer -fno-stack-protector -fno-builtin
LDFLAGS =-Ttext 0 -e startup_32 -m elf_i386
参考:
man gcc
GCC中文手册
阅读(1366) | 评论(0) | 转发(0) |