How gcc fills up crti.S

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
siavoshkc
Member
Member
Posts: 40
Joined: Wed Feb 19, 2014 11:10 am

How gcc fills up crti.S

Post by siavoshkc »

In meaty skeleton, in file crti.S there is a remark noting "/* gcc will nicely put the contents of crtbegin.o's .init section here. */". I am confused. Where is this crtbegin.o? And how gcc knows to fill crti.S with it?
Check out my FSB Data Integrity Tester at http://fsbdit.sourceforge.net/.

Siavosh
Octocontrabass
Member
Member
Posts: 5578
Joined: Mon Mar 25, 2013 7:01 pm

Re: How gcc fills up crti.S

Post by Octocontrabass »

siavoshkc wrote:Where is this crtbegin.o?
It's provided by GCC.
siavoshkc wrote:And how gcc knows to fill crti.S with it?
You tell it to do that in the makefile. The linker automatically combines sections with the same name in the order they're linked. There are sections named ".init" and ".fini" in crtbegin.o, just like the ones in crti.S, and crti.o is linked before crtbegin.o.
User avatar
siavoshkc
Member
Member
Posts: 40
Joined: Wed Feb 19, 2014 11:10 am

Re: How gcc fills up crti.S

Post by siavoshkc »

There was no explanation about this in the meaty skeleton page. Maybe a good idea to add a section about this.

Is there any page explaining those file sources?
Check out my FSB Data Integrity Tester at http://fsbdit.sourceforge.net/.

Siavosh
Post Reply