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.4//5// System calls and other sys.stuff for ARM, OpenBSD6// /usr/src/sys/kern/syscalls.master for syscall numbers.7//89#include "go_asm.h"10#include "go_tls.h"11#include "textflag.h"1213#define CLOCK_REALTIME $014#define CLOCK_MONOTONIC $31516// With OpenBSD 6.7 onwards, an armv7 syscall returns two instructions17// after the SWI instruction, to allow for a speculative execution18// barrier to be placed after the SWI without impacting performance.19// For now use hardware no-ops as this works with both older and newer20// kernels. After OpenBSD 6.8 is released this should be changed to21// speculation barriers.22#define NOOP MOVW R0, R023#define INVOKE_SYSCALL \24 SWI $0; \25 NOOP; \26 NOOP2728// mstart_stub is the first function executed on a new thread started by pthread_create.29// It just does some low-level setup and then calls mstart.30// Note: called with the C calling convention.31TEXT runtime·mstart_stub(SB),NOSPLIT,$032 // R0 points to the m.33 // We are already on m's g0 stack.3435 // Save callee-save registers.36 MOVM.DB.W [R4-R11], (R13)3738 MOVW m_g0(R0), g39 BL runtime·save_g(SB)4041 BL runtime·mstart(SB)4243 // Restore callee-save registers.44 MOVM.IA.W (R13), [R4-R11]4546 // Go is all done with this OS thread.47 // Tell pthread everything is ok (we never join with this thread, so48 // the value here doesn't really matter).49 MOVW $0, R050 RET5152TEXT runtime·sigfwd(SB),NOSPLIT,$0-1653 MOVW sig+4(FP), R054 MOVW info+8(FP), R155 MOVW ctx+12(FP), R256 MOVW fn+0(FP), R357 MOVW R13, R958 SUB $24, R1359 BIC $0x7, R13 // alignment for ELF ABI60 BL (R3)61 MOVW R9, R1362 RET6364TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME,$065 // Reserve space for callee-save registers and arguments.66 MOVM.DB.W [R4-R11], (R13)67 SUB $16, R136869 // If called from an external code context, g will not be set.70 // Save R0, since runtime·load_g will clobber it.71 MOVW R0, 4(R13) // signum72 BL runtime·load_g(SB)7374 MOVW R1, 8(R13)75 MOVW R2, 12(R13)76 BL runtime·sigtrampgo(SB)7778 // Restore callee-save registers.79 ADD $16, R1380 MOVM.IA.W (R13), [R4-R11]8182 RET8384TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-085 B runtime·armPublicationBarrier(SB)8687// TODO(jsing): OpenBSD only supports GOARM=7 machines... this88// should not be needed, however the linker still allows GOARM=589// on this platform.90TEXT runtime·read_tls_fallback(SB),NOSPLIT|NOFRAME,$091 MOVM.WP [R1, R2, R3, R12], (R13)92 MOVW $330, R12 // sys___get_tcb93 INVOKE_SYSCALL94 MOVM.IAW (R13), [R1, R2, R3, R12]95 RET9697// These trampolines help convert from Go calling convention to C calling convention.98// They should be called with asmcgocall - note that while asmcgocall does99// stack alignment, creation of a frame undoes it again.100// A pointer to the arguments is passed in R0.101// A single int32 result is returned in R0.102// (For more results, make an args/results structure.)103TEXT runtime·pthread_attr_init_trampoline(SB),NOSPLIT,$0104 MOVW R13, R9105 BIC $0x7, R13 // align for ELF ABI106 MOVW 0(R0), R0 // arg 1 attr107 CALL libc_pthread_attr_init(SB)108 MOVW R9, R13109 RET110111TEXT runtime·pthread_attr_destroy_trampoline(SB),NOSPLIT,$0112 MOVW R13, R9113 BIC $0x7, R13 // align for ELF ABI114 MOVW 0(R0), R0 // arg 1 attr115 CALL libc_pthread_attr_destroy(SB)116 MOVW R9, R13117 RET118119TEXT runtime·pthread_attr_getstacksize_trampoline(SB),NOSPLIT,$0120 MOVW R13, R9121 BIC $0x7, R13 // align for ELF ABI122 MOVW 4(R0), R1 // arg 2 size123 MOVW 0(R0), R0 // arg 1 attr124 CALL libc_pthread_attr_getstacksize(SB)125 MOVW R9, R13126 RET127128TEXT runtime·pthread_attr_setdetachstate_trampoline(SB),NOSPLIT,$0129 MOVW R13, R9130 BIC $0x7, R13 // align for ELF ABI131 MOVW 4(R0), R1 // arg 2 state132 MOVW 0(R0), R0 // arg 1 attr133 CALL libc_pthread_attr_setdetachstate(SB)134 MOVW R9, R13135 RET136137TEXT runtime·pthread_create_trampoline(SB),NOSPLIT,$0138 MOVW R13, R9139 SUB $16, R13140 BIC $0x7, R13 // align for ELF ABI141 MOVW 0(R0), R1 // arg 2 attr142 MOVW 4(R0), R2 // arg 3 start143 MOVW 8(R0), R3 // arg 4 arg144 MOVW R13, R0 // arg 1 &threadid (discarded)145 CALL libc_pthread_create(SB)146 MOVW R9, R13147 RET148149TEXT runtime·thrkill_trampoline(SB),NOSPLIT,$0150 MOVW R13, R9151 BIC $0x7, R13 // align for ELF ABI152 MOVW 4(R0), R1 // arg 2 - signal153 MOVW $0, R2 // arg 3 - tcb154 MOVW 0(R0), R0 // arg 1 - tid155 CALL libc_thrkill(SB)156 MOVW R9, R13157 RET158159TEXT runtime·thrsleep_trampoline(SB),NOSPLIT,$0160 MOVW R13, R9161 SUB $16, R13162 BIC $0x7, R13 // align for ELF ABI163 MOVW 4(R0), R1 // arg 2 - clock_id164 MOVW 8(R0), R2 // arg 3 - abstime165 MOVW 12(R0), R3 // arg 4 - lock166 MOVW 16(R0), R4 // arg 5 - abort (on stack)167 MOVW R4, 0(R13)168 MOVW 0(R0), R0 // arg 1 - id169 CALL libc_thrsleep(SB)170 MOVW R9, R13171 RET172173TEXT runtime·thrwakeup_trampoline(SB),NOSPLIT,$0174 MOVW R13, R9175 BIC $0x7, R13 // align for ELF ABI176 MOVW 4(R0), R1 // arg 2 - count177 MOVW 0(R0), R0 // arg 1 - id178 CALL libc_thrwakeup(SB)179 MOVW R9, R13180 RET181182TEXT runtime·exit_trampoline(SB),NOSPLIT,$0183 MOVW R13, R9184 BIC $0x7, R13 // align for ELF ABI185 MOVW 0(R0), R0 // arg 1 exit status186 BL libc_exit(SB)187 MOVW $0, R8 // crash on failure188 MOVW R8, (R8)189 MOVW R9, R13190 RET191192TEXT runtime·getthrid_trampoline(SB),NOSPLIT,$0193 MOVW R13, R9194 MOVW R0, R8195 BIC $0x7, R13 // align for ELF ABI196 BL libc_getthrid(SB)197 MOVW R0, 0(R8)198 MOVW R9, R13199 RET200201TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0202 MOVW R13, R9203 BIC $0x7, R13 // align for ELF ABI204 MOVW R0, R4205 BL libc_getpid(SB) // arg 1 pid206 MOVW R4, R1 // arg 2 signal207 BL libc_kill(SB)208 MOVW R9, R13209 RET210211TEXT runtime·sched_yield_trampoline(SB),NOSPLIT,$0212 MOVW R13, R9213 BIC $0x7, R13 // align for ELF ABI214 BL libc_sched_yield(SB)215 MOVW R9, R13216 RET217218TEXT runtime·mmap_trampoline(SB),NOSPLIT,$0219 MOVW R13, R9220 SUB $16, R13221 BIC $0x7, R13 // align for ELF ABI222 MOVW R0, R8223 MOVW 4(R0), R1 // arg 2 len224 MOVW 8(R0), R2 // arg 3 prot225 MOVW 12(R0), R3 // arg 4 flags226 MOVW 16(R0), R4 // arg 5 fid (on stack)227 MOVW R4, 0(R13)228 MOVW $0, R5 // pad (on stack)229 MOVW R5, 4(R13)230 MOVW 20(R0), R6 // arg 6 offset (on stack)231 MOVW R6, 8(R13) // low 32 bits232 MOVW $0, R7233 MOVW R7, 12(R13) // high 32 bits234 MOVW 0(R0), R0 // arg 1 addr235 BL libc_mmap(SB)236 MOVW $0, R1237 CMP $-1, R0238 BNE ok239 BL libc_errno(SB)240 MOVW (R0), R1 // errno241 MOVW $0, R0242ok:243 MOVW R0, 24(R8)244 MOVW R1, 28(R8)245 MOVW R9, R13246 RET247248TEXT runtime·munmap_trampoline(SB),NOSPLIT,$0249 MOVW R13, R9250 BIC $0x7, R13 // align for ELF ABI251 MOVW 4(R0), R1 // arg 2 len252 MOVW 0(R0), R0 // arg 1 addr253 BL libc_munmap(SB)254 CMP $-1, R0255 BNE 3(PC)256 MOVW $0, R8 // crash on failure257 MOVW R8, (R8)258 MOVW R9, R13259 RET260261TEXT runtime·madvise_trampoline(SB), NOSPLIT, $0262 MOVW R13, R9263 BIC $0x7, R13 // align for ELF ABI264 MOVW 4(R0), R1 // arg 2 len265 MOVW 8(R0), R2 // arg 3 advice266 MOVW 0(R0), R0 // arg 1 addr267 BL libc_madvise(SB)268 // ignore failure - maybe pages are locked269 MOVW R9, R13270 RET271272TEXT runtime·open_trampoline(SB),NOSPLIT,$0273 MOVW R13, R9274 SUB $8, R13275 BIC $0x7, R13 // align for ELF ABI276 MOVW 4(R0), R1 // arg 2 - flags277 MOVW 8(R0), R2 // arg 3 - mode (vararg, on stack)278 MOVW R2, 0(R13)279 MOVW 0(R0), R0 // arg 1 - path280 MOVW R13, R4281 BIC $0x7, R13 // align for ELF ABI282 BL libc_open(SB)283 MOVW R9, R13284 RET285286TEXT runtime·close_trampoline(SB),NOSPLIT,$0287 MOVW R13, R9288 BIC $0x7, R13 // align for ELF ABI289 MOVW 0(R0), R0 // arg 1 - fd290 BL libc_close(SB)291 MOVW R9, R13292 RET293294TEXT runtime·read_trampoline(SB),NOSPLIT,$0295 MOVW R13, R9296 BIC $0x7, R13 // align for ELF ABI297 MOVW 4(R0), R1 // arg 2 - buf298 MOVW 8(R0), R2 // arg 3 - count299 MOVW 0(R0), R0 // arg 1 - fd300 BL libc_read(SB)301 CMP $-1, R0302 BNE noerr303 BL libc_errno(SB)304 MOVW (R0), R0 // errno305 RSB.CS $0, R0 // caller expects negative errno306noerr:307 MOVW R9, R13308 RET309310TEXT runtime·write_trampoline(SB),NOSPLIT,$0311 MOVW R13, R9312 BIC $0x7, R13 // align for ELF ABI313 MOVW 4(R0), R1 // arg 2 buf314 MOVW 8(R0), R2 // arg 3 count315 MOVW 0(R0), R0 // arg 1 fd316 BL libc_write(SB)317 CMP $-1, R0318 BNE noerr319 BL libc_errno(SB)320 MOVW (R0), R0 // errno321 RSB.CS $0, R0 // caller expects negative errno322noerr:323 MOVW R9, R13324 RET325326TEXT runtime·pipe2_trampoline(SB),NOSPLIT,$0327 MOVW R13, R9328 BIC $0x7, R13 // align for ELF ABI329 MOVW 4(R0), R1 // arg 2 flags330 MOVW 0(R0), R0 // arg 1 filedes331 BL libc_pipe2(SB)332 CMP $-1, R0333 BNE 3(PC)334 BL libc_errno(SB)335 MOVW (R0), R0 // errno336 RSB.CS $0, R0 // caller expects negative errno337 MOVW R9, R13338 RET339340TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0341 MOVW R13, R9342 BIC $0x7, R13 // align for ELF ABI343 MOVW 4(R0), R1 // arg 2 new344 MOVW 8(R0), R2 // arg 3 old345 MOVW 0(R0), R0 // arg 1 which346 BL libc_setitimer(SB)347 MOVW R9, R13348 RET349350TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0351 MOVW R13, R9352 BIC $0x7, R13 // align for ELF ABI353 MOVW 0(R0), R0 // arg 1 usec354 BL libc_usleep(SB)355 MOVW R9, R13356 RET357358TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0359 MOVW R13, R9360 SUB $8, R13361 BIC $0x7, R13 // align for ELF ABI362 MOVW 4(R0), R1 // arg 2 miblen363 MOVW 8(R0), R2 // arg 3 out364 MOVW 12(R0), R3 // arg 4 size365 MOVW 16(R0), R4 // arg 5 dst (on stack)366 MOVW R4, 0(R13)367 MOVW 20(R0), R5 // arg 6 ndst (on stack)368 MOVW R5, 4(R13)369 MOVW 0(R0), R0 // arg 1 mib370 BL libc_sysctl(SB)371 MOVW R9, R13372 RET373374TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0375 MOVW R13, R9376 BIC $0x7, R13 // align for ELF ABI377 BL libc_kqueue(SB)378 MOVW R9, R13379 RET380381TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0382 MOVW R13, R9383 SUB $8, R13384 BIC $0x7, R13 // align for ELF ABI385 MOVW 4(R0), R1 // arg 2 keventt386 MOVW 8(R0), R2 // arg 3 nch387 MOVW 12(R0), R3 // arg 4 ev388 MOVW 16(R0), R4 // arg 5 nev (on stack)389 MOVW R4, 0(R13)390 MOVW 20(R0), R5 // arg 6 ts (on stack)391 MOVW R5, 4(R13)392 MOVW 0(R0), R0 // arg 1 kq393 BL libc_kevent(SB)394 CMP $-1, R0395 BNE ok396 BL libc_errno(SB)397 MOVW (R0), R0 // errno398 RSB.CS $0, R0 // caller expects negative errno399ok:400 MOVW R9, R13401 RET402403TEXT runtime·clock_gettime_trampoline(SB),NOSPLIT,$0404 MOVW R13, R9405 BIC $0x7, R13 // align for ELF ABI406 MOVW 4(R0), R1 // arg 2 tp407 MOVW 0(R0), R0 // arg 1 clock_id408 BL libc_clock_gettime(SB)409 CMP $-1, R0410 BNE noerr411 BL libc_errno(SB)412 MOVW (R0), R0 // errno413 RSB.CS $0, R0 // caller expects negative errno414noerr:415 MOVW R9, R13416 RET417418TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0419 MOVW R13, R9420 SUB $8, R13421 BIC $0x7, R13 // align for ELF ABI422 MOVW R0, R8423 MOVW 0(R8), R0 // arg 1 fd424 MOVW 4(R8), R1 // arg 2 cmd425 MOVW 8(R8), R2 // arg 3 arg (vararg, on stack)426 MOVW R2, 0(R13)427 BL libc_fcntl(SB)428 MOVW $0, R1429 CMP $-1, R0430 BNE noerr431 BL libc_errno(SB)432 MOVW (R0), R1433 MOVW $-1, R0434noerr:435 MOVW R0, 12(R8)436 MOVW R1, 16(R8)437 MOVW R9, R13438 RET439440TEXT runtime·sigaction_trampoline(SB),NOSPLIT,$0441 MOVW R13, R9442 BIC $0x7, R13 // align for ELF ABI443 MOVW 4(R0), R1 // arg 2 new444 MOVW 8(R0), R2 // arg 3 old445 MOVW 0(R0), R0 // arg 1 sig446 BL libc_sigaction(SB)447 CMP $-1, R0448 BNE 3(PC)449 MOVW $0, R8 // crash on failure450 MOVW R8, (R8)451 MOVW R9, R13452 RET453454TEXT runtime·sigprocmask_trampoline(SB),NOSPLIT,$0455 MOVW R13, R9456 BIC $0x7, R13 // align for ELF ABI457 MOVW 4(R0), R1 // arg 2 new458 MOVW 8(R0), R2 // arg 3 old459 MOVW 0(R0), R0 // arg 1 how460 BL libc_pthread_sigmask(SB)461 CMP $-1, R0462 BNE 3(PC)463 MOVW $0, R8 // crash on failure464 MOVW R8, (R8)465 MOVW R9, R13466 RET467468TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0469 MOVW R13, R9470 BIC $0x7, R13 // align for ELF ABI471 MOVW 4(R0), R1 // arg 2 old472 MOVW 0(R0), R0 // arg 1 new473 BL libc_sigaltstack(SB)474 CMP $-1, R0475 BNE 3(PC)476 MOVW $0, R8 // crash on failure477 MOVW R8, (R8)478 MOVW R9, R13479 RET480481// syscall calls a function in libc on behalf of the syscall package.482// syscall takes a pointer to a struct like:483// struct {484// fn uintptr485// a1 uintptr486// a2 uintptr487// a3 uintptr488// r1 uintptr489// r2 uintptr490// err uintptr491// }492// syscall must be called on the g0 stack with the493// C calling convention (use libcCall).494//495// syscall expects a 32-bit result and tests for 32-bit -1496// to decide there was an error.497TEXT runtime·syscall(SB),NOSPLIT,$0498 MOVW R13, R9499 BIC $0x7, R13 // align for ELF ABI500501 MOVW R0, R8502503 MOVW (0*4)(R8), R7 // fn504 MOVW (1*4)(R8), R0 // a1505 MOVW (2*4)(R8), R1 // a2506 MOVW (3*4)(R8), R2 // a3507508 BL (R7)509510 MOVW R0, (4*4)(R8) // r1511 MOVW R1, (5*4)(R8) // r2512513 // Standard libc functions return -1 on error and set errno.514 CMP $-1, R0515 BNE ok516517 // Get error code from libc.518 BL libc_errno(SB)519 MOVW (R0), R1520 MOVW R1, (6*4)(R8) // err521522ok:523 MOVW $0, R0 // no error (it's ignored anyway)524 MOVW R9, R13525 RET526527// syscallX calls a function in libc on behalf of the syscall package.528// syscallX takes a pointer to a struct like:529// struct {530// fn uintptr531// a1 uintptr532// a2 uintptr533// a3 uintptr534// r1 uintptr535// r2 uintptr536// err uintptr537// }538// syscallX must be called on the g0 stack with the539// C calling convention (use libcCall).540//541// syscallX is like syscall but expects a 64-bit result542// and tests for 64-bit -1 to decide there was an error.543TEXT runtime·syscallX(SB),NOSPLIT,$0544 MOVW R13, R9545 BIC $0x7, R13 // align for ELF ABI546547 MOVW R0, R8548549 MOVW (0*4)(R8), R7 // fn550 MOVW (1*4)(R8), R0 // a1551 MOVW (2*4)(R8), R1 // a2552 MOVW (3*4)(R8), R2 // a3553554 BL (R7)555556 MOVW R0, (4*4)(R8) // r1557 MOVW R1, (5*4)(R8) // r2558559 // Standard libc functions return -1 on error and set errno.560 CMP $-1, R0561 BNE ok562 CMP $-1, R1563 BNE ok564565 // Get error code from libc.566 BL libc_errno(SB)567 MOVW (R0), R1568 MOVW R1, (6*4)(R8) // err569570ok:571 MOVW $0, R0 // no error (it's ignored anyway)572 MOVW R9, R13573 RET574575// syscall6 calls a function in libc on behalf of the syscall package.576// syscall6 takes a pointer to a struct like:577// struct {578// fn uintptr579// a1 uintptr580// a2 uintptr581// a3 uintptr582// a4 uintptr583// a5 uintptr584// a6 uintptr585// r1 uintptr586// r2 uintptr587// err uintptr588// }589// syscall6 must be called on the g0 stack with the590// C calling convention (use libcCall).591//592// syscall6 expects a 32-bit result and tests for 32-bit -1593// to decide there was an error.594TEXT runtime·syscall6(SB),NOSPLIT,$0595 MOVW R13, R9596 SUB $8, R13597 BIC $0x7, R13 // align for ELF ABI598599 MOVW R0, R8600601 MOVW (0*4)(R8), R7 // fn602 MOVW (1*4)(R8), R0 // a1603 MOVW (2*4)(R8), R1 // a2604 MOVW (3*4)(R8), R2 // a3605 MOVW (4*4)(R8), R3 // a4606 MOVW (5*4)(R8), R4 // a5607 MOVW R4, 0(R13)608 MOVW (6*4)(R8), R5 // a6609 MOVW R5, 4(R13)610611 BL (R7)612613 MOVW R0, (7*4)(R8) // r1614 MOVW R1, (8*4)(R8) // r2615616 // Standard libc functions return -1 on error and set errno.617 CMP $-1, R0618 BNE ok619620 // Get error code from libc.621 BL libc_errno(SB)622 MOVW (R0), R1623 MOVW R1, (9*4)(R8) // err624625ok:626 MOVW $0, R0 // no error (it's ignored anyway)627 MOVW R9, R13628 RET629630// syscall6X calls a function in libc on behalf of the syscall package.631// syscall6X takes a pointer to a struct like:632// struct {633// fn uintptr634// a1 uintptr635// a2 uintptr636// a3 uintptr637// a4 uintptr638// a5 uintptr639// a6 uintptr640// r1 uintptr641// r2 uintptr642// err uintptr643// }644// syscall6X must be called on the g0 stack with the645// C calling convention (use libcCall).646//647// syscall6X is like syscall6 but expects a 64-bit result648// and tests for 64-bit -1 to decide there was an error.649TEXT runtime·syscall6X(SB),NOSPLIT,$0650 MOVW R13, R9651 SUB $8, R13652 BIC $0x7, R13 // align for ELF ABI653654 MOVW R0, R8655656 MOVW (0*4)(R8), R7 // fn657 MOVW (1*4)(R8), R0 // a1658 MOVW (2*4)(R8), R1 // a2659 MOVW (3*4)(R8), R2 // a3660 MOVW (4*4)(R8), R3 // a4661 MOVW (5*4)(R8), R4 // a5662 MOVW R4, 0(R13)663 MOVW (6*4)(R8), R5 // a6664 MOVW R5, 4(R13)665666 BL (R7)667668 MOVW R0, (7*4)(R8) // r1669 MOVW R1, (8*4)(R8) // r2670671 // Standard libc functions return -1 on error and set errno.672 CMP $-1, R0673 BNE ok674 CMP $-1, R1675 BNE ok676677 // Get error code from libc.678 BL libc_errno(SB)679 MOVW (R0), R1680 MOVW R1, (9*4)(R8) // err681682ok:683 MOVW $0, R0 // no error (it's ignored anyway)684 MOVW R9, R13685 RET686687// syscall10 calls a function in libc on behalf of the syscall package.688// syscall10 takes a pointer to a struct like:689// struct {690// fn uintptr691// a1 uintptr692// a2 uintptr693// a3 uintptr694// a4 uintptr695// a5 uintptr696// a6 uintptr697// a7 uintptr698// a8 uintptr699// a9 uintptr700// a10 uintptr701// r1 uintptr702// r2 uintptr703// err uintptr704// }705// syscall10 must be called on the g0 stack with the706// C calling convention (use libcCall).707TEXT runtime·syscall10(SB),NOSPLIT,$0708 MOVW R13, R9709 SUB $24, R13710 BIC $0x7, R13 // align for ELF ABI711712 MOVW R0, R8713714 MOVW (0*4)(R8), R7 // fn715 MOVW (1*4)(R8), R0 // a1716 MOVW (2*4)(R8), R1 // a2717 MOVW (3*4)(R8), R2 // a3718 MOVW (4*4)(R8), R3 // a4719 MOVW (5*4)(R8), R4 // a5720 MOVW R4, 0(R13)721 MOVW (6*4)(R8), R5 // a6722 MOVW R5, 4(R13)723 MOVW (7*4)(R8), R6 // a7724 MOVW R6, 8(R13)725 MOVW (8*4)(R8), R4 // a8726 MOVW R4, 12(R13)727 MOVW (9*4)(R8), R5 // a9728 MOVW R5, 16(R13)729 MOVW (10*4)(R8), R6 // a10730 MOVW R6, 20(R13)731732 BL (R7)733734 MOVW R0, (11*4)(R8) // r1735 MOVW R1, (12*4)(R8) // r2736737 // Standard libc functions return -1 on error and set errno.738 CMP $-1, R0739 BNE ok740741 // Get error code from libc.742 BL libc_errno(SB)743 MOVW (R0), R1744 MOVW R1, (13*4)(R8) // err745746ok:747 MOVW $0, R0 // no error (it's ignored anyway)748 MOVW R9, R13749 RET750751// syscall10X calls a function in libc on behalf of the syscall package.752// syscall10X takes a pointer to a struct like:753// struct {754// fn uintptr755// a1 uintptr756// a2 uintptr757// a3 uintptr758// a4 uintptr759// a5 uintptr760// a6 uintptr761// a7 uintptr762// a8 uintptr763// a9 uintptr764// a10 uintptr765// r1 uintptr766// r2 uintptr767// err uintptr768// }769// syscall10X must be called on the g0 stack with the770// C calling convention (use libcCall).771//772// syscall10X is like syscall10 but expects a 64-bit result773// and tests for 64-bit -1 to decide there was an error.774TEXT runtime·syscall10X(SB),NOSPLIT,$0775 MOVW R13, R9776 SUB $24, R13777 BIC $0x7, R13 // align for ELF ABI778779 MOVW R0, R8780781 MOVW (0*4)(R8), R7 // fn782 MOVW (1*4)(R8), R0 // a1783 MOVW (2*4)(R8), R1 // a2784 MOVW (3*4)(R8), R2 // a3785 MOVW (4*4)(R8), R3 // a4786 MOVW (5*4)(R8), R4 // a5787 MOVW R4, 0(R13)788 MOVW (6*4)(R8), R5 // a6789 MOVW R5, 4(R13)790 MOVW (7*4)(R8), R6 // a7791 MOVW R6, 8(R13)792 MOVW (8*4)(R8), R4 // a8793 MOVW R4, 12(R13)794 MOVW (9*4)(R8), R5 // a9795 MOVW R5, 16(R13)796 MOVW (10*4)(R8), R6 // a10797 MOVW R6, 20(R13)798799 BL (R7)800801 MOVW R0, (11*4)(R8) // r1802 MOVW R1, (12*4)(R8) // r2803804 // Standard libc functions return -1 on error and set errno.805 CMP $-1, R0806 BNE ok807 CMP $-1, R1808 BNE ok809810 // Get error code from libc.811 BL libc_errno(SB)812 MOVW (R0), R1813 MOVW R1, (13*4)(R8) // err814815ok:816 MOVW $0, R0 // no error (it's ignored anyway)817 MOVW R9, R13818 RET819820TEXT runtime·issetugid_trampoline(SB),NOSPLIT,$0821 MOVW R13, R9822 MOVW R0, R8823 BIC $0x7, R13 // align for ELF ABI824 BL libc_issetugid(SB)825 MOVW R0, 0(R8)826 MOVW R9, R13827 RET
Findings
✓ No findings reported for this file.