If I remember correctly, part of the reason that the stack grows down from the top is to make it easier for both the stack and heap to grow. Since both stack and heap can grow, it would be difficult to have them be placed back to back in virtual memory. To do that, you would have to make all addresses in either the stack or heap relative to some movable starting point. That would be an address translation headache. Instead, both have their starting points bound by fixed address regions. The heap grows up, the stack grows down and they can grow until they collide, which will occur when you have exhausted your VM space. -Brian Tabone On Thursday, April 3, 2003, at 12:08 AM, Robert Plantz wrote: On Wednesday, April 2, 2003, at 07:10 PM, Justin Walker wrote: tisdagen den 1 april 2003 kl 05.54 skrev Jim Magee: Out of curiosity, I've always wondered why the ABI grows the stack downwards. It seems to be just as easy to grow it upwards, which would make buffer overflows much harder, if not impossible. Habit, mostly, I think. Most of this stuff grew up on PDP11's, and the PDP11 architecture gave downward growing stacks (among other things, interrupts and subroutine calls predecremented stack pointers; and the register specifiers in instructions made it easy to 'comply' with that mode of operation). With modernXXXmore recent architectures like PowerPC where a stack is more ABI than ISA, you can, as it were, go either way (:-}). Perhaps I'm being too simplistic, but if I wanted to make maximum use of memory, I would store my program code at one end and start my stack at the other, then let them grow toward each other. --Bob _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored. _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.