| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "zasm_GOOS_GOARCH.h" | 5 #include "zasm_GOOS_GOARCH.h" |
| 6 #include "funcdata.h" | 6 #include "funcdata.h" |
| 7 #include "../../cmd/ld/textflag.h" | 7 #include "../../cmd/ld/textflag.h" |
| 8 | 8 |
| 9 // using frame size $-4 means do not save LR on stack. | 9 // using frame size $-4 means do not save LR on stack. |
| 10 TEXT _rt0_go(SB),NOSPLIT,$-4 | 10 TEXT _rt0_go(SB),NOSPLIT,$-4 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 MOVW $(-8192+104)(R13), R0 | 33 MOVW $(-8192+104)(R13), R0 |
| 34 MOVW R0, g_stackguard(g) // (w 104b guard) | 34 MOVW R0, g_stackguard(g) // (w 104b guard) |
| 35 MOVW R0, g_stackguard0(g) | 35 MOVW R0, g_stackguard0(g) |
| 36 MOVW R13, g_stackbase(g) | 36 MOVW R13, g_stackbase(g) |
| 37 BL runtime·emptyfunc(SB) // fault if stack check is wrong | 37 BL runtime·emptyfunc(SB) // fault if stack check is wrong |
| 38 | 38 |
| 39 // if there is an _cgo_init, call it. | 39 // if there is an _cgo_init, call it. |
| 40 MOVW _cgo_init(SB), R4 | 40 MOVW _cgo_init(SB), R4 |
| 41 CMP $0, R4 | 41 CMP $0, R4 |
| 42 B.EQ nocgo | 42 B.EQ nocgo |
| 43 » BL» » runtime·save_g(SB); | 43 » MOVW» g, R0 » » » // arg 0: G |
|
dave_cheney.net
2014/07/02 04:33:05
if you're going to inline setg_gcc, please retain
crawshaw
2014/07/02 14:57:22
sorry, which comment?
| |
| 44 » MOVW» g, R0 // first argument of _cgo_init is g | 44 » MOVW» $setg_gcc<>(SB), R1 » // arg 1: setg |
| 45 » MOVW» $setg_gcc<>(SB), R1 // second argument is address of save_g | 45 » MOVW.NE $runtime·tlsg(SB), R2 » // arg 2: tlsg |
|
minux
2014/07/02 04:21:14
.NE is unnecessary here.
crawshaw
2014/07/02 14:57:22
Done.
| |
| 46 » BL» » (R4) // will clobber R0-R3 | 46 » MRC 15, 0, R3, C13, C0, 3 » // arg 3: TLS base pointer |
|
minux
2014/07/02 04:21:14
because this instruction will be rewritten by the
crawshaw
2014/07/02 14:57:22
thank you, I have been testing exclusively with GO
| |
| 47 » BL» (R4) // will clobber R0-R3 | |
| 47 | 48 |
| 48 nocgo: | 49 nocgo: |
| 49 // update stackguard after _cgo_init | 50 // update stackguard after _cgo_init |
| 50 MOVW g_stackguard0(g), R0 | 51 MOVW g_stackguard0(g), R0 |
| 51 MOVW R0, g_stackguard(g) | 52 MOVW R0, g_stackguard(g) |
| 52 | 53 |
| 53 BL runtime·checkgoarm(SB) | 54 BL runtime·checkgoarm(SB) |
| 54 BL runtime·check(SB) | 55 BL runtime·check(SB) |
| 55 | 56 |
| 56 // saved argc, argv | 57 // saved argc, argv |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 _eqnext: | 682 _eqnext: |
| 682 CMP R2, R6 | 683 CMP R2, R6 |
| 683 RET.EQ | 684 RET.EQ |
| 684 MOVBU.P 1(R2), R4 | 685 MOVBU.P 1(R2), R4 |
| 685 MOVBU.P 1(R3), R5 | 686 MOVBU.P 1(R3), R5 |
| 686 CMP R4, R5 | 687 CMP R4, R5 |
| 687 BEQ _eqnext | 688 BEQ _eqnext |
| 688 MOVB R7, v+16(FP) | 689 MOVB R7, v+16(FP) |
| 689 RET | 690 RET |
| 690 | 691 |
| 691 // We have to resort to TLS variable to save g(R10). | |
| 692 // One reason is that external code might trigger | |
| 693 // SIGSEGV, and our runtime.sigtramp don't even know we | |
| 694 // are in external code, and will continue to use R10, | |
| 695 // this might as well result in another SIGSEGV. | |
| 696 // Note: all three functions will clobber R0, and the last | |
| 697 // two can be called from 5c ABI code. | |
| 698 | |
| 699 // save_g saves the g register into pthread-provided | |
| 700 // thread-local memory, so that we can call externally compiled | |
| 701 // ARM code that will overwrite those registers. | |
| 702 // NOTE: runtime.gogo assumes that R1 is preserved by this function. | |
| 703 // runtime.mcall assumes this function only clobbers R0 and R11. | |
| 704 TEXT runtime·save_g(SB),NOSPLIT,$0 | |
| 705 MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer | |
| 706 // $runtime.tlsg(SB) is a special linker symbol. | |
| 707 // It is the offset from the TLS base pointer to our | |
| 708 // thread-local storage for g. | |
| 709 MOVW $runtime·tlsg(SB), R11 | |
| 710 ADD R11, R0 | |
| 711 MOVW g, 0(R0) | |
| 712 RET | |
| 713 | |
| 714 // load_g loads the g register from pthread-provided | |
| 715 // thread-local memory, for use after calling externally compiled | |
| 716 // ARM code that overwrote those registers. | |
| 717 TEXT runtime·load_g(SB),NOSPLIT,$0 | |
| 718 MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer | |
| 719 // $runtime.tlsg(SB) is a special linker symbol. | |
| 720 // It is the offset from the TLS base pointer to our | |
| 721 // thread-local storage for g. | |
| 722 MOVW $runtime·tlsg(SB), R11 | |
| 723 ADD R11, R0 | |
| 724 MOVW 0(R0), g | |
| 725 RET | |
| 726 | |
| 727 // void setg_gcc(G*); set g called from gcc. | 692 // void setg_gcc(G*); set g called from gcc. |
| 728 TEXT setg_gcc<>(SB),NOSPLIT,$0 | 693 TEXT setg_gcc<>(SB),NOSPLIT,$0 |
| 729 MOVW R0, g | 694 MOVW R0, g |
| 730 B runtime·save_g(SB) | 695 B runtime·save_g(SB) |
| 731 | 696 |
| 732 // TODO: share code with memeq? | 697 // TODO: share code with memeq? |
| 733 TEXT bytes·Equal(SB),NOSPLIT,$0 | 698 TEXT bytes·Equal(SB),NOSPLIT,$0 |
| 734 MOVW a_len+4(FP), R1 | 699 MOVW a_len+4(FP), R1 |
| 735 MOVW b_len+16(FP), R3 | 700 MOVW b_len+16(FP), R3 |
| 736 ········ | 701 ········ |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 MOVW.P R0, 4(R2) | 1175 MOVW.P R0, 4(R2) |
| 1211 MOVW.P 4(R1), R0 | 1176 MOVW.P 4(R1), R0 |
| 1212 MOVW.P R0, 4(R2) | 1177 MOVW.P R0, 4(R2) |
| 1213 MOVW.P 4(R1), R0 | 1178 MOVW.P 4(R1), R0 |
| 1214 MOVW.P R0, 4(R2) | 1179 MOVW.P R0, 4(R2) |
| 1215 MOVW.P 4(R1), R0 | 1180 MOVW.P 4(R1), R0 |
| 1216 MOVW.P R0, 4(R2) | 1181 MOVW.P R0, 4(R2) |
| 1217 MOVW.P 4(R1), R0 | 1182 MOVW.P 4(R1), R0 |
| 1218 MOVW.P R0, 4(R2) | 1183 MOVW.P R0, 4(R2) |
| 1219 RET | 1184 RET |
| OLD | NEW |