[TriLUG] what do crt[1in].o do?
Joseph Mack NA3T
jmack at wm7d.net
Wed Dec 9 17:43:05 EST 2009
On Wed, 9 Dec 2009, Rodney Radford wrote:
Thanks Brian and Rodney,
> http://gcc.gnu.org/onlinedocs/gccint/
OK will look
> You can also run strace on the executable generated to
> find out what system calls are executed for the process
> and the names of any shared libraries that are being
> opened (for example, /lib/libc.so.6 for my system).
I tried strace on the executable that didn't run in my first
posting and all it gave was "execv: cannot find file"
> And may I ask why you are curious?
OK reasonable question. This means I have to come out of the
closet.
Short answer:
I'm teaching C and I don't know much about it :-(
(Really) Long answer:
My C is execrable. I learned it out of K&R vI and grabbed
pieces here and there to get something to work. With no time
to learn all the bits in between (and before the internet,
no one to ask), I filled in my explanations of the missing
bits with witchcraft (I was a biochemist at the time; now
I'm a full time computer person.)
For the past 2 yrs I've been teaching programming to middle
(now high) school students after school. Previously I'd been
soccer coaching and ref'ing for about 10yrs as my way of
helping kids along. I found my son wasn't being challenged
at school (I think his childhood is being wasted). I had to
be a better programming teacher than soccer teacher so I
offered to teach computer programming to anyone interested.
Two kids puts their hands up (one was my son). The school
wouldn't have a bar of it and wouldn't let me do it on the
school grounds (it overlapped with their AP Java course
apparently) so we do it in my home or the kid's home 2hrs
twice a week.
Here's my introductory class material.
http://www.austintek.com/#python
I used python to teach procedural programming although I'd
never used it before, because one of the kids liked python.
I decided if he wanted python, then he should get python (it
was his class after all) and if I couldn't teach python to
7th graders, even if I'd never used it before, then I should
shoot myself. Even though it wasn't my choice as an
introductory language (I wanted to do bash), it turned out
well, as you can teach procedural programming without having
to address the hardware or the OS (one kid did it on WinXP
and the other on a Mac and kid's code worked on both
machines). The kids get a minimal number of errors and
there's only a small number of idiosyncracies, most of which
can be explained easily, so the frustration level is low.
After this got rolling, I dropped being a soccer referee (I
was with CASL, which was well run and I liked being part of
the show, they treated refs well). I was right - I'm much
better at teaching programming than soccer.
Now I'm teaching C
http://www.austintek.com/#c
With procedural programming out of the way, I don't have to
teach the C constructs for iteration...etc and just tell the
kids to do look it up. Instead I can look at how C works.
Unlike python which appears to sit in a perfect virtual
machine, with C you wind up doing something with the machine
or the OS on just about every instruction, so teaching C is
much harder (or deeper; there's a lot more to what you're
doing).
I don't want the kids in 5 or 10yrs to say "you know I use
this all the time and I've never understood it". I've
decided it's time for me to look at all the witchcraft in my
head. Now everything I do, I ask if I understand it. Usually
I don't and have to look it up.
When you compile the "hello world" program, the first thing
you see is that the executable is about 3k while the object
file is 800 bytes. When you look at the executable with `nm
-o` you see all sorts of stuff that isn't in the object
file. What is it? I don't know. I can't say to the students
"you don't need to know that". They already get that at
school all day. I can't say "I don't know and if that's good
enough for me, then you don't need to know either". I know
only too well the misery of not knowing stuff. I wouldn't
wish that on anyone else.
So first day of C with "hello world" you hit crt[1in].o.
Sure I fobbed the kids off about it. But now we're up to
storage (auto, static, bss, data...) and I'm looking at the
simple pieces of code with the assembler to see where the
variables are stored. I used to program in assembler making
DOS TSRs. The linux assembly code looks just like the code
that ran fine under DOS, but under Linux it doesn't run
without crt[1in].o. It really is time to find out why not.
No-one at work knows anything about crt[1in].o. My searches
with google weren't helpful. So I tried TriLUG where
crt[1in].o seems to be well understood.
One of the side benefits of doing this class is that I'm
finally going to learn C properly. There's one more student
in this class than the students know about. Me.
I spend all weekend writing the class and the kids can run
through a weekend's work in about an hour sometimes. In a
way I'm glad; learning should be this easy, but I would have
hoped by now, that something that takes me 12hrs to figure
out should take more than an hour for a 9th grader to
digest.
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