| 1 |
|
| /* |
| 2 |
|
| x86_64/amd64 not-threaded, |
| 3 |
|
| PL_op in %rax, &PL_op in %rbx, &PL_sig_pending in %rcx |
| 4 |
|
| |
| 5 |
|
| 55 push %rbp |
| 6 |
|
| 48 89 e5 mov %rsp,%rbp |
| 7 |
|
| 53 push %rbx |
| 8 |
|
| 51 push %rcx |
| 9 |
|
| 31 c0 xor %eax, %eax |
| 10 |
|
| 48 89 1d xx xx xx xx mov PL_op@GOTPCREL(%rip),%rbx |
| 11 |
|
| 48 89 1e xx xx xx xx mov PL_sig_pending@GOTPCREL(%rip),%rcx |
| 12 |
|
| |
| 13 |
|
| e8 xx xx xx xx call Perl_pp_enter@PLT |
| 14 |
|
| 48 98 cltq |
| 15 |
|
| 48 89 03 mov %rax,(%rbx) |
| 16 |
|
| |
| 17 |
|
| e8 xx xx xx xx call Perl_pp_nextstate@PLT |
| 18 |
|
| 48 98 cltq |
| 19 |
|
| 48 89 03 mov %rax,(%rbx) |
| 20 |
|
| |
| 21 |
|
| 48 83 ?? 00 cmpq $0x0,(%rcx) |
| 22 |
|
| 74 0a je +10 (L2) |
| 23 |
|
| 31 c0 xor %eax,%eax |
| 24 |
|
| e8 xx xx xx xx call Perl_despatch_signals@PLT |
| 25 |
|
| 31 c0 xor %eax,%eax |
| 26 |
|
| L2: |
| 27 |
|
| e8 xx xx xx xx call Perl_pp_print@PLT |
| 28 |
|
| 48 98 cltq |
| 29 |
|
| 48 89 03 mov %rax,(%rbx) |
| 30 |
|
| |
| 31 |
|
| e8 xx xx xx xx call Perl_pp_leave@PLT |
| 32 |
|
| 48 98 cltq |
| 33 |
|
| 48 89 03 mov %rax,(%rbx) |
| 34 |
|
| |
| 35 |
|
| 5? pop %rcx |
| 36 |
|
| 5b pop %rbx |
| 37 |
|
| c9 leaveq |
| 38 |
|
| c3 retq |
| 39 |
|
| |
| 40 |
|
| Dump of assembler code from 0x1127000 to 0x1127058: |
| 41 |
|
| 0x0000000001127000: push %rbp |
| 42 |
|
| 0x0000000001127001: mov %rsp,%rbp |
| 43 |
|
| 0x0000000001127004: sub $0x8,%rsp |
| 44 |
|
| 0x0000000001127008: push %rbx |
| 45 |
|
| 0x0000000001127009: mov -0x8963b0(%rip),%rbx # 0x890c60 <PL_op> |
| 46 |
|
| 0x0000000001127010: push %rcx |
| 47 |
|
| 0x0000000001127011: mov -0x8969f3(%rip),%ecx # 0x890624 <PL_sig_pending> |
| 48 |
|
| 0x0000000001127017: callq 0x4ce3f0 <Perl_pp_enter> |
| 49 |
|
| 0x000000000112701c: mov %eax,(%rbx) |
| 50 |
|
| 0x000000000112701e: callq 0x4d18a0 <Perl_pp_nextstate> |
| 51 |
|
| 0x0000000001127023: mov %eax,(%rbx) |
| 52 |
|
| 0x0000000001127025: callq 0x4d5e20 <Perl_pp_pushmark> |
| 53 |
|
| 0x000000000112702a: mov %eax,(%rbx) |
| 54 |
|
| 0x000000000112702c: callq 0x4cb010 <Perl_pp_const> |
| 55 |
|
| 0x0000000001127031: mov %eax,(%rbx) |
| 56 |
|
| 0x0000000001127033: callq 0x4da5f0 <Perl_pp_print> |
| 57 |
|
| 0x0000000001127038: mov %eax,(%rbx) |
| 58 |
|
| 0x000000000112703a: callq 0x4cfc90 <Perl_pp_leave> |
| 59 |
|
| 0x000000000112703f: mov %eax,(%rbx) |
| 60 |
|
| 0x0000000001127041: pop %rcx |
| 61 |
|
| 0x0000000001127042: pop %rbx |
| 62 |
|
| 0x0000000001127043: add $0x8,%rsp |
| 63 |
|
| 0x0000000001127047: leaveq |
| 64 |
|
| 0x0000000001127048: retq |
| 65 |
|
| |
| 66 |
|
| */ |
| 67 |
|
| |
| 68 |
|
| T_CHARARR amd64_prolog[] = { |
| 69 |
|
| enter_8 |
| 70 |
|
| #ifdef HAVE_DISPATCH |
| 71 |
|
| ,push_rcx /* volatile, but ok for &PL_sig_pending check */ |
| 72 |
|
| #endif |
| 73 |
|
| /*,push_r12*/ /* op->next */ |
| 74 |
|
| #ifdef HAVE_DISPATCH /* &PL_sig_pending */ |
| 75 |
|
| ,mov_mem_ecx, fourbyte |
| 76 |
|
| #endif |
| 77 |
|
| }; |
| 78 |
|
| |
| 79 |
0 |
| unsigned char *push_prolog(unsigned char *code) { |
| 80 |
0 |
| CODE prolog1[] = { |
| 81 |
|
| enter_8, |
| 82 |
|
| push_rbx |
| 83 |
|
| #ifdef HAVE_DISPATCH |
| 84 |
|
| ,push_rcx |
| 85 |
|
| #endif |
| 86 |
|
| /*,push_r12*/}; |
| 87 |
0 |
| PUSHc(prolog1); |
| 88 |
|
| #ifdef HAVE_DISPATCH |
| 89 |
|
| T_CHARARR prolog2[] = { |
| 90 |
|
| mov_mem_ecx}; |
| 91 |
|
| PUSHc(prolog2); |
| 92 |
|
| PUSHrel(&PL_sig_pending); |
| 93 |
|
| #endif |
| 94 |
0 |
| return code; |
| 95 |
|
| } |
| 96 |
|
| T_CHARARR amd64_epilog[] = { |
| 97 |
|
| /*pop_r12,*/ |
| 98 |
|
| #ifdef HAVE_DISPATCH |
| 99 |
|
| pop_rcx, |
| 100 |
|
| #endif |
| 101 |
|
| pop_rbx, |
| 102 |
|
| leave, |
| 103 |
|
| ret}; |
| 104 |
|
| |
| 105 |
|
| T_CHARARR amd64_call[] = { |
| 106 |
|
| /*0xb8,0x00,0x00,0x00,0x00,*/ /* mox $0,%eax */ |
| 107 |
|
| 0xe8}; /* callq PL_op->op_ppaddr@PLT */ |
| 108 |
|
| T_CHARARR amd64_jmp[] = {0xff,0x25}; /* jmp *$PL_op->op_ppaddr */ |
| 109 |
|
| T_CHARARR amd64_save_plop[] = { |
| 110 |
|
| /*mov_eax_rebx*/ /* fails on amd64 */ |
| 111 |
|
| mov_rax_memr /* mov %rax,memrel #save new PL_op */ |
| 112 |
|
| }; |
| 113 |
|
| T_CHARARR amd64_nop[] = {0x90}; /* pad */ |
| 114 |
|
| T_CHARARR amd64_nop2[] = {0x90,0x90}; /* jmp pad */ |
| 115 |
|
| T_CHARARR amd64_dispatch_getsig[] = { |
| 116 |
|
| mov_mem_rcx}; |
| 117 |
|
| T_CHARARR amd64_dispatch[] = { |
| 118 |
|
| test_ecx_ecx, |
| 119 |
|
| je(5)}; |
| 120 |
|
| |
| 121 |
|
| T_CHARARR maybranch_plop[] = { |
| 122 |
|
| /* r12 is not save during function calls, put it onto the local stack */ |
| 123 |
|
| mov_mem_rebp8, fourbyte |
| 124 |
|
| }; |
| 125 |
0 |
| unsigned char *push_maybranch_plop(unsigned char *code, OP* next) { |
| 126 |
0 |
| CODE maybranch_plop1[] = { |
| 127 |
|
| mov_mem_rebp8}; |
| 128 |
0 |
| PUSHc(maybranch_plop1); |
| 129 |
0 |
| PUSHrel(&next); |
| 130 |
0 |
| return code; |
| 131 |
|
| } |
| 132 |
|
| T_CHARARR maybranch_check[] = { |
| 133 |
|
| cmp_eax_rebp8, |
| 134 |
|
| je_0,fourbyte |
| 135 |
|
| }; |
| 136 |
|
| T_CHARARR maybranch_checkw[] = { |
| 137 |
|
| cmp_eax_rebp8, |
| 138 |
|
| jew_0,fourbyte |
| 139 |
|
| }; |
| 140 |
|
| unsigned char * |
| 141 |
0 |
| push_maybranch_check(unsigned char *code, int fw) { |
| 142 |
0 |
| CODE maybranch_check[] = { |
| 143 |
|
| cmp_eax_rebp8, /* saved prev op->next at -4(%esp) */ |
| 144 |
|
| je_0}; |
| 145 |
0 |
▶ | if (abs(fw) > 128) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (abs(fw) > 128) { |
0 |
0 |
0 |
|
| 146 |
0 |
| CODE maybranch_checkw[] = { |
| 147 |
|
| cmp_eax_rebp8, |
| 148 |
|
| jew_0}; |
| 149 |
0 |
| PUSHc(maybranch_checkw); |
| 150 |
0 |
| PUSHrel(fw); |
| 151 |
|
| } else { |
| 152 |
0 |
| PUSHc(maybranch_check); |
| 153 |
0 |
| PUSHbyte(fw); |
| 154 |
|
| } |
| 155 |
0 |
| return code; |
| 156 |
|
| } |
| 157 |
|
| |
| 158 |
|
| T_CHARARR gotorel[] = { |
| 159 |
|
| jmpq(0) |
| 160 |
|
| }; |
| 161 |
|
| unsigned char * |
| 162 |
0 |
| push_gotorel(unsigned char *code, U32 label) { |
| 163 |
0 |
| CODE gotorel[] = { |
| 164 |
|
| jmpq_0}; |
| 165 |
0 |
| PUSHc(gotorel); |
| 166 |
0 |
| PUSHabs(&label); |
| 167 |
0 |
| return code; |
| 168 |
|
| } |
| 169 |
|
| |
| 170 |
|
| # define PROLOG amd64_prolog |
| 171 |
|
| # define CALL amd64_call |
| 172 |
|
| # define JMP amd64_jmp |
| 173 |
|
| # define NOP amd64_nop |
| 174 |
|
| # define SAVE_PLOP amd64_save_plop |
| 175 |
|
| # define DISPATCH_GETSIG amd64_dispatch_getsig |
| 176 |
|
| # define DISPATCH amd64_dispatch |
| 177 |
|
| # define EPILOG amd64_epilog |
| 178 |
|
| # define MAYBRANCH_PLOP maybranch_plop |
| 179 |
|
| # define GOTOREL gotorel |
| 180 |
|
| |
| 181 |
|
| /* |
| 182 |
|
| * Local variables: |
| 183 |
|
| * c-basic-offset: 4 |
| 184 |
|
| * End: |
| 185 |
|
| * vim: expandtab shiftwidth=4: |
| 186 |
|
| */ |