diff options
author | Tianon Gravi <admwiggin@gmail.com> | 2015-01-15 12:50:40 -0700 |
---|---|---|
committer | Tianon Gravi <admwiggin@gmail.com> | 2015-01-15 12:50:40 -0700 |
commit | 2a0db60599fdd75b1bc3e297180fbe1282763759 (patch) | |
tree | 68d43c3e30d9ab961ddf6b7365201ca6b675b253 /src/runtime/tls_arm.s | |
parent | ef33cba3c8de6c431df56503df51fcd3a473c89e (diff) | |
parent | f154da9e12608589e8d5f0508f908a0c3e88a1bb (diff) | |
download | golang-2a0db60599fdd75b1bc3e297180fbe1282763759.tar.gz |
Merge tag 'upstream/1.4' into debian-experimental
* tag 'upstream/1.4':
Imported Upstream version 1.4
Diffstat (limited to 'src/runtime/tls_arm.s')
-rw-r--r-- | src/runtime/tls_arm.s | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/runtime/tls_arm.s b/src/runtime/tls_arm.s new file mode 100644 index 000000000..85c3940bf --- /dev/null +++ b/src/runtime/tls_arm.s @@ -0,0 +1,69 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "zasm_GOOS_GOARCH.h" +#include "funcdata.h" +#include "textflag.h" + +// We have to resort to TLS variable to save g(R10). +// One reason is that external code might trigger +// SIGSEGV, and our runtime.sigtramp don't even know we +// are in external code, and will continue to use R10, +// this might as well result in another SIGSEGV. +// Note: both functions will clobber R0 and R11 and +// can be called from 5c ABI code. + +// On android, runtime.tlsg is a normal variable. +// TLS offset is computed in x_cgo_inittls. + +// save_g saves the g register into pthread-provided +// thread-local memory, so that we can call externally compiled +// ARM code that will overwrite those registers. +// NOTE: runtime.gogo assumes that R1 is preserved by this function. +// runtime.mcall assumes this function only clobbers R0 and R11. +// Returns with g in R0. +TEXT runtime·save_g(SB),NOSPLIT,$-4 +#ifdef GOOS_nacl + // nothing to do as nacl/arm does not use TLS at all. + MOVW g, R0 // preserve R0 across call to setg<> + RET +#endif + // If the host does not support MRC the linker will replace it with + // a call to runtime.read_tls_fallback which jumps to __kuser_get_tls. + // The replacement function saves LR in R11 over the call to read_tls_fallback. + MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer + // $runtime.tlsg(SB) is a special linker symbol. + // It is the offset from the TLS base pointer to our + // thread-local storage for g. +#ifdef GOOS_android + MOVW runtime·tlsg(SB), R11 +#else + MOVW $runtime·tlsg(SB), R11 +#endif + ADD R11, R0 + MOVW g, 0(R0) + MOVW g, R0 // preserve R0 across call to setg<> + RET + +// load_g loads the g register from pthread-provided +// thread-local memory, for use after calling externally compiled +// ARM code that overwrote those registers. +TEXT runtime·load_g(SB),NOSPLIT,$0 +#ifdef GOOS_nacl + // nothing to do as nacl/arm does not use TLS at all. + RET +#endif + // See save_g + MRC 15, 0, R0, C13, C0, 3 // fetch TLS base pointer + // $runtime.tlsg(SB) is a special linker symbol. + // It is the offset from the TLS base pointer to our + // thread-local storage for g. +#ifdef GOOS_android + MOVW runtime·tlsg(SB), R11 +#else + MOVW $runtime·tlsg(SB), R11 +#endif + ADD R11, R0 + MOVW 0(R0), g + RET |