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

前端 未结 1 343
独厮守ぢ
独厮守ぢ 2021-01-30 21:17

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 sam

相关标签:
1条回答
  • 2021-01-30 22:05

    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 systems 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 do not support constructors/destructors.
    0 讨论(0)
提交回复
热议问题