crt0.o and crt1.o — What's the difference?

20 篇文章 0 订阅
13 篇文章 0 订阅

原帖: http://stackoverflow.com/questions/2709998/crt0-o-and-crt1-o-whats-the-difference

==============================================================================================================================

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)

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?

===============================================================================================================================

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.

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

  • 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.
===============================================================================================================================


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值