On 13 May 2014, at 07:06, Alexander Burger <[email protected]> wrote:
>
> Basically you are implementing you own malloc(), which is still far away
> from a single-instruction push, pop or stack arithmetic.
Am I missing something? alloca() just adds an offset to the stack pointer:
#include <stdlib.h>
extern void foo(void *);
void test() {
foo(alloca(100));
}
bash-3.2$ cc -fomit-frame-pointer -fno-stack-protector -c -O3 test.c
bash-3.2$ otool -tV test.o
test.o:
(__TEXT,__text) section
_test:
0000000000000000 subq $0x68, %rsp
0000000000000004 leaq 0x4(%rsp), %rdi
0000000000000009 callq _foo
000000000000000e addq $0x68, %rsp
0000000000000012 ret
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe