avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] malloc bug ?


From: daniel_laptop
Subject: Re: [avr-libc-dev] malloc bug ?
Date: Sun, 08 Sep 2002 23:55:01 +1200

Hello All

This is not directly related to malloc bug
(but I found it while doing att. file)

My question is, is __heap_start used in anything other than malloc.c

Will att. file work for all avr-libc functions (only changing
__malloc_heap_start)

This is for moving .noinit section into external ram
(as per docs
http://freesoftware.fsf.org/download/avr-libc/doc/avr-libc-user-manual/mem_sections.html
)
also moves __heap_start to external ram so att. file to set
__malloc_heap_start to same as __bss_end
(where it would be if there was no .noinit section.)

Thanks
Daniel

#include <avr/io.h>
void init_xram (void) __attribute__ ((naked)) __attribute__ ((section 
(".init1")));

void
init_xram (void)
{
  /* enable xram */
  sbi(MCUCR,SRE); /* larger but more compatable */
  /* MCUCR = _BV(SRE); */ /* smaller but less compatable */
}

/* next section only done if "#include <stdlib.h>" already done (malloc) */
#ifdef _STDLIB_H_
/* stdlib.h has char *__malloc_heap_start */
/* next is only when .noinit section position set e.g. in makefile
   LDFLAGS += -Wl,--section-start=.noinit=0x800260
   this moves __malloc_heap_start back to __bss_end
   (same as it would be with zero .noinit size and .noinit not moved)
*/

/* ##### is __heap_start used for other things ??? ##### */

/* this needs to be done after .init4 to stick */
void init_noinit_moved (void) __attribute__ ((naked)) __attribute__ ((section 
(".init5")));

void
init_noinit_moved (void)
{
  extern char __bss_end;
  extern char __noinit_start;

/* if below is only when .noinit section position set (moved) e.g. in makefile
   LDFLAGS += -Wl,--section-start=.noinit=0x800260
   below moves __malloc_heap_start back to __bss_end
   (same as it would be with zero .noinit size and .noinit not moved)
*/
  if(&__bss_end != &__noinit_start) /* noinit has been moved */ 
    {
      __malloc_heap_start = &__bss_end;
    }
}

#endif

reply via email to

[Prev in Thread] Current Thread [Next in Thread]