[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Help understanding output files

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Help understanding output files
Date: Sat, 18 Feb 2006 10:14:15 +0100 (MET)

Micah Carrick <address@hidden> wrote:

> avr-gcc -g -mmcu=atmega8 -Os -Wall -Wa,-ahlms=toggle_led.lst -c toggle_led.c

> The first command, I am telling the assembler to generate a listing
> (toggle_led.lst) and an object file right?

You are telling the compiler to compile (-c) toggle_led.c into an
object file.  While doing that, you instruct the compiler to pass the
flags -ahlms=toggle_led.lst to the assembler, which will cause the
assembler to create an assembly listing file in addition to the object
file.  (By default, the assembler does not create listing files.)

The object file gets the default name, which is the name of the source
file with the .c replaced by .o.

>  Is the .o file generated an ELF object file file?

Yes, all object files (relocatable and non-relocatable, i. e. after
linking) are ELF files.

> avr-gcc -Wl,-Map,toggle_led.map -lm  -o toggle_led.out toggle_led.o

> Next command tells the linker to generate a map file
> (toggle_led.map) and -lm links to the math library when using
> <math.h>, and the output file (toggle_led.out) is an elf executable.

This command instructs the compiler to call the linker in a way
suitable for a C programming environment, use toggle_led.o as the
input object file, and name the output (non-relocatable) object file
toggle_led.out (the default name would be a.out).  It also passes the
option -lm to link against the math library (libm.a), but this option
is pretty pointless the way it is written, as it comes early on the
command-line.  As input object and object library files are processed
in their command-line order, and libraries are only used to satisfy
undefined external references, and since there are no preceding input
files before the library, there is not a single undefined reference
that far, nothing will be linked in from libm.a.

It also instructs the compiler to pass the option -Map=toggle_led.map
to the linker, so the linker will create a map file -- for those who
are fond of it.  I personally don't think linker map files are
readable in any way, or otherwise serve any useful purpose except
debugging the linker itself.  I believe most people would better be
served by a symbol table listing than the overly verbose linker map

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]