History

Fix alloca on x86_64 windows

herman ten brugge committed 6 years ago

Commit 426d32a1 parent a0bc1492 files · +12 −3Browse files

Unified · Split

2 files
  1. lib/alloca86_64-bt.S +11 −2
  2. x86_64-gen.c +1 −1
lib/alloca86_64-bt.S+11−2
@@ -5,7 +5,6 @@ · 4 unmodified lines
55 __bound_alloca:
66
77 #ifdef _WIN32
8− # bound checking is not implemented
98 pop %rdx
109 mov %rcx,%rax
1110 add $15,%rax
@@ -23,8 +22,18 @@ p2: · 11 unmodified lines
2322
2423 sub %rax,%rsp
2524 mov %rsp,%rax
26− add $32,%rax
2725
26+ push %rdx
27+ push %rax
28+ mov %rcx,%rdx
29+ mov %rax,%rcx
30+ sub $20,%rsp
31+ call __bound_new_region
32+ add $20,%rsp
33+ pop %rax
34+ pop %rdx
35+
36+ add $32,%rax
2837 p3:
2938 push %rdx
3039 ret
x86_64-gen.c+1−1
@@ -1025,7 +1025,7 @@ void gfunc_call(int nb_args) · 1024 unmodified lines
10251025
10261026 if ((vtop->r & VT_SYM) && vtop->sym->v == TOK_alloca) {
10271027 /* need to add the "func_scratch" area after alloca */
1028− o(0x48); func_alloca = oad(0x05, func_alloca); /* sub $NN, %rax */
1028+ o(0x48); func_alloca = oad(0x2d, func_alloca); /* sub $NN, %rax */
10291029 }
10301030
10311031 /* other compilers don't clear the upper bits when returning char/short */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t