This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Malloc problem with ARM EB01


Hi!
Itīs same for "new" and "delete" from c++. Is this a problem of
gcc or newlib? (Does the gcc know about angel?) I have the swi
in "abort.c".

I have solved this problem with:

typedef struct {
  int usedFlag;
  int * pStart;
  int * pEnd;
} fieldStruct;

class MemAllocator {
 public:
  MemAllocator(); 
  int * newMem(int memBytes);
  int deleteMem(int * pMemorie);
 private:
  int * startMem;
  int * endMem;
  fieldStruct mem[MAX_MEM_POINTER];
};

MemAllocator::MemAllocator() {
  int i;

  static int intVar[ALL_TASKS_STACK_SIZE_WORDS/sizeof(int)];

  startMem = (int *) (& intVar);
  endMem = startMem + ALL_TASKS_STACK_SIZE_WORDS;
  
  for (i=0;i<MAX_MEM_POINTER; i++){
    mem[i].usedFlag=FALSE;
    mem[i].pStart = endMem;
    mem[i].pEnd = endMem;
  }
}

This Object grabs statically a chunk of mem and provides my program
dynamically with it. The strategy is "first fit". You may also overload the
new and delete operators. Hope that helps. It is integrated in 
a small OS wich I develop on the eb01. Have a look at my web site,
->Project-Documentation->most recent blabla

:-)
Jens-Christian

Am Don, 08 Feb 2001 schrieben Sie:
> Hi all!
> 
> I'm not sure that this is the right mailing group to send this to but i'll
> try anyway ;-)
> 
> I'm working with Atmels AT91EB01 board in a RedHat 6.2 Linux enviorment
> using crosscompiler for ARM ELF:
> arm-elf-gcc version 2.96 20000501 (experimental)
> arm-elf-ld version 2.10 (with BFD 000606)
> newlib version 1.9.0
> arm-elf-gdb version 5.0
> 
> The problem is malloc() and free(), they cause a SWI during runtime. I
> think this has something to do with that the stack and heap are defined to
> some default value that isn't supported by EB01.
> If i'll write programs that don't use malloc() and free() they work fine!
> 
> The make file looks for example like this for those programs:
> CC=arm-elf-gcc
> LD=arm-elf-ld
> RM=rm
> 
> CFLAGS= -g -mcpu=arm7tdmi -I/usr/local/arm/newlib-arm-elf/arm-elf/include
> LDFLAGS= -Ttext 0x2000000 -e 0x2000000 -nostdlib -Map mapfil.txt
> LDLIB=/usr/local/arm/newlib-arm-elf/arm-elf/lib/libc.a 
> /tools/H-i686-pc-linux-gnu/lib/gcc-lib/arm-elf/2.96/libgcc.a
> RMFLAGS=-f
> 
> all:     program
> 
> program:   serial.o pio.o lib_usart.o lib_aic.o lib_pio.o
> 	$(LD) $(LDFLAGS) -o serial.elf serial.o pio.o $(LDLIB)
> 
> ..... and so on..
> 
> NOTE: 0x2000000 is the lowest adress in SRAM
> 
> I read that you can use a crt0.o file for setting upp the different
> sections (.text .data ...).
> 
> Any one know how to solve the problem is with malloc() and free()?
> Is a crt0.o file the only solution or can I tell the linker where to put
> the stack and heap?
> 
> Thanks for your time!
> 
> /Jimmy
> Halmstad University, Sweden
> 
> 
> ------
> Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
> Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
-- 


Jens-Christian Lache
Technische Universitaet Hamburg-Harburg
www.tu-harburg.de/~sejl1601
Mail:
lache@tu-harburg.de
lache@ngi.de
Tel.:
+0491759610756

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]