[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creatin
From: |
Colin D Bennett |
Subject: |
[avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable |
Date: |
Fri, 18 Apr 2008 10:23:04 -0700 |
Hi,
I spent two days trying to track down why my program was behaving
unexpectedly -- as in, when I write to a global variable, it does not
read back as the same value! I finally tracked it down to this:
the global variable was getting placed at RAM address 0x60 on my
ATmega88, which is the location of one of the watchdog registers!
It turns out that my Makefile was not passing the -mmcu=X flag when I
linked my object files together (with avr-gcc), so gcc silently assumed
that putting the variable at 0x60 is OK. By adding -mmcu=atmega88 to
the linker flags, the variable was then placed at RAM address 0x100,
which then made the code behave properly on the target device.
When you compile code with avr-gcc and avr-libc without specifying
-mmcu=X, you get a warning; shouldn't it be the same with linking?
Clearly, the default assumption of the linker will not result in a
working program for all AVR models, as I have found.
Am I doing something wrong? Should I have got a warning? Should I be
using 'avr-ld' to link instead of 'avr-gcc'? Do you think that linking
a program for an unknown AVR MCU model makes sense?
Thanks,
Colin
- [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable,
Colin D Bennett <=
- Re: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Colin D Bennett, 2008/04/18
- Re: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, David Brown, 2008/04/19
- Re: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Joerg Wunsch, 2008/04/19
- RE: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Weddington, Eric, 2008/04/21
- Re: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Joerg Wunsch, 2008/04/21
- RE: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Weddington, Eric, 2008/04/21
- Re: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Dave N6NZ, 2008/04/21
- RE: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable, Weddington, Eric, 2008/04/21