]> Cypherpunks.ru repositories - gostls13.git/commit
runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external...
authorElias Naur <elias.naur@gmail.com>
Wed, 14 Aug 2013 15:38:54 +0000 (15:38 +0000)
committerRuss Cox <rsc@golang.org>
Wed, 14 Aug 2013 15:38:54 +0000 (15:38 +0000)
commit45233734e28776a6679dd8aa9f66a1d545ca8ec6
tree2d2df0108d9e04c1a23924201ff35acac4358cff
parentc92287686d3735050dc36a7eaa93ae1824732500
runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking

This CL is an aggregate of 10271047104990439733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
44 files changed:
src/cmd/5l/5.out.h
src/cmd/5l/asm.c
src/cmd/5l/l.h
src/cmd/5l/noop.c
src/cmd/5l/obj.c
src/cmd/5l/optab.c
src/cmd/5l/pass.c
src/cmd/5l/span.c
src/cmd/6a/a.y
src/cmd/6a/y.tab.c
src/cmd/6l/asm.c
src/cmd/6l/l.h
src/cmd/6l/obj.c
src/cmd/6l/pass.c
src/cmd/6l/span.c
src/cmd/8l/asm.c
src/cmd/8l/l.h
src/cmd/8l/obj.c
src/cmd/8l/span.c
src/cmd/cgo/out.go
src/cmd/dist/buildruntime.c
src/cmd/ld/data.c
src/cmd/ld/elf.c
src/cmd/ld/elf.h
src/cmd/ld/go.c
src/cmd/ld/lib.c
src/cmd/ld/lib.h
src/cmd/ld/symtab.c
src/pkg/runtime/asm_arm.s
src/pkg/runtime/cgo/asm_arm.s
src/pkg/runtime/cgo/cgo_arm.c [deleted file]
src/pkg/runtime/cgo/gcc_arm.S
src/pkg/runtime/cgo/gcc_freebsd_arm.c
src/pkg/runtime/cgo/gcc_linux_arm.c
src/pkg/runtime/cgo/gcc_netbsd_arm.c
src/pkg/runtime/cgocall.c
src/pkg/runtime/os_linux_arm.c
src/pkg/runtime/rt0_freebsd_arm.s
src/pkg/runtime/rt0_linux_arm.s
src/pkg/runtime/rt0_netbsd_arm.s
src/pkg/runtime/sys_freebsd_arm.s
src/pkg/runtime/sys_linux_arm.s
src/pkg/runtime/sys_netbsd_arm.s
src/run.bash