#47: The captain violates the Prime Directive, then either endangers the Enterprise or has an affair
with an attractive alien, or both, while trying to rectify matters.
#48: The captain eventually brings peace to two primitive warring societies ("we come in peace, shoot
to kill") on a world that is strangely reminiscent of Earth.
—Professor Snopes' Book of Canonical Star Trek Plots, and Delicious Yam Recipes
a.out and a.out folklore...segments...what the OS does with your a.out...what the C runtime does
with your a.out...what happens when a function gets called: the procedure activation record...helpful
C tools...some light relief—Princeton programming puzzle
One of the classic dichotomies in programming language theory is the distinction between code and
data. Some languages, like LISP, unite these elements; others, like C, usually maintain the division.
The Internet worm, described in Chapter 2, was hard to understand because its method of attack was
based on transforming data into code. The distinction between code and data can also be analyzed as a
division between compiletime and runtime. Most of the work of a compiler is concerned with
translating code; most of the necessary data storage management happens at runtime. This chapter
describes the hidden data structures of the runtime system.
There are three reasons to learn about the runtime system:
- It will help you tune code for the highest performance.
- It will help you understand more advanced material.
- It will help you diagnose problems more easily, when you run into trouble.
a.out and a.out Folklore
Did you ever wonder how the name "a.out" was chosen? Having all output files default to the same
name, a.out, can be inconvenient, as you might forget which source file it came from, and you will
overwrite it on the next compilation of any file. Most people have a vague impression that the name
originated with traditional UNIX brevity, and "a" is the first letter of the alphabet, so it's the first letter
you hit for a new filename. Actually, it's nothing to do with any of this.
It's an abbreviation for "assembler output"! The old BSD manpage even hints at this:
NAME
a.out - assembler and link editor output format
One problem: it's not assembler output—it's linker output!
The "assembler output" name is purely historical. On the PDP-7 (even before the B language), there
was no linker. Programs were created by assembling the catenation of all the source files, and the
resulting assembler output went in a.out. The convention stuck around for the final output even after a
linker was finally written for the PDP-11; the name had come to mean "a new program ready to try to
execute." So the a.out default name is an example in UNIX of "no good reason, but we always did it
that way"!