Commit dcb954c3 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/link: remove size and version from genasmsym's argument

They are trivially available in the few places they are needed.

Change-Id: I6544692e9027076ec9e6e9a295c66457039e55e1
Reviewed-on: https://go-review.googlesource.com/29332
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 22660475
...@@ -814,7 +814,7 @@ func synthesizechantypes(ctxt *Link, die *dwarf.DWDie) { ...@@ -814,7 +814,7 @@ func synthesizechantypes(ctxt *Link, die *dwarf.DWDie) {
} }
// For use with pass.c::genasmsym // For use with pass.c::genasmsym
func defdwsymb(ctxt *Link, sym *Symbol, s string, t SymbolType, v int64, size int64, ver int, gotype *Symbol) { func defdwsymb(ctxt *Link, sym *Symbol, s string, t SymbolType, v int64, gotype *Symbol) {
if strings.HasPrefix(s, "go.string.") { if strings.HasPrefix(s, "go.string.") {
return return
} }
...@@ -835,9 +835,9 @@ func defdwsymb(ctxt *Link, sym *Symbol, s string, t SymbolType, v int64, size in ...@@ -835,9 +835,9 @@ func defdwsymb(ctxt *Link, sym *Symbol, s string, t SymbolType, v int64, size in
return return
case DataSym, BSSSym: case DataSym, BSSSym:
dv = newdie(ctxt, &dwglobals, dwarf.DW_ABRV_VARIABLE, s, ver) dv = newdie(ctxt, &dwglobals, dwarf.DW_ABRV_VARIABLE, s, int(sym.Version))
newabslocexprattr(dv, v, sym) newabslocexprattr(dv, v, sym)
if ver == 0 { if sym.Version == 0 {
newattr(dv, dwarf.DW_AT_external, dwarf.DW_CLS_FLAG, 1, 0) newattr(dv, dwarf.DW_AT_external, dwarf.DW_CLS_FLAG, 1, 0)
} }
fallthrough fallthrough
......
...@@ -1818,16 +1818,16 @@ const ( ...@@ -1818,16 +1818,16 @@ const (
AutoSym = 'a' AutoSym = 'a'
) )
func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, int64, int, *Symbol)) { func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, *Symbol)) {
// These symbols won't show up in the first loop below because we // These symbols won't show up in the first loop below because we
// skip STEXT symbols. Normal STEXT symbols are emitted by walking textp. // skip STEXT symbols. Normal STEXT symbols are emitted by walking textp.
s := Linklookup(ctxt, "runtime.text", 0) s := Linklookup(ctxt, "runtime.text", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
s = Linklookup(ctxt, "runtime.etext", 0) s = Linklookup(ctxt, "runtime.etext", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
for _, s := range ctxt.Allsym { for _, s := range ctxt.Allsym {
...@@ -1866,7 +1866,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i ...@@ -1866,7 +1866,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i
if !s.Attr.Reachable() { if !s.Attr.Reachable() {
continue continue
} }
put(ctxt, s, s.Name, DataSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype) put(ctxt, s, s.Name, DataSym, Symaddr(ctxt, s), s.Gotype)
case obj.SBSS, obj.SNOPTRBSS: case obj.SBSS, obj.SNOPTRBSS:
if !s.Attr.Reachable() { if !s.Attr.Reachable() {
...@@ -1875,39 +1875,39 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i ...@@ -1875,39 +1875,39 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i
if len(s.P) > 0 { if len(s.P) > 0 {
ctxt.Diag("%s should not be bss (size=%d type=%d special=%v)", s.Name, len(s.P), s.Type, s.Attr.Special()) ctxt.Diag("%s should not be bss (size=%d type=%d special=%v)", s.Name, len(s.P), s.Type, s.Attr.Special())
} }
put(ctxt, s, s.Name, BSSSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype) put(ctxt, s, s.Name, BSSSym, Symaddr(ctxt, s), s.Gotype)
case obj.SFILE: case obj.SFILE:
put(ctxt, nil, s.Name, FileSym, s.Value, 0, int(s.Version), nil) put(ctxt, nil, s.Name, FileSym, s.Value, nil)
case obj.SHOSTOBJ: case obj.SHOSTOBJ:
if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui || Iself { if Headtype == obj.Hwindows || Headtype == obj.Hwindowsgui || Iself {
put(ctxt, s, s.Name, UndefinedSym, s.Value, 0, int(s.Version), nil) put(ctxt, s, s.Name, UndefinedSym, s.Value, nil)
} }
case obj.SDYNIMPORT: case obj.SDYNIMPORT:
if !s.Attr.Reachable() { if !s.Attr.Reachable() {
continue continue
} }
put(ctxt, s, s.Extname, UndefinedSym, 0, 0, int(s.Version), nil) put(ctxt, s, s.Extname, UndefinedSym, 0, nil)
case obj.STLSBSS: case obj.STLSBSS:
if Linkmode == LinkExternal && Headtype != obj.Hopenbsd { if Linkmode == LinkExternal && Headtype != obj.Hopenbsd {
put(ctxt, s, s.Name, TLSSym, Symaddr(ctxt, s), s.Size, int(s.Version), s.Gotype) put(ctxt, s, s.Name, TLSSym, Symaddr(ctxt, s), s.Gotype)
} }
} }
} }
var off int32 var off int32
for _, s := range ctxt.Textp { for _, s := range ctxt.Textp {
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), s.Gotype) put(ctxt, s, s.Name, TextSym, s.Value, s.Gotype)
locals := int32(0) locals := int32(0)
if s.FuncInfo != nil { if s.FuncInfo != nil {
locals = s.FuncInfo.Locals locals = s.FuncInfo.Locals
} }
// NOTE(ality): acid can't produce a stack trace without .frame symbols // NOTE(ality): acid can't produce a stack trace without .frame symbols
put(ctxt, nil, ".frame", FrameSym, int64(locals)+int64(SysArch.PtrSize), 0, 0, nil) put(ctxt, nil, ".frame", FrameSym, int64(locals)+int64(SysArch.PtrSize), nil)
if s.FuncInfo == nil { if s.FuncInfo == nil {
continue continue
...@@ -1928,13 +1928,13 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i ...@@ -1928,13 +1928,13 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, i
// FP // FP
if off >= 0 { if off >= 0 {
put(ctxt, nil, a.Asym.Name, ParamSym, int64(off), 0, 0, a.Gotype) put(ctxt, nil, a.Asym.Name, ParamSym, int64(off), a.Gotype)
continue continue
} }
// SP // SP
if off <= int32(-SysArch.PtrSize) { if off <= int32(-SysArch.PtrSize) {
put(ctxt, nil, a.Asym.Name, AutoSym, -(int64(off) + int64(SysArch.PtrSize)), 0, 0, a.Gotype) put(ctxt, nil, a.Asym.Name, AutoSym, -(int64(off) + int64(SysArch.PtrSize)), a.Gotype)
continue continue
} }
} }
......
...@@ -612,7 +612,7 @@ func symkind(s *Symbol) int { ...@@ -612,7 +612,7 @@ func symkind(s *Symbol) int {
return SymKindLocal return SymKindLocal
} }
func addsym(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, size int64, ver int, gotype *Symbol) { func addsym(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, gotype *Symbol) {
if s == nil { if s == nil {
return return
} }
...@@ -661,7 +661,7 @@ func machogenasmsym(ctxt *Link) { ...@@ -661,7 +661,7 @@ func machogenasmsym(ctxt *Link) {
for _, s := range ctxt.Allsym { for _, s := range ctxt.Allsym {
if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ { if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ {
if s.Attr.Reachable() { if s.Attr.Reachable() {
addsym(ctxt, s, "", DataSym, 0, 0, 0, nil) addsym(ctxt, s, "", DataSym, 0, nil)
} }
} }
} }
......
...@@ -930,7 +930,7 @@ func newPEDWARFSection(ctxt *Link, name string, size int64) *IMAGE_SECTION_HEADE ...@@ -930,7 +930,7 @@ func newPEDWARFSection(ctxt *Link, name string, size int64) *IMAGE_SECTION_HEADE
func writePESymTableRecords(ctxt *Link) int { func writePESymTableRecords(ctxt *Link) int {
var symcnt int var symcnt int
put := func(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, size int64, ver int, gotype *Symbol) { put := func(ctxt *Link, s *Symbol, name string, type_ SymbolType, addr int64, gotype *Symbol) {
if s == nil { if s == nil {
return return
} }
...@@ -1000,13 +1000,13 @@ func writePESymTableRecords(ctxt *Link) int { ...@@ -1000,13 +1000,13 @@ func writePESymTableRecords(ctxt *Link) int {
for d := dr; d != nil; d = d.next { for d := dr; d != nil; d = d.next {
for m := d.ms; m != nil; m = m.next { for m := d.ms; m != nil; m = m.next {
s := m.s.R[0].Xsym s := m.s.R[0].Xsym
put(ctxt, s, s.Name, UndefinedSym, 0, int64(SysArch.PtrSize), 0, nil) put(ctxt, s, s.Name, UndefinedSym, 0, nil)
} }
} }
s := Linklookup(ctxt, ".text", 0) s := Linklookup(ctxt, ".text", 0)
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
put(ctxt, s, s.Name, TextSym, s.Value, s.Size, int(s.Version), nil) put(ctxt, s, s.Name, TextSym, s.Value, nil)
} }
} }
......
...@@ -76,7 +76,7 @@ var numelfsym int = 1 // 0 is reserved ...@@ -76,7 +76,7 @@ var numelfsym int = 1 // 0 is reserved
var elfbind int var elfbind int
func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size int64, ver int, go_ *Symbol) { func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, go_ *Symbol) {
var typ int var typ int
switch t { switch t {
...@@ -98,6 +98,11 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size i ...@@ -98,6 +98,11 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size i
typ = STT_TLS typ = STT_TLS
} }
size := x.Size
if t == UndefinedSym {
size = 0
}
xo := x xo := x
for xo.Outer != nil { for xo.Outer != nil {
xo = xo.Outer xo = xo.Outer
...@@ -124,7 +129,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size i ...@@ -124,7 +129,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, size i
// maybe one day STB_WEAK. // maybe one day STB_WEAK.
bind := STB_GLOBAL bind := STB_GLOBAL
if ver != 0 || (x.Type&obj.SHIDDEN != 0) || x.Attr.Local() { if x.Version != 0 || (x.Type&obj.SHIDDEN != 0) || x.Attr.Local() {
bind = STB_LOCAL bind = STB_LOCAL
} }
...@@ -208,11 +213,11 @@ func Asmelfsym(ctxt *Link) { ...@@ -208,11 +213,11 @@ func Asmelfsym(ctxt *Link) {
genasmsym(ctxt, putelfsym) genasmsym(ctxt, putelfsym)
} }
func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, size int64, ver int, go_ *Symbol) { func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, go_ *Symbol) {
t := int(typ) t := int(typ)
switch typ { switch typ {
case TextSym, DataSym, BSSSym: case TextSym, DataSym, BSSSym:
if ver != 0 { if x.Version != 0 {
t += 'a' - 'A' t += 'a' - 'A'
} }
fallthrough fallthrough
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment