Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6429 | siemargl | 1 | /* ---------------------------------------------- */ |
2 | /* alloca86_64.S */ |
||
3 | |||
4 | .globl __bound_alloca |
||
5 | __bound_alloca: |
||
6 | |||
7 | #ifdef TCC_TARGET_PE |
||
8 | # bound checking is not implemented |
||
9 | pop %rdx |
||
10 | mov %rcx,%rax |
||
11 | add $15,%rax |
||
12 | and $-16,%rax |
||
13 | jz p3 |
||
14 | |||
15 | p1: |
||
16 | cmp $4096,%rax |
||
17 | jbe p2 |
||
18 | test %rax,-4096(%rsp) |
||
19 | sub $4096,%rsp |
||
20 | sub $4096,%rax |
||
21 | jmp p1 |
||
22 | p2: |
||
23 | |||
24 | sub %rax,%rsp |
||
25 | mov %rsp,%rax |
||
26 | add $32,%rax |
||
27 | |||
28 | p3: |
||
29 | push %rdx |
||
30 | ret |
||
31 | #else |
||
32 | pop %rdx |
||
33 | mov %rdi,%rax |
||
34 | movl %rax,%rsi # size, a second parm to the __bound_new_region |
||
35 | |||
36 | add $15,%rax |
||
37 | and $-16,%rax |
||
38 | jz p3 |
||
39 | |||
40 | |||
41 | sub %rax,%rsp |
||
42 | mov %rsp,%rdi # pointer, a first parm to the __bound_new_region |
||
43 | mov %rsp,%rax |
||
44 | |||
45 | push %rdx |
||
46 | push %rax |
||
47 | call __bound_new_region |
||
48 | pop %rax |
||
49 | pop %rdx |
||
50 | |||
51 | p3: |
||
52 | push %rdx |
||
53 | ret |
||
54 | #endif |
||
55 | |||
56 | /* mark stack as nonexecutable */ |
||
57 | #if defined __ELF__ && defined __linux__ |
||
58 | .section .note.GNU-stack,"",@progbits |
||
59 | #endif |
||
60 | /* ---------------------------------------------- */ |