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

Issue 7975045: code review 7975045: cmd/ld: emit TLS relocations during external linking

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by rsc
Modified:
12 years ago
Reviewers:
gobot, iant
CC:
golang-dev
Visibility:
Public.

Description

cmd/ld: emit TLS relocations during external linking This CL adds TLS relocation to the ELF .o file we write during external linking, so that the host linker (gcc) can decide the final location of m and g. Similar relocations are not necessary on OS X because we use an alternate program start-time mechanism to acquire thread-local storage. Similar relocations are not necessary on ARM or Plan 9 or Windows because external linking mode is not yet supported on those systems. On almost all ELF systems, the references we use are like %fs:-0x4 or %gs:-0x4, which we write in 6a/8a as -0x4(FS) or -0x4(GS). On Linux/ELF, however, Xen's lack of support for this mode forced us long ago to use a two-instruction sequence: first we load %gs:0x0 into a register r, and then we use -0x4(r). (The ELF program loader arranges that %gs:0x0 contains a regular pointer to that same memory location.) In order to relocate those -0x4(r) references, the linker must know where they are. This CL adds the equivalent notation -0x4(r)(GS*1) for this purpose: it assembles to the same encoding as -0x4(r) but the (GS*1) indicates to the linker that this is one of those thread-local references that needs relocation. Thanks to Elias Naur for reminding me about this missing piece and also for writing the test.

Patch Set 1 #

Patch Set 2 : diff -r b3cfb8be2faf https://code.google.com/p/go/ #

Patch Set 3 : diff -r bcc0898b0026 https://code.google.com/p/go/ #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+771 lines, -835 lines) Patch
A misc/cgo/testtls/tls.go View 1 1 chunk +28 lines, -0 lines 0 comments Download
A misc/cgo/testtls/tls_test.go View 1 2 1 chunk +13 lines, -0 lines 0 comments Download
A misc/cgo/testtls/tls_unix.c View 1 1 chunk +19 lines, -0 lines 0 comments Download
M src/cmd/5l/5.out.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/6l/6.out.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/6l/asm.c View 1 1 chunk +7 lines, -0 lines 0 comments Download
M src/cmd/6l/obj.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/6l/span.c View 1 2 chunks +23 lines, -0 lines 0 comments Download
M src/cmd/8a/a.y View 1 1 chunk +9 lines, -0 lines 0 comments Download
M src/cmd/8a/y.tab.h View 1 4 chunks +21 lines, -25 lines 0 comments Download
M src/cmd/8a/y.tab.c View 1 117 chunks +535 lines, -795 lines 0 comments Download
M src/cmd/8l/8.out.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/8l/asm.c View 1 1 chunk +6 lines, -0 lines 0 comments Download
M src/cmd/8l/obj.c View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/8l/pass.c View 1 2 chunks +4 lines, -0 lines 1 comment Download
M src/cmd/8l/span.c View 1 5 chunks +33 lines, -2 lines 0 comments Download
M src/cmd/dist/buildruntime.c View 1 1 chunk +8 lines, -3 lines 0 comments Download
M src/cmd/ld/data.c View 1 4 chunks +25 lines, -6 lines 0 comments Download
M src/cmd/ld/elf.c View 1 3 chunks +7 lines, -1 line 0 comments Download
M src/cmd/ld/lib.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/ld/symtab.c View 1 1 chunk +20 lines, -0 lines 0 comments Download
M src/run.bash View 1 2 1 chunk +7 lines, -1 line 0 comments Download

Messages

Total messages: 3
rsc
Hello iant (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
12 years, 9 months ago (2013-03-25 21:50:48 UTC) #1
iant
https://codereview.appspot.com/7975045/diff/4001/src/cmd/8l/pass.c File src/cmd/8l/pass.c (right): https://codereview.appspot.com/7975045/diff/4001/src/cmd/8l/pass.c#newcode304 src/cmd/8l/pass.c:304: q->from.index = D_GS; // signal to relocate I don't ...
12 years, 9 months ago (2013-03-27 20:19:09 UTC) #2
gobot
12 years ago (2013-12-18 16:54:41 UTC) #3
R=close (assigned by rsc@google.com)
Sign in to reply to this message.

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