Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2159516
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2016-09-01 10:08:51

1. 
  1. CFLAGS = -Wall $(INCLUDE) -c -m32 -fno-builtin -W -Wstrict-prototypes -Wmissing-prototypes -nostdinc

  2. -fno-builtin:
  3.    Don't recognize built-in functions that do not begin with __builtin_ as prefix
  4.    
  5.    printf中用到了 va_start这个函数,如果不加-fno-builtin则用的是系统自带的va_start,加上这个-fno-builtin则用的是自己写的va_start
  6.    
  7. -Wstrict-prototypes (C and Objective-C only)
  8.    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.)
  9.    
  10.    
  11. -Wmissing-prototypes (C and Objective-C only)
  12.    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
  1. -nostdinc++
  2.    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.)
  3.  不要在标准系统目录中寻找头文件.只搜索`-I’选项指定的目录(以及当前目录,如果合适).
    结合使用`-nostdinc’和`-I-’选项,你可以把包含文件搜索限制在显式指定的目录.
为了避免系统中己存在的头文件的干扰加上-nostdinc
3.-fno-stack-protector
  1. -fno-stack-protector
  2. -fstack-protector
  3.    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
  4.    objects. This includes functions that call "alloca", and functions with buffers larger than 8 bytes. The guards are initialized when a function is
  5.    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中文手册



阅读(1372) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~