crt0.o and crt1.o — What's the difference?
2012-10-02 11:26
423 查看
原帖: 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.
===============================================================================================================================
==============================================================================================================================
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.
===============================================================================================================================
相关文章推荐
- Green and native threads -- what's the difference?
- Stack vs. Heap: What's the difference?
- CareerCup What is the difference between a computers heap and it's stack?
- What is the difference between '/n' and '/r/n'? /n /r/n的区别是什么
- Disaster Recovery, High Availability, and Continuous Availability - What's the Difference?
- What's the difference between a URI and a URL?
- App server, Web server: What's the difference?
- What's the best Linux server for you? == 最佳Linux服务器发行版
- what's the real life?
- 哈佛:孰对孰错 中英字幕 What's the right thing to do
- 《公正:该如何做是好?》(Justice: What's the Right Thing to Do? )【youtube上最受欢迎讲座】【哈佛大学最受新生喜爱公共课】【更新BBC里斯讲座】
- What's New in the .NET Framework 2.0 Beta
- The difference between 'typedef' and '#define'
- intro: what's the problem
- What is the difference between a = a * (2^3) and a = a << 3?
- What is the 'software life cycle'?
- What’s the Difference Between Sudo & Su?
- Justice: What's the Right Thing to Do
- What's the true life
- What are the differences between shell , console & terminal?