Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1647)

Issue 12871044: runtime.cmd/ld: Add ARM external linking and implement ... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 8 months ago by elias.naur
Modified:
10 years, 8 months ago
Reviewers:
capnm, rsc
CC:
rsc, golang-dev
Visibility:
Public.

Description

runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking This CL is an aggregate of 10271047, 10499043, 9733044. 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 issue 5590.

Patch Set 1 #

Patch Set 2 : diff -r 2bc5fc177d58c8483e71fc97787e2a510e99e676 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+685 lines, -541 lines) Patch
M src/cmd/5l/5.out.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/5l/asm.c View 1 7 chunks +82 lines, -13 lines 0 comments Download
M src/cmd/5l/l.h View 1 3 chunks +1 line, -3 lines 0 comments Download
M src/cmd/5l/noop.c View 1 3 chunks +82 lines, -1 line 0 comments Download
M src/cmd/5l/obj.c View 1 4 chunks +21 lines, -12 lines 0 comments Download
M src/cmd/5l/optab.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/5l/pass.c View 1 1 chunk +7 lines, -0 lines 0 comments Download
M src/cmd/5l/span.c View 1 4 chunks +6 lines, -6 lines 0 comments Download
M src/cmd/6a/a.y View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/cmd/6a/y.tab.c View 1 18 chunks +179 lines, -164 lines 0 comments Download
M src/cmd/6l/asm.c View 1 2 chunks +6 lines, -9 lines 0 comments Download
M src/cmd/6l/l.h View 1 2 chunks +0 lines, -2 lines 0 comments Download
M src/cmd/6l/obj.c View 1 4 chunks +5 lines, -3 lines 0 comments Download
M src/cmd/6l/pass.c View 1 6 chunks +81 lines, -1 line 0 comments Download
M src/cmd/6l/span.c View 1 4 chunks +25 lines, -15 lines 0 comments Download
M src/cmd/8l/asm.c View 1 2 chunks +2 lines, -6 lines 0 comments Download
M src/cmd/8l/l.h View 1 2 chunks +0 lines, -2 lines 0 comments Download
M src/cmd/8l/obj.c View 1 1 chunk +0 lines, -1 line 0 comments Download
M src/cmd/8l/span.c View 1 1 chunk +3 lines, -10 lines 0 comments Download
M src/cmd/cgo/out.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/dist/buildruntime.c View 1 1 chunk +7 lines, -3 lines 0 comments Download
M src/cmd/ld/data.c View 1 11 chunks +11 lines, -40 lines 0 comments Download
M src/cmd/ld/elf.h View 1 2 chunks +3 lines, -1 line 0 comments Download
M src/cmd/ld/elf.c View 1 4 chunks +9 lines, -12 lines 0 comments Download
M src/cmd/ld/go.c View 1 2 chunks +3 lines, -2 lines 0 comments Download
M src/cmd/ld/lib.h View 1 2 chunks +1 line, -2 lines 0 comments Download
M src/cmd/ld/lib.c View 1 6 chunks +28 lines, -13 lines 0 comments Download
M src/cmd/ld/symtab.c View 1 2 chunks +2 lines, -15 lines 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 6 chunks +44 lines, -11 lines 0 comments Download
M src/pkg/runtime/cgo/asm_arm.s View 1 1 chunk +2 lines, -3 lines 0 comments Download
R src/pkg/runtime/cgo/cgo_arm.c View 1 1 chunk +0 lines, -12 lines 0 comments Download
M src/pkg/runtime/cgo/gcc_arm.S View 1 1 chunk +1 line, -5 lines 0 comments Download
M src/pkg/runtime/cgo/gcc_freebsd_arm.c View 1 2 chunks +11 lines, -55 lines 0 comments Download
M src/pkg/runtime/cgo/gcc_linux_arm.c View 1 3 chunks +7 lines, -50 lines 0 comments Download
M src/pkg/runtime/cgo/gcc_netbsd_arm.c View 1 2 chunks +6 lines, -53 lines 0 comments Download
M src/pkg/runtime/cgocall.c View 1 1 chunk +0 lines, -5 lines 0 comments Download
M src/pkg/runtime/os_linux_arm.c View 1 1 chunk +1 line, -4 lines 0 comments Download
M src/pkg/runtime/rt0_freebsd_arm.s View 1 1 chunk +3 lines, -0 lines 0 comments Download
M src/pkg/runtime/rt0_linux_arm.s View 1 3 chunks +12 lines, -0 lines 0 comments Download
M src/pkg/runtime/rt0_netbsd_arm.s View 1 1 chunk +3 lines, -0 lines 0 comments Download
M src/pkg/runtime/sys_freebsd_arm.s View 1 1 chunk +4 lines, -0 lines 0 comments Download
M src/pkg/runtime/sys_linux_arm.s View 1 2 chunks +8 lines, -3 lines 0 comments Download
M src/pkg/runtime/sys_netbsd_arm.s View 1 1 chunk +6 lines, -0 lines 0 comments Download
M src/run.bash View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 13
rsc
LGTM Splitting crosscall_arm2 into setmg + crosscall_arm2 is not okay. There's no guarantee that gcc ...
10 years, 8 months ago (2013-08-14 14:44:23 UTC) #1
rsc
NOT LGTM Actually, I'm very confused by the TLS changes. I'm going to go back ...
10 years, 8 months ago (2013-08-14 14:58:16 UTC) #2
rsc
LGTM I figured it out. Now I pass setmg_gcc to crosscall_arm2 and it does both ...
10 years, 8 months ago (2013-08-14 15:37:38 UTC) #3
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=7b621e98c86e *** runtime.cmd/ld: Add ARM external linking and implement -shared in terms ...
10 years, 8 months ago (2013-08-14 15:39:07 UTC) #4
elias.naur
Thank you very much. The builders are not quite happy with the change; I'm looking ...
10 years, 8 months ago (2013-08-14 16:00:07 UTC) #5
elias.naur
https://codereview.appspot.com/12829044 should fix the windows failure. On Wednesday, August 14, 2013 6:00:07 PM UTC+2, Elias ...
10 years, 8 months ago (2013-08-14 16:05:20 UTC) #6
rsc
Thanks. Any idea about Darwin?
10 years, 8 months ago (2013-08-14 16:11:22 UTC) #7
elias.naur
Not yet, but it used to work fine on an iMac I tried it on ...
10 years, 8 months ago (2013-08-14 16:22:13 UTC) #8
capnm
The builder is somehow mixing different go paths: fatal error: cgocall nil goroutine 8 [running]: ...
10 years, 8 months ago (2013-08-14 16:39:50 UTC) #9
elias.naur
https://codereview.appspot.com/12842044 should fix the bsds on arm. - elias On Wednesday, August 14, 2013 6:00:07 ...
10 years, 8 months ago (2013-08-14 17:16:14 UTC) #10
elias.naur
https://codereview.appspot.com/12938043 should regain support on older ARM processors.
10 years, 8 months ago (2013-08-14 17:26:18 UTC) #11
elias.naur
On Wednesday, August 14, 2013 7:26:18 PM UTC+2, Elias Naur wrote: > > https://codereview.appspot.com/12938043 should ...
10 years, 8 months ago (2013-08-14 18:41:03 UTC) #12
rsc
10 years, 8 months ago (2013-08-14 18:43:53 UTC) #13
I sent a CL.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b