github.com/AESNooper/go/src@v0.0.0-20220218095104-b56a4ab1bbbb/runtime/libfuzzer_amd64.s (about) 1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build libfuzzer 6 7 #include "go_asm.h" 8 #include "go_tls.h" 9 #include "textflag.h" 10 11 // Based on race_amd64.s; see commentary there. 12 13 #ifdef GOOS_windows 14 #define RARG0 CX 15 #define RARG1 DX 16 #else 17 #define RARG0 DI 18 #define RARG1 SI 19 #endif 20 21 // void runtime·libfuzzerCall(fn, arg0, arg1 uintptr) 22 // Calls C function fn from libFuzzer and passes 2 arguments to it. 23 TEXT runtime·libfuzzerCall(SB), NOSPLIT, $0-24 24 MOVQ fn+0(FP), AX 25 MOVQ arg0+8(FP), RARG0 26 MOVQ arg1+16(FP), RARG1 27 28 get_tls(R12) 29 MOVQ g(R12), R14 30 MOVQ g_m(R14), R13 31 32 // Switch to g0 stack. 33 MOVQ SP, R12 // callee-saved, preserved across the CALL 34 MOVQ m_g0(R13), R10 35 CMPQ R10, R14 36 JE call // already on g0 37 MOVQ (g_sched+gobuf_sp)(R10), SP 38 call: 39 ANDQ $~15, SP // alignment for gcc ABI 40 CALL AX 41 MOVQ R12, SP 42 RET