1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:44:43 -07:00

[dev.link] cmd/link: remove elfsetstring

No longer needed.

Change-Id: I7cd08915e4731c4546414340df69521e2347367f
Reviewed-on: https://go-review.googlesource.com/c/go/+/233521
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-05-12 17:16:51 -04:00
parent 69261d1f36
commit 2eb475be6b
6 changed files with 6 additions and 28 deletions

View File

@ -628,7 +628,7 @@ func elfwriteshdrs(out *OutBuf) uint32 {
return uint32(ehdr.shnum) * ELF32SHDRSIZE return uint32(ehdr.shnum) * ELF32SHDRSIZE
} }
func elfsetstring2(ctxt *Link, s loader.Sym, str string, off int) { func elfsetstring(ctxt *Link, s loader.Sym, str string, off int) {
if nelfstr >= len(elfstr) { if nelfstr >= len(elfstr) {
ctxt.Errorf(s, "too many elf strings") ctxt.Errorf(s, "too many elf strings")
errorexit() errorexit()

View File

@ -1,23 +0,0 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ld
import "cmd/link/internal/sym"
// Temporary dumping around for sym.Symbol version of helper
// functions in elf.go, still being used for some archs/oses.
// FIXME: get rid of this file when dodata() is completely
// converted and the sym.Symbol functions are not needed.
func elfsetstring(s *sym.Symbol, str string, off int) {
if nelfstr >= len(elfstr) {
Errorf(s, "too many elf strings")
errorexit()
}
elfstr[nelfstr].s = str
elfstr[nelfstr].off = off
nelfstr++
}

View File

@ -506,7 +506,8 @@ func (ctxt *Link) loadlib() {
default: default:
log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups) log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups)
} }
ctxt.loader = loader.NewLoader(flags, elfsetstring, &ctxt.ErrorReporter.ErrorReporter) elfsetstring1 := func(str string, off int) { elfsetstring(ctxt, 0, str, off) }
ctxt.loader = loader.NewLoader(flags, elfsetstring1, &ctxt.ErrorReporter.ErrorReporter)
ctxt.ErrorReporter.SymName = func(s loader.Sym) string { ctxt.ErrorReporter.SymName = func(s loader.Sym) string {
return ctxt.loader.SymName(s) return ctxt.loader.SymName(s)
} }

View File

@ -312,7 +312,7 @@ const (
nonPkgRef nonPkgRef
) )
type elfsetstringFunc func(s *sym.Symbol, str string, off int) type elfsetstringFunc func(str string, off int)
// extSymPayload holds the payload (data + relocations) for linker-synthesized // extSymPayload holds the payload (data + relocations) for linker-synthesized
// external symbols (note that symbol value is stored in a separate slice). // external symbols (note that symbol value is stored in a separate slice).

View File

@ -28,7 +28,7 @@ func addDummyObjSym(t *testing.T, ldr *Loader, or *oReader, name string) Sym {
} }
func mkLoader() *Loader { func mkLoader() *Loader {
edummy := func(s *sym.Symbol, str string, off int) {} edummy := func(str string, off int) {}
er := ErrorReporter{} er := ErrorReporter{}
ldr := NewLoader(0, edummy, &er) ldr := NewLoader(0, edummy, &er)
er.ldr = ldr er.ldr = ldr

View File

@ -363,7 +363,7 @@ func (sb *SymbolBuilder) Addstring(str string) int64 {
r := sb.size r := sb.size
if sb.name == ".shstrtab" { if sb.name == ".shstrtab" {
// FIXME: find a better mechanism for this // FIXME: find a better mechanism for this
sb.l.elfsetstring(nil, str, int(r)) sb.l.elfsetstring(str, int(r))
} }
sb.data = append(sb.data, str...) sb.data = append(sb.data, str...)
sb.data = append(sb.data, 0) sb.data = append(sb.data, 0)