[TriLUG] what do crt[1in].o do?

Joseph Mack NA3T jmack at wm7d.net
Wed Dec 9 11:10:37 EST 2009


On Wed, 9 Dec 2009, Rodney Radford wrote:

>
> The crt are the "C Run Time" objects that set up the 
> environment expected by main, such as getting the opening 
> any files,

OK

> initializing the C runtime library

what/where is the C runtime library - is it in the crt*.o 
files?

> setting up the stack, setting up heap, and grabbing the 
> values of argc, argv, and envp for your main program, and 
> opening stdin, stdout and stderr.

thanks good to know. I haven't been able to find this 
anywhere with google and it's not in K&R II or Harbison and 
Steel (another C book)

I assume this is common knowledge somewhere. Is this found 
in undergrad CS books?

> You should be able to create the link line with your 
> output assembly file and those files,

that's what I thought too :-)

> but there may be additional switches to set up the entry 
> point for the executable.

who know's what's missing.

> The reason the debugger starts at main is you are using a 
> source level debugger and you don't have C source for the 
> crt files.

sounds reasonable.

I did find two crt*.asm files, but not the 3rd. When I 
figure out how to link the crt*.o files to get a working 
executable, the next thing would be to produce the crt*.o 
files from the .asm files. However docs on the internet seem 
to assocate the crt*.o files with libc in some situations 
and with the compiler in other situations (and I don't know 
which is which). Presumably you'd have to understand this to 
link up all of these files from source.

> If you were to use a lower level debugger (or 
> you can probably pass in an argument to your debugger to 
> tell it to not auto-step over the crt code), you could 
> stop at the real entry point and single step through the 
> assembly code setup.

sounds reasonable too - it's theoretically possible then. 
That's good to know.

Thanks Joe

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!



More information about the TriLUG mailing list