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

Issue 35790044: code review 35790044: liblink: create new library based on linker code (Closed)

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

Description

liblink: create new library based on linker code There is an enormous amount of code moving around in this CL, but the code is the same, and it is invoked in the same ways. This CL is preparation for the new linker structure, not the new structure itself. The new library's definition is in include/link.h. The main change is the use of a Link structure to hold all the linker-relevant state, replacing the smattering of global variables. The Link structure should both make it clearer which state must be carried around and make it possible to parallelize more easily later. The main body of the linker has moved into the architecture-independent cmd/ld directory. That includes the list of known header types, so the distinction between Hplan9x32 and Hplan9x64 is removed (no other header type distinguished 32- and 64-bit formats), and code for unused formats such as ipaq kernels has been deleted. The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld. Because multiple files are being merged in the liblink directory, it is not possible to show the diffs nicely in hg. The Prog and Addr structures have been unified into an architecture-independent form and moved to link.h, where they will be shared by all tools: the assemblers, the compilers, and the linkers. The unification makes it possible to write architecture-independent traversal of Prog lists, among other benefits. The Sym structures cannot be unified: they are too fundamentally different between the linker and the compilers. Instead, liblink defines an LSym - a linker Sym - to be used in the Prog and Addr structures, and the linker now refers exclusively to LSyms. The compilers will keep using their own syms but will fill out the corresponding LSyms in the Prog and Addr structures. Although code from 5l, 6l, and 8l is now in a single library, the code has been arranged so that only one architecture needs to be linked into a particular program: 5l will not contain the code needed for x86 instruction layout, for example. The object file writing code in liblink/obj.c is from cmd/gc/obj.c. Preparation for golang.org/s/go13linker work. This CL does not build by itself. It depends on 35740044 and will be submitted at the same time.

Patch Set 1 #

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

Total comments: 22

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

Total comments: 4

Patch Set 4 : diff -r 7326da92ff4d https://code.google.com/p/go/ #

Patch Set 5 : diff -r 7326da92ff4d https://code.google.com/p/go/ #

Patch Set 6 : diff -r 4a9cefaed227 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11924 lines, -24290 lines) Patch
A include/link.h View 1 2 3 4 5 1 chunk +567 lines, -0 lines 0 comments Download
M include/u.h View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M src/cmd/5l/5.out.h View 1 2 3 4 5 1 chunk +35 lines, -44 lines 0 comments Download
M src/cmd/5l/asm.c View 1 3 4 5 28 chunks +105 lines, -1388 lines 0 comments Download
M src/cmd/5l/l.h View 1 2 3 4 5 5 chunks +43 lines, -307 lines 0 comments Download
M src/cmd/5l/list.c View 1 3 4 5 9 chunks +18 lines, -22 lines 0 comments Download
M src/cmd/5l/noop.c View 1 3 4 5 1 chunk +3 lines, -668 lines 0 comments Download
M src/cmd/5l/obj.c View 1 2 3 4 5 4 chunks +8 lines, -716 lines 0 comments Download
R src/cmd/5l/optab.c View 1 3 4 5 1 chunk +0 lines, -277 lines 0 comments Download
R src/cmd/5l/pass.c View 1 3 4 5 1 chunk +0 lines, -409 lines 0 comments Download
R src/cmd/5l/prof.c View 1 3 4 5 1 chunk +0 lines, -211 lines 0 comments Download
R src/cmd/5l/softfloat.c View 1 3 4 5 1 chunk +0 lines, -91 lines 0 comments Download
M src/cmd/6l/6.out.h View 1 2 3 4 5 1 chunk +0 lines, -12 lines 0 comments Download
M src/cmd/6l/asm.c View 1 3 4 5 22 chunks +97 lines, -137 lines 0 comments Download
M src/cmd/6l/l.h View 1 2 3 4 5 3 chunks +25 lines, -340 lines 0 comments Download
M src/cmd/6l/list.c View 1 3 4 5 4 chunks +11 lines, -11 lines 0 comments Download
M src/cmd/6l/obj.c View 1 2 3 4 5 6 chunks +6 lines, -664 lines 0 comments Download
R src/cmd/6l/optab.c View 1 2 3 4 5 1 chunk +0 lines, -1372 lines 0 comments Download
R src/cmd/6l/prof.c View 1 3 4 5 1 chunk +0 lines, -171 lines 0 comments Download
M src/cmd/8l/8.out.h View 1 2 3 4 5 1 chunk +0 lines, -12 lines 0 comments Download
M src/cmd/8l/asm.c View 1 3 4 5 24 chunks +95 lines, -248 lines 0 comments Download
M src/cmd/8l/l.h View 1 2 3 4 5 3 chunks +26 lines, -305 lines 0 comments Download
M src/cmd/8l/list.c View 1 3 4 5 5 chunks +11 lines, -11 lines 0 comments Download
M src/cmd/8l/obj.c View 1 2 3 4 5 6 chunks +8 lines, -666 lines 0 comments Download
R src/cmd/8l/optab.c View 1 2 3 4 5 1 chunk +0 lines, -1032 lines 0 comments Download
R src/cmd/8l/prof.c View 1 3 4 5 1 chunk +0 lines, -173 lines 0 comments Download
M src/cmd/ld/data.c View 1 3 4 5 40 chunks +101 lines, -436 lines 0 comments Download
M src/cmd/ld/decodesym.c View 1 3 4 5 7 chunks +31 lines, -31 lines 0 comments Download
M src/cmd/ld/dwarf.h View 1 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/ld/dwarf.c View 1 3 4 5 24 chunks +43 lines, -43 lines 0 comments Download
M src/cmd/ld/elf.h View 1 3 4 5 3 chunks +7 lines, -7 lines 0 comments Download
M src/cmd/ld/elf.c View 1 3 4 5 26 chunks +92 lines, -92 lines 0 comments Download
M src/cmd/ld/go.c View 1 3 4 5 17 chunks +25 lines, -58 lines 0 comments Download
M src/cmd/ld/ldelf.c View 1 3 4 5 10 chunks +21 lines, -21 lines 0 comments Download
M src/cmd/ld/ldmacho.c View 1 3 4 5 9 chunks +17 lines, -17 lines 0 comments Download
M src/cmd/ld/ldpe.c View 1 3 4 5 8 chunks +18 lines, -18 lines 0 comments Download
M src/cmd/ld/lib.h View 1 2 3 4 5 7 chunks +124 lines, -259 lines 0 comments Download
M src/cmd/ld/lib.c View 1 2 3 4 5 32 chunks +119 lines, -1197 lines 0 comments Download
M src/cmd/ld/macho.c View 1 3 4 5 16 chunks +53 lines, -53 lines 0 comments Download
A src/cmd/ld/pass.c View 1 3 4 5 1 chunk +104 lines, -0 lines 0 comments Download
A src/cmd/ld/pcln.c View 1 3 4 5 1 chunk +258 lines, -0 lines 0 comments Download
M src/cmd/ld/pe.h View 1 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/ld/pe.c View 1 3 4 5 12 chunks +20 lines, -20 lines 0 comments Download
A src/cmd/ld/pobj.c View 1 2 3 4 5 1 chunk +223 lines, -0 lines 0 comments Download
M src/cmd/ld/symtab.c View 1 3 4 5 15 chunks +25 lines, -25 lines 0 comments Download
A src/liblink/Makefile View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M src/liblink/asm5.c View 1 2 3 4 5 28 chunks +1799 lines, -293 lines 0 comments Download
M src/liblink/asm6.c View 1 2 3 4 5 40 chunks +1927 lines, -484 lines 0 comments Download
M src/liblink/asm8.c View 1 2 3 4 5 30 chunks +1454 lines, -390 lines 0 comments Download
A src/liblink/data.c View 1 2 3 4 5 1 chunk +366 lines, -0 lines 0 comments Download
A src/liblink/go.c View 1 2 3 4 5 1 chunk +74 lines, -0 lines 0 comments Download
M src/liblink/ld.c View 1 2 3 4 5 8 chunks +371 lines, -2334 lines 0 comments Download
M src/liblink/obj.c View 1 2 3 4 5 5 chunks +261 lines, -198 lines 0 comments Download
M src/liblink/obj5.c View 1 2 3 4 5 13 chunks +971 lines, -492 lines 0 comments Download
M src/liblink/obj6.c View 1 2 3 4 5 8 chunks +880 lines, -793 lines 0 comments Download
M src/liblink/obj8.c View 1 2 3 4 5 8 chunks +754 lines, -675 lines 0 comments Download
M src/liblink/pass.c View 1 2 3 4 5 1 chunk +52 lines, -928 lines 0 comments Download
M src/liblink/pcln.c View 1 2 3 4 5 10 chunks +152 lines, -2389 lines 0 comments Download
M src/liblink/rdobj5.c View 1 2 3 4 5 12 chunks +188 lines, -411 lines 0 comments Download
M src/liblink/rdobj6.c View 1 2 3 4 5 14 chunks +129 lines, -436 lines 0 comments Download
M src/liblink/rdobj8.c View 1 2 3 4 5 13 chunks +131 lines, -457 lines 0 comments Download
M src/liblink/sym.c View 1 2 3 4 5 2 chunks +67 lines, -2444 lines 0 comments Download

Messages

Total messages: 6
iant
Comment just from reading link.h. https://codereview.appspot.com/35790044/diff/20001/include/link.h File include/link.h (right): https://codereview.appspot.com/35790044/diff/20001/include/link.h#newcode46 include/link.h:46: struct Addr It would ...
10 years, 4 months ago (2013-12-04 19:14:12 UTC) #1
rsc
Hello iant, iant@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
10 years, 4 months ago (2013-12-04 19:23:34 UTC) #2
iant
https://codereview.appspot.com/35790044/diff/40001/src/cmd/5l/asm.c File src/cmd/5l/asm.c (right): https://codereview.appspot.com/35790044/diff/40001/src/cmd/5l/asm.c#newcode426 src/cmd/5l/asm.c:426: addgotsyminternal(Link *ctxt, LSym *s) What is your guideline for ...
10 years, 4 months ago (2013-12-05 02:20:06 UTC) #3
rsc
PTAL Thanks. https://codereview.appspot.com/35790044/diff/20001/include/link.h File include/link.h (right): https://codereview.appspot.com/35790044/diff/20001/include/link.h#newcode46 include/link.h:46: struct Addr On 2013/12/04 19:14:13, iant wrote: ...
10 years, 4 months ago (2013-12-05 02:59:07 UTC) #4
iant
LGTM
10 years, 4 months ago (2013-12-05 04:27:31 UTC) #5
rsc
10 years, 4 months ago (2013-12-09 03:49:42 UTC) #6
*** Submitted as https://code.google.com/p/go/source/detail?r=00fa28348495 ***

liblink: create new library based on linker code

There is an enormous amount of code moving around in this CL,
but the code is the same, and it is invoked in the same ways.
This CL is preparation for the new linker structure, not the new
structure itself.

The new library's definition is in include/link.h.

The main change is the use of a Link structure to hold all the
linker-relevant state, replacing the smattering of global variables.
The Link structure should both make it clearer which state must
be carried around and make it possible to parallelize more easily
later.

The main body of the linker has moved into the architecture-independent
cmd/ld directory. That includes the list of known header types, so the
distinction between Hplan9x32 and Hplan9x64 is removed (no other
header type distinguished 32- and 64-bit formats), and code for unused
formats such as ipaq kernels has been deleted.

The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld.
Because multiple files are being merged in the liblink directory,
it is not possible to show the diffs nicely in hg.

The Prog and Addr structures have been unified into an
architecture-independent form and moved to link.h, where they will
be shared by all tools: the assemblers, the compilers, and the linkers.
The unification makes it possible to write architecture-independent
traversal of Prog lists, among other benefits.

The Sym structures cannot be unified: they are too fundamentally
different between the linker and the compilers. Instead, liblink defines
an LSym - a linker Sym - to be used in the Prog and Addr structures,
and the linker now refers exclusively to LSyms. The compilers will
keep using their own syms but will fill out the corresponding LSyms in
the Prog and Addr structures.

Although code from 5l, 6l, and 8l is now in a single library, the
code has been arranged so that only one architecture needs to
be linked into a particular program: 5l will not contain the code
needed for x86 instruction layout, for example.

The object file writing code in liblink/obj.c is from cmd/gc/obj.c.

Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and will be submitted at the same time.

R=iant
CC=golang-dev
https://codereview.appspot.com/35790044
Sign in to reply to this message.

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