This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [uClinux-dev] brk(2) and stack pointer
- From: Jamie Lokier <jamie at shareable dot org>
- To: uClinux development list <uclinux-dev at uclinux dot org>
- Cc: ARM Linux <linux at arm dot linux dot org dot uk>, newlib at sources dot redhat dot com
- Date: Fri, 28 Apr 2006 17:11:40 +0100
- Subject: Re: [uClinux-dev] brk(2) and stack pointer
- References: <7f45d9390604280853tf742eb6qfc8e213b78c7df03@mail.gmail.com>
Shaun Jackman wrote:
> I'm implementing ARM Linux support for the newlib libc. When
> implementing brk(2), is it reasonable to check that the requested
> end_data_segment is below the stack pointer, or should the brk(2)
> implementation allow for a stack that's been allocated below the heap
> in memory?
A few programs allocate memory on the heap, and then use that as a
stack (possibly one of several stacks). Programs which do that will
fail your test, unless malloc(3) is implemented by doing anonymous
mmap(2) instead of brk(2).
Such programs tend to be those doing user-space threading or clever
things with signals. Those techniques are relatively portable and
valid, using "sigaltstack" or "makecontext", so although most programs
don't use them, a few do that you might want to use (or someone else
using newlib on ARM might want to use).
What's the reason for the check?
-- Jamie