github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/runtime/rt0_linux_arm.s (about) 1 // Copyright 2009 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 TEXT _rt0_arm_linux(SB),7,$-4 6 // We first need to detect the kernel ABI, and warn the user 7 // if the system only supports OABI 8 // The strategy here is to call some EABI syscall to see if 9 // SIGILL is received. 10 // To catch SIGILL, we have to first setup sigaction, this is 11 // a chicken-and-egg problem, because we can't do syscall if 12 // we don't know the kernel ABI... Oh, not really, we can do 13 // syscall in Thumb mode. 14 15 // set up sa_handler 16 MOVW $bad_abi<>(SB), R0 // sa_handler 17 MOVW $0, R1 // sa_flags 18 MOVW $0, R2 // sa_restorer 19 MOVW $0, R3 // sa_mask 20 MOVM.DB.W [R0-R3], (R13) 21 MOVW $4, R0 // SIGILL 22 MOVW R13, R1 // sa 23 SUB $16, R13 24 MOVW R13, R2 // old_sa 25 MOVW $8, R3 // c 26 MOVW $174, R7 // sys_sigaction 27 BL oabi_syscall<>(SB) 28 29 // do an EABI syscall 30 MOVW $20, R7 // sys_getpid 31 SWI $0 // this will trigger SIGILL on OABI systems 32 33 MOVW $4, R0 // SIGILL 34 MOVW R13, R1 // sa 35 MOVW $0, R2 // old_sa 36 MOVW $8, R3 // c 37 MOVW $174, R7 // sys_sigaction 38 SWI $0 // restore signal handler 39 ADD $32, R13 40 41 SUB $4, R13 // fake a stack frame for runtime·setup_auxv 42 BL runtime·setup_auxv(SB) 43 ADD $4, R13 44 B _rt0_arm(SB) 45 46 TEXT bad_abi<>(SB),7,$-4 47 // give diagnosis and exit 48 MOVW $2, R0 // stderr 49 MOVW $bad_abi_msg(SB), R1 // data 50 MOVW $45, R2 // len 51 MOVW $4, R7 // sys_write 52 BL oabi_syscall<>(SB) 53 MOVW $1, R0 54 MOVW $1, R7 // sys_exit 55 BL oabi_syscall<>(SB) 56 B 0(PC) 57 58 DATA bad_abi_msg+0x00(SB)/8, $"This pro" 59 DATA bad_abi_msg+0x08(SB)/8, $"gram can" 60 DATA bad_abi_msg+0x10(SB)/8, $" only be" 61 DATA bad_abi_msg+0x18(SB)/8, $" run on " 62 DATA bad_abi_msg+0x20(SB)/8, $"EABI ker" 63 DATA bad_abi_msg+0x28(SB)/4, $"nels" 64 DATA bad_abi_msg+0x2c(SB)/1, $0xa 65 GLOBL bad_abi_msg(SB), $45 66 67 TEXT oabi_syscall<>(SB),7,$-4 68 ADD $1, PC, R4 69 WORD $0xe12fff14 //BX (R4) // enter thumb mode 70 // TODO(minux): only supports little-endian CPUs 71 WORD $0x4770df01 // swi $1; bx lr 72