arm-linux-gnueabihf-gcc -Wall -nostdlib -c -O2 -o start.o start.s 什么意思? 2020-11-21

目录

1、arm-linux-gnueabihf-gcc -Wall -nostdlib -c -O2 -o start.o start.s

Wall:【Warning all】

-O0:【Optimize 优化】 

-nostdlib:【No Standard Library 】 

2、参考链接

2.1 Makefile中的-Wall -O2 -Os -g等选项介绍

2.2 gcc – g,静态初始化和-nostdlib

2.3 编译时“-nostdlib”的使用

2.4 使用GNU编译器集合(GCC)官方手册


1、arm-linux-gnueabihf-gcc -Wall -nostdlib -c -O2 -o start.o start.s

Wall:【Warning all】

选项可以打印出编译时所有的错误或者警告信息。这个选项很容易被遗忘,编译的时候,没有错误或者警告提示,以为自己的程序很完美,其实,里面有可能隐藏着许多陷阱。变量没有初始化,类型不匹配,或者类型转换错误等警告提示需要重点注意,错误就隐藏在这些代码里面。没有使用的变量也需要注意,去掉无用的代码,让整个程序显得干净一点。下次写Makefile的时候,一定加-Wall编译选项。

-O0:【Optimize 优化】 

表示编译时没有优化。

-O1: 表示编译时使用默认优化。

-O2: 表示编译时使用二级优化。

-O3: 表示编译时使用最高级优化。

-Os:相当于-O2.5优化,但又不所见代码尺寸,具体见链接:点击打开链接 点击打开链接

-nostdlib:【No Standard Library 】 

不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器。这个选项常用于编译内核、bootloader等程序,它们不需要启动文件、标准库文件。

从 gcc linker docs,

-nostdlib

Do not use the standard system startup files or libraries when
linking. No startup files and only the libraries you specify will be
passed to the linker
, and options specifying linkage of the system
libraries, such as -static-libgcc or -shared-libgcc, are ignored.

因此使用,

-nodefaultlibs

链接时请勿使用标准系统库.只有您指定的库才会传递给链接器,指定系统库链接的选项(如-static-libgcc或-shared-libgcc)将被忽略.除非使用-nostartfiles,否则标准启动文件将正常使用.编译器可能会生成对memcmp,memset,memcpy和memmove的调用.这些条目通常由libc中的条目解析.指定此选项时,应通过其他机制提供这些入口点.

2、参考链接

2.1 Makefile中的-Wall -O2 -Os -g等选项介绍

https://blog.csdn.net/shenhuan1104/article/details/76861029?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

2.2 gcc – g,静态初始化和-nostdlib

http://www.voidcn.com/article/p-kiqmapwv-btm.html

2.3 编译时“-nostdlib”的使用

https://blog.csdn.net/weibo1230123/article/details/82817006

2.4 使用GNU编译器集合(GCC)官方手册

https://gcc.gnu.org/onlinedocs/gcc/index.html#SEC_Contents

https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

猜你喜欢

转载自blog.csdn.net/qq_40662854/article/details/109909131