Scott Bell
Scott Bell

Reputation: 51

How do you dynamically allocate memory in Mac OS X assembly?

I would like to dynamically allocate memory from an assembly program that does not link against the standard C library. Since brk(2) and sbrk(2) are unavailable on Mac OS X (10.6.2), what are the alternatives?

(I'm guessing that it involves a Mach call, but there seems to be little documentation around that)

Upvotes: 5

Views: 2207

Answers (2)

Ken Aspeslagh
Ken Aspeslagh

Reputation: 11594

Looks like malloc calls mmap, which calls __mmap, which looks like it's just a syscall

Upvotes: 2

Paul R
Paul R

Reputation: 212979

Probably the easiest thing to do is look at the Darwin sources and see how malloc works internally.

Upvotes: 2

Related Questions