[Top][All Lists]

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

Re: [avr-gcc-list] avr-as doesn't treat non-existing labels as warnings?

From: Theodore A. Roth
Subject: Re: [avr-gcc-list] avr-as doesn't treat non-existing labels as warnings?
Date: Thu, 18 Nov 2004 07:49:13 -0800 (PST)

On Thu, 18 Nov 2004, Johannes Bauer wrote:

> Hi list,
> is it just me or... does avr-as not spit out at least a warning when
> there are jumps to non-existent labels? They're quite hard to find and
> I've had some trouble there today. For example, when you have a typo in
> your "rjmp" label, it is just ignored and assembled to "rjmp .+0".

My guess is that you are using avr-as only and not linking the final
program with avr-ld (which you should let avr-gcc do). To test this
theory, I wrote a two line asm file:

  $ cat foo.S
          rjmp bar

Pretend that bar is a misspeeled foo.

Then my Makefile build the program like this:

   $ make
1  avr-gcc -g -Os -Wall -mmcu=atmega128     -c -o test.o test.c
2  avr-gcc -g -Wall -x assembler-with-cpp -mmcu=atmega128 -c -o foo.o foo.S
3  avr-gcc -g -Os -Wall -mmcu=atmega128   -Wl,-Map,test.map  -o test.elf test.o 
   foo.o(.text+0x0): In function `foo':
   : undefined reference to `bar'
   make: *** [test.elf] Error 1

Note that the second command (assembling foo.S into foo.o) was
successful, but the linker (third command) complained that it couldn't
find a reference to bar.

Here's the dump of foo.o:

  $ avr-objdump -d foo.o

  foo.o:     file format elf32-avr

  Disassembly of section .text:

  00000000 <foo>:
     0:   00 c0           rjmp    .+0             ; 0x2

The assembler is doing the correct thing here since it assumes that you
are going to link the resulting object file to other modules which may
(or may not) resolve the undefined symbol.

If you want to assembler a single asm file into a final rom image, you
would probably want to do something like this:

  $ avr-gcc -x assembler-with-cpp -mmcu=atmega128 -nostartfiles -nodefaultlibs 
-nostdlib -o foo.elf foo.S
  /tmp/cc8wLduR.o(.text+0x0): In function `foo':
  : undefined reference to `bar'

Notice that this indeed catches the undefined reference.

Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden

reply via email to

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