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: Heap and Stack Usage


Hi,

I hope this is not too late. Did you get the solution for the problem ?
Please go thro' my remarks.

Yes. Section .end in the linker script specifies the end of heap.
As a note of advice, this section should not get overlapped with any other
sections, specially .stack section.

At the moment, inside the compiler, no such ceiling is available to limit
heap size or to have fixed size stack. But this can be achieved using user
defined dummy sections in between stack and .end section.

Regards

GNUTeam

-----Original Message-----
From: crossgcc-owner@sources.redhat.com
[mailto:crossgcc-owner@sources.redhat.com]On Behalf Of John Lowen
Sent: Friday, June 15, 2001 11:54 PM
To: crossgcc@sourceware.cygnus.com
Subject: Heap and Stack Usage


Is it possible to limit the heap size? My understanding is that dynamic
memory allocation occurs through the use of sbrk() when memory is needed via
malloc, etc. If the memory is available, a pointer is returned to the block.
If there is not enough memory, the heap is expanded by 4k increments (sh
target). My understanding is that the heap will grow until the top of the
heap overlaps the stack. Looking at the sources is appears that the new top
of heap is checked against the stack pointer and if the allocation would
cause the heap to expand beyond the stack pointer, a null pointer is
returned indicating not enough memory. Since the stack pointer tends to be
volatile, this could cause problems unless there is plenty of memory for
stack and heap. My question is whether you can put a hard ceiling on the
heap independent of the stack pointer, thereby creating a fixed-size area
that is exclusively used by the stack. I read a reference on brk() in glibc
documentation but brk() was undefined in my implementation which is sh-elf.

Thanks,
John

AMT-Datasouth
jlowen@amtdatasouth.com
http://www.datasouth.com
(704)523-8500 ext. 132




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


------
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]