Skip to content

Commit 6914dd1

Browse files
ianlancetaylorgopherbot
authored andcommitted
cmd/link: add and use new SymKind SFirstUnallocated
The linker sources in several places used SXREF to mark the first SymKind which is not allocated in memory. This is cryptic. Instead use SFirstUnallocated, following the example of the existing SFirstWritable. Change-Id: If326ad63027402699094bcc49ef860db3772f82a Reviewed-on: https://go-review.googlesource.com/c/go/+/715623 Reviewed-by: Than McIntosh <thanm@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent f5f1426 commit 6914dd1

File tree

7 files changed

+36
-34
lines changed

7 files changed

+36
-34
lines changed

src/cmd/link/internal/ld/data.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,9 +1628,9 @@ type dodataState struct {
16281628
// Link context
16291629
ctxt *Link
16301630
// Data symbols bucketed by type.
1631-
data [sym.SXREF][]loader.Sym
1631+
data [sym.SFirstUnallocated][]loader.Sym
16321632
// Max alignment for each flavor of data symbol.
1633-
dataMaxAlign [sym.SXREF]int32
1633+
dataMaxAlign [sym.SFirstUnallocated]int32
16341634
// Overridden sym type
16351635
symGroupType []sym.SymKind
16361636
// Current data size so far.
@@ -1687,7 +1687,7 @@ func (ctxt *Link) dodata(symGroupType []sym.SymKind) {
16871687

16881688
st := state.symType(s)
16891689

1690-
if st <= sym.STEXTFIPSEND || st >= sym.SXREF {
1690+
if st <= sym.STEXTEND || st >= sym.SFirstUnallocated {
16911691
continue
16921692
}
16931693
state.data[st] = append(state.data[st], s)
@@ -2264,11 +2264,11 @@ func (state *dodataState) allocateDataSections(ctxt *Link) {
22642264
}
22652265

22662266
siz := 0
2267-
for symn := sym.SELFRXSECT; symn < sym.SXREF; symn++ {
2267+
for symn := sym.SELFRXSECT; symn < sym.SFirstUnallocated; symn++ {
22682268
siz += len(state.data[symn])
22692269
}
22702270
ctxt.datap = make([]loader.Sym, 0, siz)
2271-
for symn := sym.SELFRXSECT; symn < sym.SXREF; symn++ {
2271+
for symn := sym.SELFRXSECT; symn < sym.SFirstUnallocated; symn++ {
22722272
ctxt.datap = append(ctxt.datap, state.data[symn]...)
22732273
}
22742274
}

src/cmd/link/internal/ld/macho.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ func collectmachosyms(ctxt *Link) {
919919
continue
920920
}
921921
t := ldr.SymType(s)
922-
if t >= sym.SELFRXSECT && t < sym.SXREF { // data sections handled in dodata
922+
if t >= sym.SELFRXSECT && t < sym.SFirstUnallocated { // data sections handled in dodata
923923
if t == sym.STLSBSS {
924924
// TLSBSS is not used on darwin. See data.go:allocateDataSections
925925
continue

src/cmd/link/internal/ld/pe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func (f *peFile) writeSymbols(ctxt *Link) {
854854
continue
855855
}
856856
t := ldr.SymType(s)
857-
if t >= sym.SELFRXSECT && t < sym.SXREF { // data sections handled in dodata
857+
if t >= sym.SELFRXSECT && t < sym.SFirstUnallocated { // data sections handled in dodata
858858
if t == sym.STLSBSS {
859859
continue
860860
}

src/cmd/link/internal/ld/symtab.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func genelfsym(ctxt *Link, elfbind elf.SymBind) {
244244
continue
245245
}
246246
st := ldr.SymType(s)
247-
if st >= sym.SELFRXSECT && st < sym.SXREF {
247+
if st >= sym.SELFRXSECT && st < sym.SFirstUnallocated {
248248
typ := elf.STT_OBJECT
249249
if st == sym.STLSBSS {
250250
if ctxt.IsInternal() {
@@ -345,7 +345,7 @@ func asmbPlan9Sym(ctxt *Link) {
345345
continue
346346
}
347347
t := ldr.SymType(s)
348-
if t >= sym.SELFRXSECT && t < sym.SXREF { // data sections handled in dodata
348+
if t >= sym.SELFRXSECT && t < sym.SFirstUnallocated { // data sections handled in dodata
349349
if t == sym.STLSBSS {
350350
continue
351351
}
@@ -843,7 +843,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
843843
}
844844

845845
// CarrierSymByType tracks carrier symbols and their sizes.
846-
var CarrierSymByType [sym.SXREF]struct {
846+
var CarrierSymByType [sym.SFirstUnallocated]struct {
847847
Sym loader.Sym
848848
Size int64
849849
}

src/cmd/link/internal/ld/xcoff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ func (f *xcoffFile) asmaixsym(ctxt *Link) {
11211121
putaixsym(ctxt, s, BSSSym)
11221122
}
11231123

1124-
case st >= sym.SELFRXSECT && st < sym.SXREF: // data sections handled in dodata
1124+
case st >= sym.SELFRXSECT && st < sym.SFirstUnallocated: // data sections handled in dodata
11251125
if ldr.AttrReachable(s) {
11261126
putaixsym(ctxt, s, DataSym)
11271127
}

src/cmd/link/internal/sym/symkind.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const (
125125
STLSBSS // Thread-local zeroed data.
126126

127127
// Unallocated segment.
128+
SFirstUnallocated
128129
SXREF // Reference from non-Go object file.
129130
SMACHOSYMSTR // Mach-O string table.
130131
SMACHOSYMTAB // Mach-O symbol table.

src/cmd/link/internal/sym/symkind_string.go

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)