diff options
| author | Russ Cox <rsc@golang.org> | 2010-08-04 17:50:22 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2010-08-04 17:50:22 -0700 |
| commit | e473f42b2d3ac9b877436638dc182342dcd2e86c (patch) | |
| tree | 4a8b31048310c4334ac1c16f4321c6d9e667dfcb /src/cmd/6l/obj.c | |
| parent | 3dc6c9e64d8de9931ed621aaa15884512014afd2 (diff) | |
| download | go-e473f42b2d3ac9b877436638dc182342dcd2e86c.tar.xz | |
amd64: use segment memory for thread-local storage
Returns R14 and R15 to the available register pool.
Plays more nicely with ELF ABI C code.
In particular, our signal handlers will no longer crash
when a signal arrives during execution of a cgo C call.
Fixes #720.
R=ken2, r
CC=golang-dev
https://golang.org/cl/1847051
Diffstat (limited to 'src/cmd/6l/obj.c')
| -rw-r--r-- | src/cmd/6l/obj.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index 724f11296a..3b981a6127 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -165,6 +165,11 @@ main(int argc, char *argv[]) INITRND = 4096; break; case 6: /* apple MACH */ + /* + * OS X system constant - offset from 0(GS) to our TLS. + * Explained in ../../libcgo/darwin_amd64.c. + */ + tlsoffset = 0x8a0; machoinit(); HEADR = MACHORESERVE; if(INITRND == -1) @@ -176,6 +181,13 @@ main(int argc, char *argv[]) break; case 7: /* elf64 executable */ case 9: /* freebsd */ + /* + * ELF uses TLS offset negative from FS. + * Translate 0(FS) and 8(FS) into -16(FS) and -8(FS). + * Also known to ../../pkg/runtime/linux/amd64/sys.s + * and ../../libcgo/linux_amd64.s. + */ + tlsoffset = -16; elfinit(); HEADR = ELFRESERVE; if(INITTEXT == -1) @@ -434,6 +446,8 @@ zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[]) adrgotype = zsym(pn, f, h); s = a->sym; t = a->type; + if(t == D_INDIR+D_GS) + a->offset += tlsoffset; if(t != D_AUTO && t != D_PARAM) { if(s && adrgotype) s->gotype = adrgotype; |
