OK Erik,

I think I can see the mechanism now.
The crt[tn13].o seems to be complied from avr-libc-1.4.6/crt1/gcrt1.S
which has:
==========================================================================
#ifndef __AVR_ASM_ONLY__
        .weak   __stack

        /* By default, malloc() uses the current value of the stack pointer
           minus __malloc_margin as the highest available address.

           In some applications with external SRAM, the stack can be below
           the data section (in the internal SRAM - faster), and __heap_end
           should be set to the highest address available for malloc().  */
        .weak   __heap_end
        .set    __heap_end, 0

        .section .init2,"ax",@progbits
        clr     __zero_reg__
        out     _SFR_IO_ADDR(SREG), __zero_reg__
        ldi     r28,lo8(__stack)
#ifdef SPH
        ldi     r29,hi8(__stack)
        out     _SFR_IO_ADDR(SPH), r29
#endif
        out     _SFR_IO_ADDR(SPL), r28
==========================================================================
This means that the __stack value is determined at the time of compiling
avr-libc. It is marked as weak, so I can override it's value in my
source file (tested). It's a shame that not all the .init[x] sections
aren't marked as weak so they could be individually overwritten (.init0 is).
Either I live with the (admitted small - but on these parts every byte
counts when you're up against the end stops) penalty of some redundant
code or I modify my avr-libc and recompile as a non-standard toolchain.
I checked the latest release and the code here is still the same.

Anyway, many thanks for your comments Erik, I wish you good health,

Robert

_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat

Reply via email to