Linker options to report RAM overflow

View: New views
3 Messages — Rating Filter:   Alert me  

Linker options to report RAM overflow

by vaclavpe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

today I did some experiments with long buffers and accidentally set buffers longer than 1kB on ATMEGA16. The only visible problem was that printf() stopped working. One hour later I noticed that I have too long buffers.

Can I force linker to shout in such situation ?

Thank you in advance,
Vaclav


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: Linker options to report RAM overflow

by Weddington, Eric :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eric.weddington=atmel.com@...
> [mailto:avr-gcc-list-bounces+eric.weddington=atmel.com@nongnu.
> org] On Behalf Of Vaclav Peroutka
> Sent: Monday, September 14, 2009 10:33 PM
> To: avr-gcc-list@...
> Subject: [avr-gcc-list] Linker options to report RAM overflow
>
> Hello all,
>
> today I did some experiments with long buffers and
> accidentally set buffers longer than 1kB on ATMEGA16. The
> only visible problem was that printf() stopped working. One
> hour later I noticed that I have too long buffers.
>
> Can I force linker to shout in such situation ?
>

Take a look at the first diagram on this page in the avr-libc user manual:
http://www.nongnu.org/avr-libc/user-manual/malloc.html

The stack grows downwards, and there is no way to set in the toolchain a bottom value to that stack. Also, if you use dynamic memory allocation (malloc) the heap grows upward, again without a preset boundary. This means that there is not a way that the toolchain will know that there is a stack overflow, or data overflow, because that is only discovered at run-time.


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: Linker options to report RAM overflow

by Joerg Wunsch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

=?us-ascii?Q?Vaclav=20Peroutka?= <vaclavpe@...> wrote:

> Can I force linker to shout in such situation ?

In addition to the problem Eric mentioned, all AVR linker scripts
generally set the length of the data segment to 0xffa0 (starting at
0x60 by default, which can be overridden by the compiler), so even a
static RAM allocation overflow would only be detected once the
allocation exceeds that value.

This has been done since the linker has no notion about which AVR
device could possibly access external SRAM and which cannot.  Thus,
all AVRs are assumed to offer this capability.  Without that
generalization, we would need one linker script per AVR device
(actually even five of them, because the linker needs five files per
device/architecture).

Just use the avr-size command to monitor the static RAM and ROM
consumption.

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

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


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list