中的crt0.o和crt1.o - 有什么区别? [英] crt0.o and crt1.o -- What's the difference?

查看:2329
本文介绍了中的crt0.o和crt1.o - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在试图调试一些低层次的工作,我无法找到编译器(AVR-GCC)的crt0.s中,但我没有找到一个crt1.S(以及相应的.o文件相同)

recently I've been trying to debug some low level work and I could not find the crt0.S for the compiler(avr-gcc) but I did find a crt1.S (and the same with the corresponding .o files)

什么是这两个文件之间的差异?是CRT1完全不同的东西还是什么?他们都似乎有东西引导做的(设置堆栈帧等等),但为什么区别?

What is the difference between these two files? Is crt1 something completely different or what? They both seem to have to do with something for bootstrapping(setting up stack frame and such), but why the distinction?

推荐答案

这两个信息crt0 / CRT1做同样的事情,基本上是调用之前需要什么样的main()的(如堆栈初始化,设置的IRQ等)。应该用一个或另一个但不是两者连结。他们是不是真的库,但真正的内联汇编code。

Both crt0/crt1 do the same thing, basically do what is needed before calling main() (like initializing stack, setting irqs, etc.). You should link with one or the other but not both. They are not really libraries but really inline assembly code.

据我了解,CRT有两种口味

As far as I understand, crt comes in two "flavors"


  • CRT1 在支持(之前和之后的主要和退出被调用函数)构造和析构系统中使用。在这种情况下,主要是对待像一个正常的函数调用。

  • 信息crt0 用于在不支持的构造函数/析构函数系统。

  • crt1 is used on system that support constructors and destructors (functions called before and after main and exit). In this case main is treated like a normal function call.
  • crt0 is used on systems that does not support constructors/destructors.

这篇关于中的crt0.o和crt1.o - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆