This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: help!!!


On Wed, Apr 25, 2001 at 09:02:29PM -0400, Robert Bernecky wrote:
> If you stuff the above text into a file called "simple.c"
> and then do:
> 
>   gcc simple.c
> 
> you should get a file apeparing called (Don't ask me why -- it's
> stupid, but that's what it does...)  a.out.

In the interest of expanding everyone's pile of useless trivia: a.out
stands for "assembler output".  If you write a trivial program in
assembly, e.g (i386 and Linux specific)

; iefbr14
	.text
	.globl _start
_start:
	movl	$0x0, %ebx
	movl	$0x1, %eax
	int	$0x80

and do "as test.s", you'll get a file named a.out.  On an ELF-based
system that file is not executable, but with older Unixes it would
have been (maybe needing a chmod +x first).  You can make it
executable by running ld on it with no further arguments, except that
ld doesn't like having its input and output have the same name, so you
have to do

$ as test.s -o test.o
$ ld test.o

to get an actual executable a.out on an ELF system.

I've heard a legend that on really old Unixes (pre-V7) a trivial C
program could be compiled and assembled into a complete, executable
a.out without any link phase.  Hence, the default executable name is
"a.out" because, way back in the mists of 1970, it really was the
output of the assembler.  I'm not sure if I believe this - it seems to
me that libc.a and maybe crt0.o would have been needed from the
beginning.

These days, a.out is still the default output name out of historical
inertia.  It's also known not to be the name of any system utility or
application, so convenient for trivial programs.  ("test" isn't
suitable, that's a shell builtin, more commonly known as "[".)

Mr. Henry may be interested to know that the name can be changed with
the -o option to the compiler, so:

$ cc simple.c -o simple

will create "simple", not "a.out".

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]