[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] avr-size .bss bigger than RAM?
From: |
Erik Christiansen |
Subject: |
Re: [avr-chat] avr-size .bss bigger than RAM? |
Date: |
Tue, 1 Aug 2017 19:16:49 +1000 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On 25.07.17 19:24, Stuart Longland wrote:
> > $ avr-size bin/attiny861/synth
> > text data bss dec hex filename
> > 3216 6 535 3757 ead bin/attiny861/synth
On 26.07.17 08:10, Stuart Longland wrote:
> On 25/07/17 22:36, Rolf Pfister wrote:
> > I would say it uses more than 29 bytes too much. Because data also
> > needs SRAM. And subroutine calling and interrupts will also need some
> > bytes of SRAM for the stack.
> > Maybe you didn't see something going wrong yet because it didn't fill
> > all reserved data structures yet.
>
> Right… I was a bit surprised that it would allow such a program to link.
> arm-ld complains when the data structures won't fit into the spaces
> allocated by the linker script.
Yes, the gnu linker does warn on memory region overflow, so it is likely
that the linker script you're using is one of those which were made so
generic that this protection has been disabled. Your version may differ,
but here:
$ avr-gcc -mmcu=attiny861 -Wl,--verbose | more
...
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 8K
data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K
lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K
signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K
}
Your data + bss has no chance of overflowing 0xffa0 (65440) bytes.
Admittedly, my version is perhaps a bit dated:
$ avr-ld --version
GNU ld (GNU Binutils) 2.20.1.20100303
There is nothing to stop you taking a copy of the linker script, and
correcting the size limit on the data region, to restore the protection.
> I did another check, and found one of my structures occupied the full
> 512 bytes, so I've cut it back, .bss is now 279 bytes.
>
> Often the code will define a big integer array somewhere and call that
> the stack, so you know exactly where it is and how big it is. AVR
> though, all that is abstracted.
>
> Anyone know where I can find out how much RAM is allocated for stack on AVR?
If you have a look at the prologue to main, in a list file for your
program, created with an avr-gcc option along the lines of:
-Wa,-ahdl=xx.lst
then the top of stack may be found where it is loaded into SP. What is
available is the gap between that and what you have used.
Erik
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [avr-chat] avr-size .bss bigger than RAM?,
Erik Christiansen <=