Howdy.
I recently ran into an issue with my program stack growing into the
statically-allocated variables in the .bss section due to some
overenthusiastic use of printf's. Looking through the archives, I found this
discussion<http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg10178.html>
regarding
general stack protection techniques.

Two questions, which may be more general gcc/ld-related than msp-specific

1. While it's impossible in the general case to determine the maximum stack
size that a program will use, is there any mspgcc setting (or standalone
tool) that can handle the simple cases that dominate in MCUs (no recursion,
no function pointers, no nested ISRs) and spit out a maximum stack depth?


2. Failing that, what is the preferred method for indicating that X bytes
should be reserved at the top of RAM, and violations of this should result
in a linker error? It looks like the .noinit section gets placed where I
want it, so I see a couple of options:

a. Use the RESERVE_RAM
annotation<http://mspgcc.sourceforge.net/manual/x1023.html> on
the main method. This is somewhat undesirable to me because I'm working in
TinyOS and this would introduce what seems to be an msp-gcc specific change
to an otherwise platform-independent core file. It's not a deal-breaker,
but I'd like to avoid it if possible. Unless avr-gcc supports this and I'm
just not finding it in the documentation.

b. Use the section attribute, something like this:
char __attribute__ ((section(".noinit"))) stack_space[RESERVED_STACK_SIZE];

where RESERVED_STACK_SIZE is based on either observation or the type of
analysis described above. This appears to be somewhat supported by
avr-gcc<http://nongnu.org/avr-libc/user-manual/mem_sections.html#sec_dot_noinit>
.

c. Some unknown-to-me command in the linker script that forces a particular
section to be of a given size, regardless of what symbols are actually
supposed to be placed there.


Any suggestions would be most appreciated.

Thanks!
Doug Carlson
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to