VirtualBox

source: vbox/trunk/src/recompiler/VBoxREMWrapperA.asm@ 3581

最後變更 在這個檔案從3581是 3581,由 vboxsync 提交於 17 年 前

Fixed incorrect/missing shadow space reservations in WrapGCC2MSC0Int, WrapGCC2MSC1Int and WrapGCC2MSC0Int. Added generic entry/exit logging option.

  • 屬性 svn:keywords 設為 Id
檔案大小: 14.1 KB
 
1; $Id: VBoxREMWrapperA.asm 3581 2007-07-12 13:41:39Z vboxsync $
2;; @file
3;
4; VBoxREM Wrapper, Assembly routines and wrapper Templates.
5;
6; innotek GmbH confidential
7;
8; Copyright (C) 2006-2007 innotek GmbH
9;
10; Author: knut st. osmundsen <[email protected]>
11;
12; All Rights Reserved
13;
14;
15
16
17
18
19;*******************************************************************************
20;* Header Files *
21;*******************************************************************************
22%include "iprt/asmdefs.mac"
23
24;%define ENTRY_LOGGING 1
25;%define EXIT_LOGGING 1
26
27
28%ifdef __AMD64__
29 ;;
30 ; 64-bit pushad
31 %macro MY_PUSHAQ 0
32 push rax
33 push rbx
34 push rcx
35 push rdx
36 push rsi
37 push rdi
38 push rbp
39 push r8
40 push r9
41 push r10
42 push r11
43 push r12
44 push r13
45 push r14
46 push r15
47 %endmacro
48
49 ;;
50 ; 64-bit popad
51 %macro MY_POPAQ 0
52 pop r15
53 pop r14
54 pop r13
55 pop r12
56 pop r11
57 pop r10
58 pop r9
59 pop r8
60 pop rbp
61 pop rdi
62 pop rsi
63 pop rdx
64 pop rcx
65 pop rbx
66 pop rax
67 %endmacro
68
69 ;;
70 ; Entry logging
71 %ifdef ENTRY_LOGGING
72 %macro LOG_ENTRY 0
73 MY_PUSHAQ
74 push rbp
75 mov rbp, rsp
76 and rsp, ~0fh
77 sub rsp, 20h ; shadow space
78
79 %ifdef __WIN__
80 mov rcx, 0xdead00010001dead
81 %else
82 mov rdi, 0xdead00010001dead
83 %endif
84 mov rax, 0xdead00020002dead
85 call rax
86
87 leave
88 MY_POPAQ
89 %endmacro
90 %else
91 %define LOG_ENTRY
92 %endif
93
94 ;;
95 ; Exit logging
96 %ifdef EXIT_LOGGING
97 %macro LOG_EXIT 0
98 MY_PUSHAQ
99 push rbp
100 mov rbp, rsp
101 and rsp, ~0fh
102 sub rsp, 20h ; shadow space
103
104 %ifdef __WIN__
105 mov rdx, rax
106 mov rcx, 0xdead00010001dead
107 %else
108 mov rsi, eax
109 mov rdi, 0xdead00010001dead
110 %endif
111 mov rax, 0xdead00030003dead
112 call rax
113
114 leave
115 MY_POPAQ
116 %endmacro
117 %else
118 %define LOG_EXIT
119 %endif
120
121%else
122 %define LOG_ENTRY
123 %define LOG_EXIT
124%endif
125
126
127BEGINCODE
128
129%ifdef __WIN__
130 %ifdef __AMD64__
131
132
133BEGINPROC WrapGCC2MSC0Int
134 LOG_ENTRY
135 push rbp
136 mov rbp, rsp
137 sub rsp, 20h
138
139%ifdef USE_DIRECT_CALLS
140 call $+5+0deadbeefh
141%else
142 mov rax, 0xdeadf00df00ddead
143 call rax
144%endif
145
146 leave
147 LOG_EXIT
148 ret
149ENDPROC WrapGCC2MSC0Int
150
151
152BEGINPROC WrapGCC2MSC1Int
153 LOG_ENTRY
154 push rbp
155 mov rbp, rsp
156 sub rsp, 20h
157
158 mov rcx, rdi
159%ifdef USE_DIRECT_CALLS
160 call $+5+0deadbeefh
161%else
162 mov rax, 0xdeadf00df00ddead
163 call rax
164%endif
165
166 leave
167 LOG_EXIT
168 ret
169ENDPROC WrapGCC2MSC1Int
170
171
172BEGINPROC WrapGCC2MSC2Int
173 LOG_ENTRY
174 push rbp
175 mov rbp, rsp
176 sub rsp, 20h
177
178 mov rdx, rsi
179 mov rcx, rdi
180%ifdef USE_DIRECT_CALLS
181 call $+5+0deadbeefh
182%else
183 mov rax, 0xdeadf00df00ddead
184 call rax
185%endif
186
187 leave
188 LOG_EXIT
189 ret
190ENDPROC WrapGCC2MSC2Int
191
192
193BEGINPROC WrapGCC2MSC3Int
194 LOG_ENTRY
195 push rbp
196 mov rbp, rsp
197 sub rsp, 20h
198
199 mov r8, rdx
200 mov rdx, rsi
201 mov rcx, rdi
202%ifdef USE_DIRECT_CALLS
203 call $+5+0deadbeefh
204%else
205 mov rax, 0xdeadf00df00ddead
206 call rax
207%endif
208
209 leave
210 LOG_EXIT
211 ret
212ENDPROC WrapGCC2MSC3Int
213
214
215BEGINPROC WrapGCC2MSC4Int
216 LOG_ENTRY
217 push rbp
218 mov rbp, rsp
219 sub rsp, 20h
220
221 mov r9, rcx
222 mov r8, rdx
223 mov rdx, rsi
224 mov rcx, rdi
225%ifdef USE_DIRECT_CALLS
226 call $+5+0deadbeefh
227%else
228 mov rax, 0xdeadf00df00ddead
229 call rax
230%endif
231
232 leave
233 LOG_EXIT
234 ret
235ENDPROC WrapGCC2MSC4Int
236
237
238BEGINPROC WrapGCC2MSC5Int
239 LOG_ENTRY
240 push rbp
241 mov rbp, rsp
242 sub rsp, 30h
243
244 mov [rsp + 20h], r8
245 mov r9, rcx
246 mov r8, rdx
247 mov rdx, rsi
248 mov rcx, rdi
249%ifdef USE_DIRECT_CALLS
250 call $+5+0deadbeefh
251%else
252 mov rax, 0xdeadf00df00ddead
253 call rax
254%endif
255
256 leave
257 LOG_EXIT
258 ret
259ENDPROC WrapGCC2MSC5Int
260
261
262BEGINPROC WrapGCC2MSC6Int
263 LOG_ENTRY
264 push rbp
265 mov rbp, rsp
266 sub rsp, 30h
267
268 mov [rsp + 28h], r9
269 mov [rsp + 20h], r8
270 mov r9, rcx
271 mov r8, rdx
272 mov rdx, rsi
273 mov rcx, rdi
274%ifdef USE_DIRECT_CALLS
275 call $+5+0deadbeefh
276%else
277 mov rax, 0xdeadf00df00ddead
278 call rax
279%endif
280
281 leave
282 LOG_EXIT
283 ret
284ENDPROC WrapGCC2MSC6Int
285
286
287BEGINPROC WrapGCC2MSC7Int
288 LOG_ENTRY
289 push rbp
290 mov rbp, rsp
291 sub rsp, 40h
292
293 mov r11, [ebp + 10h]
294 mov [rsp + 30h], r11
295 mov [rsp + 28h], r9
296 mov [rsp + 20h], r8
297 mov r9, rcx
298 mov r8, rdx
299 mov rdx, rsi
300 mov rcx, rdi
301%ifdef USE_DIRECT_CALLS
302 call $+5+0deadbeefh
303%else
304 mov rax, 0xdeadf00df00ddead
305 call rax
306%endif
307
308 leave
309 LOG_EXIT
310 ret
311ENDPROC WrapGCC2MSC7Int
312
313
314BEGINPROC WrapGCC2MSC8Int
315 LOG_ENTRY
316 push rbp
317 mov rbp, rsp
318 sub rsp, 40h
319
320 mov r10, [ebp + 18h]
321 mov [rsp + 38h], r10
322 mov r11, [ebp + 10h]
323 mov [rsp + 30h], r11
324 mov [rsp + 28h], r9
325 mov [rsp + 20h], r8
326 mov r9, rcx
327 mov r8, rdx
328 mov rdx, rsi
329 mov rcx, rdi
330%ifdef USE_DIRECT_CALLS
331 call $+5+0deadbeefh
332%else
333 mov rax, 0xdeadf00df00ddead
334 call rax
335%endif
336
337 leave
338 LOG_EXIT
339 ret
340ENDPROC WrapGCC2MSC8Int
341
342
343BEGINPROC WrapGCC2MSC9Int
344 LOG_ENTRY
345 push rbp
346 mov rbp, rsp
347 sub rsp, 50h
348
349 mov rax, [ebp + 20h]
350 mov [rsp + 40h], rax
351 mov r10, [ebp + 18h]
352 mov [rsp + 38h], r10
353 mov r11, [ebp + 10h]
354 mov [rsp + 30h], r11
355 mov [rsp + 28h], r9
356 mov [rsp + 20h], r8
357 mov r9, rcx
358 mov r8, rdx
359 mov rdx, rsi
360 mov rcx, rdi
361%ifdef USE_DIRECT_CALLS
362 call $+5+0deadbeefh
363%else
364 mov rax, 0xdeadf00df00ddead
365 call rax
366%endif
367
368 leave
369 LOG_EXIT
370 ret
371ENDPROC WrapGCC2MSC9Int
372
373
374BEGINPROC WrapGCC2MSC10Int
375 LOG_ENTRY
376 push rbp
377 mov rbp, rsp
378 sub rsp, 50h
379
380 mov r11, [ebp + 28h]
381 mov [rsp + 48h], r11
382 mov rax, [ebp + 20h]
383 mov [rsp + 40h], rax
384 mov r10, [ebp + 18h]
385 mov [rsp + 38h], r10
386 mov r11, [ebp + 10h]
387 mov [rsp + 30h], r11
388 mov [rsp + 28h], r9
389 mov [rsp + 20h], r8
390 mov r9, rcx
391 mov r8, rdx
392 mov rdx, rsi
393 mov rcx, rdi
394%ifdef USE_DIRECT_CALLS
395 call $+5+0deadbeefh
396%else
397 mov rax, 0xdeadf00df00ddead
398 call rax
399%endif
400
401 leave
402 LOG_EXIT
403 ret
404ENDPROC WrapGCC2MSC10Int
405
406
407BEGINPROC WrapGCC2MSC11Int
408 LOG_ENTRY
409 push rbp
410 mov rbp, rsp
411 sub rsp, 60h
412
413 mov r10, [ebp + 30h]
414 mov [rsp + 50h], r10
415 mov r11, [ebp + 28h]
416 mov [rsp + 48h], r11
417 mov rax, [ebp + 20h]
418 mov [rsp + 40h], rax
419 mov r10, [ebp + 18h]
420 mov [rsp + 38h], r10
421 mov r11, [ebp + 10h]
422 mov [rsp + 30h], r11
423 mov [rsp + 28h], r9
424 mov [rsp + 20h], r8
425 mov r9, rcx
426 mov r8, rdx
427 mov rdx, rsi
428 mov rcx, rdi
429%ifdef USE_DIRECT_CALLS
430 call $+5+0deadbeefh
431%else
432 mov rax, 0xdeadf00df00ddead
433 call rax
434%endif
435
436 leave
437 LOG_EXIT
438 ret
439ENDPROC WrapGCC2MSC11Int
440
441
442BEGINPROC WrapGCC2MSC12Int
443 LOG_ENTRY
444 push rbp
445 mov rbp, rsp
446 sub rsp, 60h
447
448 mov rax, [ebp + 28h]
449 mov [rsp + 48h], rax
450 mov r10, [ebp + 30h]
451 mov [rsp + 50h], r10
452 mov r11, [ebp + 28h]
453 mov [rsp + 48h], r11
454 mov rax, [ebp + 20h]
455 mov [rsp + 40h], rax
456 mov r10, [ebp + 18h]
457 mov [rsp + 38h], r10
458 mov r11, [ebp + 10h]
459 mov [rsp + 30h], r11
460 mov [rsp + 28h], r9
461 mov [rsp + 20h], r8
462 mov r9, rcx
463 mov r8, rdx
464 mov rdx, rsi
465 mov rcx, rdi
466%ifdef USE_DIRECT_CALLS
467 call $+5+0deadbeefh
468%else
469 mov rax, 0xdeadf00df00ddead
470 call rax
471%endif
472
473 leave
474 LOG_EXIT
475 ret
476ENDPROC WrapGCC2MSC12Int
477
478
479
480BEGINPROC WrapGCC2MSCVariadictInt
481 LOG_ENTRY
482%ifdef DEBUG
483 ; check that there are NO floting point arguments in XMM registers!
484 or rax, rax
485 jz .ok
486 int3
487.ok:
488%endif
489 sub rsp, 28h
490 mov r11, [rsp + 28h] ; r11 = return address.
491 mov [rsp + 28h], r9
492 mov [rsp + 20h], r8
493 mov r9, rcx
494 mov [rsp + 18h], r9 ; (*)
495 mov r8, rdx
496 mov [rsp + 14h], r8 ; (*)
497 mov rdx, rsi
498 mov [rsp + 8h], rdx ; (*)
499 mov rcx, rdi
500 mov [rsp], rcx ; (*)
501 mov rsi, r11 ; rsi is preserved by the callee.
502%ifdef USE_DIRECT_CALLS
503 call $+5+0deadbeefh
504%else
505 mov rax, 0xdeadf00df00ddead
506 call rax
507%endif
508
509 add rsp, 30h
510 LOG_EXIT
511 jmp rsi
512 ; (*) unconditionally spill the registers, just in case '...' implies weird stuff on MSC. Check this out!
513ENDPROC WrapGCC2MSCVariadictInt
514
515
516
517;
518; The other way around:
519;
520
521
522BEGINPROC WrapMSC2GCC0Int
523 LOG_ENTRY
524 push rbp
525 mov rbp, rsp
526 sub rsp, 10h
527 mov [ebp - 10h], rsi
528 mov [ebp - 18h], rdi
529
530%ifdef USE_DIRECT_CALLS
531 call $+5+0deadbeefh
532%else
533 mov rax, 0xdeadf00df00ddead
534 call rax
535%endif
536
537 mov rdi, [ebp - 18h]
538 mov rsi, [ebp - 10h]
539 leave
540 LOG_EXIT
541 ret
542ENDPROC WrapMSC2GCC0Int
543
544
545BEGINPROC WrapMSC2GCC1Int
546 LOG_ENTRY
547 push rbp
548 mov rbp, rsp
549 sub rsp, 20h
550 mov [ebp - 10h], rsi
551 mov [ebp - 18h], rdi
552
553 mov rdi, rcx
554%ifdef USE_DIRECT_CALLS
555 call $+5+0deadbeefh
556%else
557 mov rax, 0xdeadf00df00ddead
558 call rax
559%endif
560
561 mov rdi, [ebp - 18h]
562 mov rsi, [ebp - 10h]
563 leave
564 LOG_EXIT
565 ret
566ENDPROC WrapMSC2GCC1Int
567
568
569BEGINPROC WrapMSC2GCC2Int
570 LOG_ENTRY
571 push rbp
572 mov rbp, rsp
573 sub rsp, 20h
574 mov [ebp - 10h], rsi
575 mov [ebp - 18h], rdi
576
577 mov rdi, rcx
578 mov rsi, rdx
579%ifdef USE_DIRECT_CALLS
580 call $+5+0deadbeefh
581%else
582 mov rax, 0xdeadf00df00ddead
583 call rax
584%endif
585
586 mov rdi, [ebp - 18h]
587 mov rsi, [ebp - 10h]
588 leave
589 LOG_EXIT
590 ret
591ENDPROC WrapMSC2GCC2Int
592
593
594BEGINPROC WrapMSC2GCC3Int
595 LOG_ENTRY
596 push rbp
597 mov rbp, rsp
598 sub rsp, 20h
599 mov [ebp - 10h], rsi
600 mov [ebp - 18h], rdi
601
602 mov rdi, rcx
603 mov rsi, rdx
604 mov rdx, r8
605 call $+5+0deadbeefh
606
607 mov rdi, [ebp - 18h]
608 mov rsi, [ebp - 10h]
609 leave
610 LOG_EXIT
611 ret
612ENDPROC WrapMSC2GCC3Int
613
614
615BEGINPROC WrapMSC2GCC4Int
616 LOG_ENTRY
617 push rbp
618 mov rbp, rsp
619 sub rsp, 20h
620 mov [ebp - 10h], rsi
621 mov [ebp - 18h], rdi
622
623 mov rdi, rcx
624 mov rsi, rdx
625 mov rdx, r8
626 mov rcx, r9
627 call $+5+0deadbeefh
628
629 mov rdi, [ebp - 18h]
630 mov rsi, [ebp - 10h]
631 leave
632 LOG_EXIT
633 ret
634ENDPROC WrapMSC2GCC4Int
635
636
637BEGINPROC WrapMSC2GCC5Int
638 LOG_ENTRY
639 push rbp
640 mov rbp, rsp
641 sub rsp, 20h
642 mov [ebp - 10h], rsi
643 mov [ebp - 18h], rdi
644
645 mov rdi, rcx
646 mov rsi, rdx
647 mov rdx, r8
648 mov rcx, r9
649 mov r8, [ebp + 30h]
650 call $+5+0deadbeefh
651
652 mov rdi, [ebp - 18h]
653 mov rsi, [ebp - 10h]
654 leave
655 LOG_EXIT
656 ret
657ENDPROC WrapMSC2GCC5Int
658
659
660BEGINPROC WrapMSC2GCC6Int
661 LOG_ENTRY
662 push rbp
663 mov rbp, rsp
664 sub rsp, 20h
665 mov [ebp - 10h], rsi
666 mov [ebp - 18h], rdi
667
668 mov rdi, rcx
669 mov rsi, rdx
670 mov rdx, r8
671 mov rcx, r9
672 mov r8, [ebp + 30h]
673 mov r9, [ebp + 38h]
674 call $+5+0deadbeefh
675
676 mov rdi, [ebp - 18h]
677 mov rsi, [ebp - 10h]
678 leave
679 LOG_EXIT
680 ret
681ENDPROC WrapMSC2GCC6Int
682
683
684BEGINPROC WrapMSC2GCC7Int
685 LOG_ENTRY
686 push rbp
687 mov rbp, rsp
688 sub rsp, 30h
689 mov [ebp - 10h], rsi
690 mov [ebp - 18h], rdi
691
692 mov rdi, rcx
693 mov rsi, rdx
694 mov rdx, r8
695 mov rcx, r9
696 mov r8, [ebp + 30h]
697 mov r9, [ebp + 38h]
698 mov r10, [ebp + 40h]
699 mov [esp], r10
700 call $+5+0deadbeefh
701
702 mov rdi, [ebp - 18h]
703 mov rsi, [ebp - 10h]
704 leave
705 LOG_EXIT
706 ret
707ENDPROC WrapMSC2GCC7Int
708
709
710BEGINPROC WrapMSC2GCC8Int
711 LOG_ENTRY
712 push rbp
713 mov rbp, rsp
714 sub rsp, 30h
715 mov [ebp - 10h], rsi
716 mov [ebp - 18h], rdi
717
718 mov rdi, rcx
719 mov rsi, rdx
720 mov rdx, r8
721 mov rcx, r9
722 mov r8, [ebp + 30h]
723 mov r9, [ebp + 38h]
724 mov r10, [ebp + 40h]
725 mov [esp], r10
726 mov r11, [ebp + 48h]
727 mov [esp + 8], r11
728 call $+5+0deadbeefh
729
730 mov rdi, [ebp - 18h]
731 mov rsi, [ebp - 10h]
732 leave
733 LOG_EXIT
734 ret
735ENDPROC WrapMSC2GCC8Int
736
737
738BEGINPROC WrapMSC2GCC9Int
739 LOG_ENTRY
740 push rbp
741 mov rbp, rsp
742 sub rsp, 40h
743 mov [ebp - 10h], rsi
744 mov [ebp - 18h], rdi
745
746 mov rdi, rcx
747 mov rsi, rdx
748 mov rdx, r8
749 mov rcx, r9
750 mov r8, [ebp + 30h]
751 mov r9, [ebp + 38h]
752 mov r10, [ebp + 40h]
753 mov [esp], r10
754 mov r11, [ebp + 48h]
755 mov [esp + 8], r11
756 mov rax, [ebp + 50h]
757 mov [esp + 10h], rax
758 call $+5+0deadbeefh
759
760 mov rdi, [ebp - 18h]
761 mov rsi, [ebp - 10h]
762 leave
763 LOG_EXIT
764 ret
765ENDPROC WrapMSC2GCC9Int
766
767 %endif ; __AMD64__
768%endif ; __WIN__
769
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette