Somewhat newb question about assy and the heap.

Posted by Eric M on Stack Overflow See other posts from Stack Overflow or by Eric M
Published on 2011-01-09T03:21:25Z Indexed on 2011/01/09 3:54 UTC
Read the original article Hit count: 229

Ultimately I am just trying to figure out how to dynamically allocate heap memory from within assembly.

If I call Linux sbrk() from assembly code, can I use the address returned as I would use an address of a statically (ie in the .data section of my program listing) declared chunk of memory?

I know Linux uses the hardware MMU if present, so I am not sure if what sbrk returns is a 'raw' pointer to real RAM, or is it a cooked pointer to RAM that may be modified by Linux's VM system?

I read this: How are sbrk/brk implemented in Linux?. I suspect I can not use the return value from sbrk() without worry: the MMU fault on access-non-allocated-address must cause the VM to alter the real location in RAM being addressed. Thus assy, not linked against libc or what-have-you, would not know the address has changed.

Does this make sense, or am I out to lunch?

© Stack Overflow or respective owner

Related posts about memory-allocation

Related posts about assembler