Rev 1693 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1693 | Rev 1906 | ||
---|---|---|---|
1 | .global ___chkstk |
1 | .global ___chkstk |
2 | .global __alloca |
2 | .global __alloca |
3 | 3 | ||
4 | .section .text |
4 | .section .text |
5 | 5 | ||
6 | .align 4 |
- | |
7 | ___chkstk: |
6 | ___chkstk: |
8 | __alloca: |
7 | __alloca: |
9 | pushl %ecx /* save temp */ |
8 | pushl %ecx /* save temp */ |
10 | leal 8(%esp), %ecx /* point past return addr */ |
9 | leal 8(%esp), %ecx /* point past return addr */ |
11 | subl %eax, %ecx |
10 | subl %eax, %ecx |
12 | cmpl %fs:4, %ecx # check low stack limit |
11 | cmpl %fs:4, %ecx # check low stack limit |
13 | jb 1f |
12 | jb 1f |
14 | 13 | ||
15 | movl %esp, %eax /* save old stack pointer */ |
14 | movl %esp, %eax /* save old stack pointer */ |
16 | movl %ecx, %esp /* decrement stack */ |
15 | movl %ecx, %esp /* decrement stack */ |
17 | movl (%eax), %ecx /* recover saved temp */ |
16 | movl (%eax), %ecx /* recover saved temp */ |
18 | movl 4(%eax), %eax /* recover return address */ |
17 | movl 4(%eax), %eax /* recover return address */ |
19 | 18 | ||
20 | /* Push the return value back. Doing this instead of just |
19 | /* Push the return value back. Doing this instead of just |
21 | jumping to %eax preserves the cached call-return stack |
20 | jumping to %eax preserves the cached call-return stack |
22 | used by most modern processors. */ |
21 | used by most modern processors. */ |
23 | pushl %eax |
22 | pushl %eax |
24 | ret |
23 | ret |
25 | 1: |
24 | 1: |
26 | int3 #trap to debugger |
25 | int3 #trap to debugger |
27 | .ascii "Stack overflow" |
26 | .ascii "Stack overflow" |
28 | 27 | ||
- | 28 |