github.com/bytedance/mockey@v1.2.10/internal/monkey/mem/write_linux_arm64.s (about) 1 /* 2 * Copyright 2022 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "textflag.h" 18 19 #define NOP64 WORD $0x1f2003d5; WORD $0x1f2003d5; 20 #define NOP512 NOP64; NOP64; NOP64; NOP64; NOP64; NOP64; NOP64; NOP64; 21 #define NOP4096 NOP512; NOP512; NOP512; NOP512; NOP512; NOP512; NOP512; NOP512; 22 #define NOP16384 NOP4096; NOP4096; NOP4096; NOP4096; NOP4096; NOP4096; NOP4096; NOP4096; 23 24 #define protRW $(0x1|0x2) 25 #define mProtect $0xe2 26 27 TEXT ·write(SB),NOSPLIT,$24 28 B START 29 NOP16384 30 START: 31 MOVD mProtect, R8 32 MOVD page+24(FP), R0 33 MOVD pageSize+32(FP), R1 34 MOVD protRW, R2 35 SVC $0x00 36 CMP $0, R0 37 BEQ PROTECT_OK 38 B RETURN 39 PROTECT_OK: 40 MOVD target+0(FP), R0 41 MOVD data+8(FP), R1 42 MOVD len+16(FP), R2 43 MOVD R0, to-24(SP) 44 MOVD R1, from-16(SP) 45 MOVD R2, n-8(SP) 46 CALL runtime·memmove(SB) 47 MOVD mProtect, R8 48 MOVD page+24(FP), R0 49 MOVD pageSize+32(FP), R1 50 MOVD oriProt+40(FP), R2 51 SVC $0x00 52 B RETURN 53 NOP16384 54 RETURN: 55 MOVD R0, ret+48(FP) 56 RET