src/runtime/sys_linux_amd64.s 772 lines View on github.com → Search inside
1// Copyright 2009 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.45//6// System calls and other sys.stuff for AMD64, Linux7//89#include "go_asm.h"10#include "go_tls.h"11#include "textflag.h"12#include "cgo/abi_amd64.h"1314#define AT_FDCWD -1001516#define SYS_read		017#define SYS_write		118#define SYS_close		319#define SYS_mmap		920#define SYS_munmap		1121#define SYS_brk 		1222#define SYS_rt_sigaction	1323#define SYS_rt_sigprocmask	1424#define SYS_rt_sigreturn	1525#define SYS_sched_yield 	2426#define SYS_mincore		2727#define SYS_madvise		2828#define SYS_nanosleep		3529#define SYS_setittimer		3830#define SYS_getpid		3931#define SYS_socket		4132#define SYS_connect		4233#define SYS_clone		5634#define SYS_exit		6035#define SYS_kill		6236#define SYS_sigaltstack 	13137#define SYS_arch_prctl		15838#define SYS_gettid		18639#define SYS_futex		20240#define SYS_sched_getaffinity	20441#define SYS_timer_create	22242#define SYS_timer_settime	22343#define SYS_timer_delete	22644#define SYS_clock_gettime	22845#define SYS_exit_group		23146#define SYS_tgkill		23447#define SYS_openat		25748#define SYS_faccessat		26949#define SYS_pipe2		2935051TEXT runtime·exit(SB),NOSPLIT,$0-452	MOVL	code+0(FP), DI53	MOVL	$SYS_exit_group, AX54	SYSCALL55	RET5657// func exitThread(wait *atomic.Uint32)58TEXT runtime·exitThread(SB),NOSPLIT,$0-859	MOVQ	wait+0(FP), AX60	// We're done using the stack.61	MOVL	$0, (AX)62	MOVL	$0, DI	// exit code63	MOVL	$SYS_exit, AX64	SYSCALL65	// We may not even have a stack any more.66	INT	$367	JMP	0(PC)6869TEXT runtime·open(SB),NOSPLIT,$0-2070	// This uses openat instead of open, because Android O blocks open.71	MOVL	$AT_FDCWD, DI // AT_FDCWD, so this acts like open72	MOVQ	name+0(FP), SI73	MOVL	mode+8(FP), DX74	MOVL	perm+12(FP), R1075	MOVL	$SYS_openat, AX76	SYSCALL77	CMPQ	AX, $0xfffffffffffff00178	JLS	2(PC)79	MOVL	$-1, AX80	MOVL	AX, ret+16(FP)81	RET8283TEXT runtime·closefd(SB),NOSPLIT,$0-1284	MOVL	fd+0(FP), DI85	MOVL	$SYS_close, AX86	SYSCALL87	CMPQ	AX, $0xfffffffffffff00188	JLS	2(PC)89	MOVL	$-1, AX90	MOVL	AX, ret+8(FP)91	RET9293TEXT runtime·write1(SB),NOSPLIT,$0-2894	MOVQ	fd+0(FP), DI95	MOVQ	p+8(FP), SI96	MOVL	n+16(FP), DX97	MOVL	$SYS_write, AX98	SYSCALL99	MOVL	AX, ret+24(FP)100	RET101102TEXT runtime·read(SB),NOSPLIT,$0-28103	MOVL	fd+0(FP), DI104	MOVQ	p+8(FP), SI105	MOVL	n+16(FP), DX106	MOVL	$SYS_read, AX107	SYSCALL108	MOVL	AX, ret+24(FP)109	RET110111// func pipe2(flags int32) (r, w int32, errno int32)112TEXT runtime·pipe2(SB),NOSPLIT,$0-20113	LEAQ	r+8(FP), DI114	MOVL	flags+0(FP), SI115	MOVL	$SYS_pipe2, AX116	SYSCALL117	MOVL	AX, errno+16(FP)118	RET119120TEXT runtime·usleep(SB),NOSPLIT,$16121	MOVL	$0, DX122	MOVL	usec+0(FP), AX123	MOVL	$1000000, CX124	DIVL	CX125	MOVQ	AX, 0(SP)126	MOVL	$1000, AX	// usec to nsec127	MULL	DX128	MOVQ	AX, 8(SP)129130	// nanosleep(&ts, 0)131	MOVQ	SP, DI132	MOVL	$0, SI133	MOVL	$SYS_nanosleep, AX134	SYSCALL135	RET136137TEXT runtime·gettid(SB),NOSPLIT,$0-4138	MOVL	$SYS_gettid, AX139	SYSCALL140	MOVL	AX, ret+0(FP)141	RET142143TEXT runtime·raise(SB),NOSPLIT,$0144	MOVL	$SYS_getpid, AX145	SYSCALL146	MOVL	AX, R12147	MOVL	$SYS_gettid, AX148	SYSCALL149	MOVL	AX, SI	// arg 2 tid150	MOVL	R12, DI	// arg 1 pid151	MOVL	sig+0(FP), DX	// arg 3152	MOVL	$SYS_tgkill, AX153	SYSCALL154	RET155156TEXT runtime·raiseproc(SB),NOSPLIT,$0157	MOVL	$SYS_getpid, AX158	SYSCALL159	MOVL	AX, DI	// arg 1 pid160	MOVL	sig+0(FP), SI	// arg 2161	MOVL	$SYS_kill, AX162	SYSCALL163	RET164165TEXT ·getpid(SB),NOSPLIT,$0-8166	MOVL	$SYS_getpid, AX167	SYSCALL168	MOVQ	AX, ret+0(FP)169	RET170171TEXT ·tgkill(SB),NOSPLIT,$0172	MOVQ	tgid+0(FP), DI173	MOVQ	tid+8(FP), SI174	MOVQ	sig+16(FP), DX175	MOVL	$SYS_tgkill, AX176	SYSCALL177	RET178179TEXT runtime·setitimer(SB),NOSPLIT,$0-24180	MOVL	mode+0(FP), DI181	MOVQ	new+8(FP), SI182	MOVQ	old+16(FP), DX183	MOVL	$SYS_setittimer, AX184	SYSCALL185	RET186187TEXT runtime·timer_create(SB),NOSPLIT,$0-28188	MOVL	clockid+0(FP), DI189	MOVQ	sevp+8(FP), SI190	MOVQ	timerid+16(FP), DX191	MOVL	$SYS_timer_create, AX192	SYSCALL193	MOVL	AX, ret+24(FP)194	RET195196TEXT runtime·timer_settime(SB),NOSPLIT,$0-28197	MOVL	timerid+0(FP), DI198	MOVL	flags+4(FP), SI199	MOVQ	new+8(FP), DX200	MOVQ	old+16(FP), R10201	MOVL	$SYS_timer_settime, AX202	SYSCALL203	MOVL	AX, ret+24(FP)204	RET205206TEXT runtime·timer_delete(SB),NOSPLIT,$0-12207	MOVL	timerid+0(FP), DI208	MOVL	$SYS_timer_delete, AX209	SYSCALL210	MOVL	AX, ret+8(FP)211	RET212213TEXT runtime·mincore(SB),NOSPLIT,$0-28214	MOVQ	addr+0(FP), DI215	MOVQ	n+8(FP), SI216	MOVQ	dst+16(FP), DX217	MOVL	$SYS_mincore, AX218	SYSCALL219	MOVL	AX, ret+24(FP)220	RET221222// func nanotime1() int64223TEXT runtime·nanotime1(SB),NOSPLIT,$16-8224	// We don't know how much stack space the VDSO code will need,225	// so switch to g0.226	// In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n227	// and hardening can use a full page of stack space in gettime_sym228	// due to stack probes inserted to avoid stack/heap collisions.229	// See issue #20427.230231#ifdef GOEXPERIMENT_runtimesecret232	// The kernel might spill our secrets onto g0233	// erase our registers here.234	// TODO(dmo): what is the ABI guarantee here? we use235	// R14 later, but the function is ABI0236	CMPL	g_secret(R14), $0237	JEQ	nosecret238	CALL	·secretEraseRegisters(SB)239240nosecret:241#endif242243	MOVQ	SP, R12	// Save old SP; R12 unchanged by C code.244245	MOVQ	g_m(R14), BX // BX unchanged by C code.246247	// Set vdsoPC and vdsoSP for SIGPROF traceback.248	// Save the old values on stack and restore them on exit,249	// so this function is reentrant.250	MOVQ	m_vdsoPC(BX), CX251	MOVQ	m_vdsoSP(BX), DX252	MOVQ	CX, 0(SP)253	MOVQ	DX, 8(SP)254255	LEAQ	ret+0(FP), DX256	MOVQ	-8(DX), CX257	MOVQ	CX, m_vdsoPC(BX)258	MOVQ	DX, m_vdsoSP(BX)259260	CMPQ	R14, m_curg(BX)	// Only switch if on curg.261	JNE	noswitch262263	MOVQ	m_g0(BX), DX264	MOVQ	(g_sched+gobuf_sp)(DX), SP	// Set SP to g0 stack265266noswitch:267	SUBQ	$16, SP		// Space for results268	ANDQ	$~15, SP	// Align for C code269270	MOVL	$1, DI // CLOCK_MONOTONIC271	LEAQ	0(SP), SI272	MOVQ	runtime·vdsoClockgettimeSym(SB), AX273	CMPQ	AX, $0274	JEQ	fallback275	CALL	AX276ret:277	MOVQ	0(SP), AX	// sec278	MOVQ	8(SP), DX	// nsec279	MOVQ	R12, SP		// Restore real SP280	// Restore vdsoPC, vdsoSP281	// We don't worry about being signaled between the two stores.282	// If we are not in a signal handler, we'll restore vdsoSP to 0,283	// and no one will care about vdsoPC. If we are in a signal handler,284	// we cannot receive another signal.285	MOVQ	8(SP), CX286	MOVQ	CX, m_vdsoSP(BX)287	MOVQ	0(SP), CX288	MOVQ	CX, m_vdsoPC(BX)289	// sec is in AX, nsec in DX290	// return nsec in AX291	IMULQ	$1000000000, AX292	ADDQ	DX, AX293	MOVQ	AX, ret+0(FP)294	RET295fallback:296	MOVQ	$SYS_clock_gettime, AX297	SYSCALL298	JMP	ret299300TEXT runtime·rtsigprocmask(SB),NOSPLIT,$0-28301	MOVL	how+0(FP), DI302	MOVQ	new+8(FP), SI303	MOVQ	old+16(FP), DX304	MOVL	size+24(FP), R10305	MOVL	$SYS_rt_sigprocmask, AX306	SYSCALL307	CMPQ	AX, $0xfffffffffffff001308	JLS	2(PC)309	MOVL	$0xf1, 0xf1  // crash310	RET311312TEXT runtime·rt_sigaction(SB),NOSPLIT,$0-36313	MOVQ	sig+0(FP), DI314	MOVQ	new+8(FP), SI315	MOVQ	old+16(FP), DX316	MOVQ	size+24(FP), R10317	MOVL	$SYS_rt_sigaction, AX318	SYSCALL319	MOVL	AX, ret+32(FP)320	RET321322// Call the function stored in _cgo_sigaction using the GCC calling convention.323TEXT runtime·callCgoSigaction(SB),NOSPLIT,$16324	MOVQ	sig+0(FP), DI325	MOVQ	new+8(FP), SI326	MOVQ	old+16(FP), DX327	MOVQ	_cgo_sigaction(SB), AX328	MOVQ	SP, BX	// callee-saved329	ANDQ	$~15, SP	// alignment as per amd64 psABI330	CALL	AX331	MOVQ	BX, SP332	MOVL	AX, ret+24(FP)333	RET334335TEXT runtime·sigfwd(SB),NOSPLIT,$0-32336	MOVQ	fn+0(FP),    AX337	MOVL	sig+8(FP),   DI338	MOVQ	info+16(FP), SI339	MOVQ	ctx+24(FP),  DX340	MOVQ	SP, BX		// callee-saved341	ANDQ	$~15, SP     // alignment for x86_64 ABI342	CALL	AX343	MOVQ	BX, SP344	RET345346// Called using C ABI.347TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0348	// Transition from C ABI to Go ABI.349	PUSH_REGS_HOST_TO_ABI0()350351	// Set up ABIInternal environment: g in R14, cleared X15.352	get_tls(R12)353	MOVQ	g(R12), R14354	PXOR	X15, X15355#ifndef GOAMD64_v3356#ifndef GOAMD64_v4357	CMPB	internalcpu·X86+const_offsetX86HasAVX(SB), $1358	JNE	2(PC)359#endif360#endif361	VXORPS	X15, X15, X15362363	// Reserve space for spill slots.364	NOP	SP		// disable vet stack checking365	ADJSP   $24366367	// Call into the Go signal handler368	MOVQ	DI, AX	// sig369	MOVQ	SI, BX	// info370	MOVQ	DX, CX	// ctx371	CALL	·sigtrampgo<ABIInternal>(SB)372373	ADJSP	$-24374375	POP_REGS_HOST_TO_ABI0()376	RET377378// Called using C ABI.379TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT|NOFRAME,$0380	// Transition from C ABI to Go ABI.381	PUSH_REGS_HOST_TO_ABI0()382383	// Set up ABIInternal environment: g in R14, cleared X15.384	get_tls(R12)385	MOVQ	g(R12), R14386	PXOR	X15, X15387#ifndef GOAMD64_v3388#ifndef GOAMD64_v4389	CMPB	internalcpu·X86+const_offsetX86HasAVX(SB), $1390	JNE	2(PC)391#endif392#endif393	VXORPS	X15, X15, X15394395	// Reserve space for spill slots.396	NOP	SP		// disable vet stack checking397	ADJSP   $24398399	// Call into the Go signal handler400	MOVQ	DI, AX	// sig401	MOVQ	SI, BX	// info402	MOVQ	DX, CX	// ctx403	CALL	·sigprofNonGo<ABIInternal>(SB)404405	ADJSP	$-24406407	POP_REGS_HOST_TO_ABI0()408	RET409410// Used instead of sigtramp in programs that use cgo.411// Arguments from kernel are in DI, SI, DX.412TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0413	// If no traceback function, do usual sigtramp.414	MOVQ	runtime·cgoTraceback(SB), AX415	TESTQ	AX, AX416	JZ	sigtramp417418	// If no traceback support function, which means that419	// runtime/cgo was not linked in, do usual sigtramp.420	MOVQ	_cgo_callers(SB), AX421	TESTQ	AX, AX422	JZ	sigtramp423424	// Figure out if we are currently in a cgo call.425	// If not, just do usual sigtramp.426	get_tls(CX)427	MOVQ	g(CX),AX428	TESTQ	AX, AX429	JZ	sigtrampnog     // g == nil430	MOVQ	g_m(AX), AX431	TESTQ	AX, AX432	JZ	sigtramp        // g.m == nil433	MOVL	m_ncgo(AX), CX434	TESTL	CX, CX435	JZ	sigtramp        // g.m.ncgo == 0436	MOVQ	m_curg(AX), CX437	TESTQ	CX, CX438	JZ	sigtramp        // g.m.curg == nil439	MOVQ	g_syscallsp(CX), CX440	TESTQ	CX, CX441	JZ	sigtramp        // g.m.curg.syscallsp == 0442	MOVQ	m_cgoCallers(AX), R8443	TESTQ	R8, R8444	JZ	sigtramp        // g.m.cgoCallers == nil445	MOVL	m_cgoCallersUse(AX), CX446	TESTL	CX, CX447	JNZ	sigtramp	// g.m.cgoCallersUse != 0448449	// Jump to a function in runtime/cgo.450	// That function, written in C, will call the user's traceback451	// function with proper unwind info, and will then call back here.452	// The first three arguments, and the fifth, are already in registers.453	// Set the two remaining arguments now.454	MOVQ	runtime·cgoTraceback(SB), CX455	MOVQ	$runtime·sigtramp(SB), R9456	MOVQ	_cgo_callers(SB), AX457	JMP	AX458459sigtramp:460	JMP	runtime·sigtramp(SB)461462sigtrampnog:463	// Signal arrived on a non-Go thread. If this is SIGPROF, get a464	// stack trace.465	CMPL	DI, $27 // 27 == SIGPROF466	JNZ	sigtramp467468	// Lock sigprofCallersUse.469	MOVL	$0, AX470	MOVL	$1, CX471	MOVQ	$runtime·sigprofCallersUse(SB), R11472	LOCK473	CMPXCHGL	CX, 0(R11)474	JNZ	sigtramp  // Skip stack trace if already locked.475476	// Jump to the traceback function in runtime/cgo.477	// It will call back to sigprofNonGo, via sigprofNonGoWrapper, to convert478	// the arguments to the Go calling convention.479	// First three arguments to traceback function are in registers already.480	MOVQ	runtime·cgoTraceback(SB), CX481	MOVQ	$runtime·sigprofCallers(SB), R8482	MOVQ	$runtime·sigprofNonGoWrapper<>(SB), R9483	MOVQ	_cgo_callers(SB), AX484	JMP	AX485486// For cgo unwinding to work, this function must look precisely like487// the one in glibc. The glibc source code is:488// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c;h=afdce87381228f0cf32fa9fa6c8c4efa5179065c#l80489// The code that cares about the precise instructions used is:490// https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/i386/linux-unwind.h;h=5486223d60272c73d5103b29ae592d2ee998e1cf#l49491//492// For gdb unwinding to work, this function must look precisely like the one in493// glibc and must be named "__restore_rt" or contain the string "sigaction" in494// the name. The gdb source code is:495// https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/amd64-linux-tdep.c;h=cbbac1a0c64e1deb8181b9d0ff6404e328e2979d#l178496TEXT runtime·sigreturn__sigaction(SB),NOSPLIT,$0497	// The 7-byte sign-extended "48 c7 c0 0f 00 00 00" form of498	// "MOVQ $SYS_rt_sigreturn, AX" is required: gdb and libgcc match499	// these exact bytes to recognize the signal trampoline. The Go500	// assembler now emits the 5-byte zero-extended "b8 0f 00 00 00"501	// form for positive imm32, so write the bytes by hand.502	BYTE $0x48; BYTE $0xc7; BYTE $0xc0503	BYTE $0x0f; BYTE $0x00; BYTE $0x00; BYTE $0x00504	SYSCALL505	INT $3	// not reached506507TEXT runtime·sysMmap(SB),NOSPLIT,$0508	MOVQ	addr+0(FP), DI509	MOVQ	n+8(FP), SI510	MOVL	prot+16(FP), DX511	MOVL	flags+20(FP), R10512	MOVL	fd+24(FP), R8513	MOVL	off+28(FP), R9514515	MOVL	$SYS_mmap, AX516	SYSCALL517	CMPQ	AX, $0xfffffffffffff001518	JLS	ok519	NOTQ	AX520	INCQ	AX521	MOVQ	$0, p+32(FP)522	MOVQ	AX, err+40(FP)523	RET524ok:525	MOVQ	AX, p+32(FP)526	MOVQ	$0, err+40(FP)527	RET528529// Call the function stored in _cgo_mmap using the GCC calling convention.530// This must be called on the system stack.531TEXT runtime·callCgoMmap(SB),NOSPLIT,$16532	MOVQ	addr+0(FP), DI533	MOVQ	n+8(FP), SI534	MOVL	prot+16(FP), DX535	MOVL	flags+20(FP), CX536	MOVL	fd+24(FP), R8537	MOVL	off+28(FP), R9538	MOVQ	_cgo_mmap(SB), AX539	MOVQ	SP, BX540	ANDQ	$~15, SP	// alignment as per amd64 psABI541	MOVQ	BX, 0(SP)542	CALL	AX543	MOVQ	0(SP), SP544	MOVQ	AX, ret+32(FP)545	RET546547TEXT runtime·sysMunmap(SB),NOSPLIT,$0548	MOVQ	addr+0(FP), DI549	MOVQ	n+8(FP), SI550	MOVQ	$SYS_munmap, AX551	SYSCALL552	CMPQ	AX, $0xfffffffffffff001553	JLS	2(PC)554	MOVL	$0xf1, 0xf1  // crash555	RET556557// Call the function stored in _cgo_munmap using the GCC calling convention.558// This must be called on the system stack.559TEXT runtime·callCgoMunmap(SB),NOSPLIT,$16-16560	MOVQ	addr+0(FP), DI561	MOVQ	n+8(FP), SI562	MOVQ	_cgo_munmap(SB), AX563	MOVQ	SP, BX564	ANDQ	$~15, SP	// alignment as per amd64 psABI565	MOVQ	BX, 0(SP)566	CALL	AX567	MOVQ	0(SP), SP568	RET569570TEXT runtime·madvise(SB),NOSPLIT,$0571	MOVQ	addr+0(FP), DI572	MOVQ	n+8(FP), SI573	MOVL	flags+16(FP), DX574	MOVQ	$SYS_madvise, AX575	SYSCALL576	MOVL	AX, ret+24(FP)577	RET578579// int64 futex(int32 *uaddr, int32 op, int32 val,580//	struct timespec *timeout, int32 *uaddr2, int32 val2);581TEXT runtime·futex(SB),NOSPLIT,$0582	MOVQ	addr+0(FP), DI583	MOVL	op+8(FP), SI584	MOVL	val+12(FP), DX585	MOVQ	ts+16(FP), R10586	MOVQ	addr2+24(FP), R8587	MOVL	val3+32(FP), R9588	MOVL	$SYS_futex, AX589	SYSCALL590	MOVL	AX, ret+40(FP)591	RET592593// int32 clone(int32 flags, void *stk, M *mp, G *gp, void (*fn)(void));594TEXT runtime·clone(SB),NOSPLIT|NOFRAME,$0595	MOVL	flags+0(FP), DI596	MOVQ	stk+8(FP), SI597	MOVQ	$0, DX598	MOVQ	$0, R10599	MOVQ    $0, R8600	// Copy mp, gp, fn off parent stack for use by child.601	// Careful: Linux system call clobbers CX and R11.602	MOVQ	mp+16(FP), R13603	MOVQ	gp+24(FP), R9604	MOVQ	fn+32(FP), R12605	CMPQ	R13, $0    // m606	JEQ	nog1607	CMPQ	R9, $0    // g608	JEQ	nog1609	LEAQ	m_tls(R13), R8610#ifdef GOOS_android611	// Android stores the TLS offset in runtime·tls_g.612	SUBQ	runtime·tls_g(SB), R8613#else614	ADDQ	$8, R8	// ELF wants to use -8(FS)615#endif616	ORQ 	$0x00080000, DI //add flag CLONE_SETTLS(0x00080000) to call clone617nog1:618	MOVL	$SYS_clone, AX619	SYSCALL620621	// In parent, return.622	CMPQ	AX, $0623	JEQ	3(PC)624	MOVL	AX, ret+40(FP)625	RET626627	// In child, on new stack.628	MOVQ	SI, SP629630	// If g or m are nil, skip Go-related setup.631	CMPQ	R13, $0    // m632	JEQ	nog2633	CMPQ	R9, $0    // g634	JEQ	nog2635636	// Initialize m->procid to Linux tid637	MOVL	$SYS_gettid, AX638	SYSCALL639	MOVQ	AX, m_procid(R13)640641	// In child, set up new stack642	get_tls(CX)643	MOVQ	R13, g_m(R9)644	MOVQ	R9, g(CX)645	MOVQ	R9, R14 // set g register646	CALL	runtime·stackcheck(SB)647648nog2:649	// Call fn. This is the PC of an ABI0 function.650	CALL	R12651652	// It shouldn't return. If it does, exit that thread.653	MOVL	$111, DI654	MOVL	$SYS_exit, AX655	SYSCALL656	JMP	-3(PC)	// keep exiting657658TEXT runtime·sigaltstack(SB),NOSPLIT,$0659	MOVQ	new+0(FP), DI660	MOVQ	old+8(FP), SI661	MOVQ	$SYS_sigaltstack, AX662	SYSCALL663	CMPQ	AX, $0xfffffffffffff001664	JLS	2(PC)665	MOVL	$0xf1, 0xf1  // crash666	RET667668// set tls base to DI669TEXT runtime·settls(SB),NOSPLIT,$32670#ifdef GOOS_android671	// Android stores the TLS offset in runtime·tls_g.672	SUBQ	runtime·tls_g(SB), DI673#else674	ADDQ	$8, DI	// ELF wants to use -8(FS)675#endif676	MOVQ	DI, SI677	MOVQ	$0x1002, DI	// ARCH_SET_FS678	MOVQ	$SYS_arch_prctl, AX679	SYSCALL680	CMPQ	AX, $0xfffffffffffff001681	JLS	2(PC)682	MOVL	$0xf1, 0xf1  // crash683	RET684685TEXT runtime·osyield(SB),NOSPLIT,$0686	MOVL	$SYS_sched_yield, AX687	SYSCALL688	RET689690TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0691	MOVQ	pid+0(FP), DI692	MOVQ	len+8(FP), SI693	MOVQ	buf+16(FP), DX694	MOVL	$SYS_sched_getaffinity, AX695	SYSCALL696	MOVL	AX, ret+24(FP)697	RET698699// int access(const char *name, int mode)700TEXT runtime·access(SB),NOSPLIT,$0701	// This uses faccessat instead of access, because Android O blocks access.702	MOVL	$AT_FDCWD, DI // AT_FDCWD, so this acts like access703	MOVQ	name+0(FP), SI704	MOVL	mode+8(FP), DX705	MOVL	$0, R10706	MOVL	$SYS_faccessat, AX707	SYSCALL708	MOVL	AX, ret+16(FP)709	RET710711// int connect(int fd, const struct sockaddr *addr, socklen_t addrlen)712TEXT runtime·connect(SB),NOSPLIT,$0-28713	MOVL	fd+0(FP), DI714	MOVQ	addr+8(FP), SI715	MOVL	len+16(FP), DX716	MOVL	$SYS_connect, AX717	SYSCALL718	MOVL	AX, ret+24(FP)719	RET720721// int socket(int domain, int type, int protocol)722TEXT runtime·socket(SB),NOSPLIT,$0-20723	MOVL	domain+0(FP), DI724	MOVL	typ+4(FP), SI725	MOVL	prot+8(FP), DX726	MOVL	$SYS_socket, AX727	SYSCALL728	MOVL	AX, ret+16(FP)729	RET730731// func sbrk0() uintptr732TEXT runtime·sbrk0(SB),NOSPLIT,$0-8733	// Implemented as brk(NULL).734	MOVQ	$0, DI735	MOVL	$SYS_brk, AX736	SYSCALL737	MOVQ	AX, ret+0(FP)738	RET739740// func vgetrandom1(buf *byte, length uintptr, flags uint32, state uintptr, stateSize uintptr) int741TEXT runtime·vgetrandom1<ABIInternal>(SB),NOSPLIT,$16-48742	MOVQ	SI, R8 // stateSize743	MOVL	CX, DX // flags744	MOVQ	DI, CX // state745	MOVQ	BX, SI // length746	MOVQ	AX, DI // buf747748	MOVQ	SP, R12749750	MOVQ	runtime·vdsoGetrandomSym(SB), AX751	MOVQ	g_m(R14), BX752753	MOVQ	m_vdsoPC(BX), R9754	MOVQ	R9, 0(SP)755	MOVQ	m_vdsoSP(BX), R9756	MOVQ	R9, 8(SP)757	LEAQ	buf+0(FP), R9758	MOVQ	R9, m_vdsoSP(BX)759	MOVQ	-8(R9), R9760	MOVQ	R9, m_vdsoPC(BX)761762	ANDQ	$~15, SP763764	CALL	AX765766	MOVQ	R12, SP767	MOVQ	8(SP), R9768	MOVQ	R9, m_vdsoSP(BX)769	MOVQ	0(SP), R9770	MOVQ	R9, m_vdsoPC(BX)771	RET

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.