This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [uClinux-dev] brk(2) and stack pointer


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


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