1
0
mirror of https://github.com/golang/go synced 2024-10-04 08:21:22 -06:00
go/src/liblink
Russ Cox b377c9c6a9 liblink, runtime: fix cgo on arm
The addition of TLS to ARM rewrote the MRC instruction
differently depending on whether we were using internal
or external linking mode. That's clearly not okay, since we
don't know that during compilation, which is when we now
generate the code. Also, because the change did not introduce
a real MRC instruction but instead just macro-expanded it
in the assembler, liblink is rewriting a WORD instruction that
may actually be looking for that specific constant, which would
lead to very unexpected results. It was also using one value
that happened to be 8 where a different value that also
happened to be 8 belonged. So the code was correct for those
values but not correct in general, and very confusing.

Throw it all away.

Replace with the following. There is a linker-provided symbol
runtime.tlsgm with a value (address) set to the offset from the
hardware-provided TLS base register to the g and m storage.
Any reference to that name emits an appropriate TLS relocation
to be resolved by either the internal linker or the external linker,
depending on the link mode. The relocation has exactly the
semantics of the R_ARM_TLS_LE32 relocation, which is what
the external linker provides.

This symbol is only used in two routines, runtime.load_gm and
runtime.save_gm. In both cases it is now used like this:

        MRC		15, 0, R0, C13, C0, 3 // fetch TLS base pointer
        MOVW	$runtime·tlsgm(SB), R2
        ADD	R2, R0 // now R0 points at thread-local g+m storage

It is likely that this change breaks the generation of shared libraries
on ARM, because the MOVW needs to be rewritten to use the global
offset table and a different relocation type. But let's get the supported
functionality working again before we worry about unsupported
functionality.

LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/56120043
2014-01-23 22:51:39 -05:00
..
asm5.c liblink, runtime: fix cgo on arm 2014-01-23 22:51:39 -05:00
asm6.c liblink: fix comments. Someone was overzealous with search & replace. 2014-01-09 19:46:46 -08:00
asm8.c liblink: fix Plan 9 warnings 2013-12-18 20:19:29 +01:00
data.c liblink: check for symgrow size too large 2014-01-21 06:12:54 -08:00
go.c liblink: create new library based on linker code 2013-12-08 22:49:37 -05:00
ld.c liblink: don't search for an import file with an absolute path 2013-12-18 10:33:47 -08:00
list5.c liblink: include missing pragmas for plan9 formatter 2014-01-22 06:23:19 +01:00
list6.c liblink: adjust format verbs to avoid collisions 2014-01-09 19:01:08 -08:00
list8.c liblink: adjust format verbs to avoid collisions 2014-01-09 19:01:08 -08:00
Makefile liblink: create new library based on linker code 2013-12-08 22:49:37 -05:00
obj5.c liblink, runtime: fix cgo on arm 2014-01-23 22:51:39 -05:00
obj6.c liblink: fix Plan 9 warnings 2013-12-18 20:19:29 +01:00
obj8.c cmd/ld: move instruction selection + layout into compilers, assemblers 2013-12-16 12:51:58 -05:00
obj.c cmd/ld: move instruction selection + layout into compilers, assemblers 2013-12-16 12:51:58 -05:00
objfile.c liblink: allow either of a pair of conflicting symbols to say dupok 2013-12-19 16:52:47 -05:00
pass.c cmd/ld: move instruction selection + layout into compilers, assemblers 2013-12-16 12:51:58 -05:00
pcln.c liblink, cmd/gc: resolve several shift warnings 2013-12-19 10:34:33 +11:00
sym.c cmd/ld: move instruction selection + layout into compilers, assemblers 2013-12-16 12:51:58 -05:00