感谢 yzh 大神的分享!!!!
gcc的几个选项:
-ffreestanding (表示编译出的程序将在裸机上运行)(注意:freestanding运行时环境默认的入口是_start())
Assert that compilation targets a freestanding environment. This implies -fno-builtin. A freestanding environment is one in which the standard library may not exist, and program
startup may not necessarily be at "main". The most obvious example is an OS kernel. This is equivalent to -fno-hosted.
-nostdlib (链接时不使用标准系统启动文件以及标准库)
Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify are passed to the linker, and options specifying linkage of
the system libraries, such as -static-libgcc or -shared-libgcc, are ignored.
The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries in libc. These entry points should be supplied through some
other mechanism when this option is specified.
One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is libgcc.a, a library of internal subroutines which GCC uses to overcome shortcomings of particular machines, or
special needs for some languages.
In most cases, you need libgcc.a even when you want to avoid other standard libraries. In other words, when you specify -nostdlib or -nodefaultlibs you should usually specify -lgcc as
well. This ensures that you have no unresolved references to internal GCC library subroutines. (An example of such an internal subroutine is "__main", used to ensure C++ constructors
are called.)
-Wl,-Ttext=0x80000000 告诉链接器,把代码段的起始地址放在 0x80000000
啊
啊
标签:startup,when,第五课,library,standard,libraries,一芯,libgcc,模拟器 From: https://www.cnblogs.com/yinhuachen/p/16800302.html