1
0
mirror of https://github.com/golang/go synced 2024-11-20 07:24:40 -07:00

cmd/internal/obj, cmd/link: random style cleanups

Identified during review of golang.org/cl/22103.

Change-Id: I86bab4cc17204df1e45deefdb0d0f9a8f6e17073
Reviewed-on: https://go-review.googlesource.com/22106
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2016-04-14 19:44:55 -07:00
parent 1441f76938
commit 106b9d3915
2 changed files with 9 additions and 27 deletions

View File

@ -158,19 +158,18 @@ func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg
return int32(pcln.Lastindex) return int32(pcln.Lastindex)
} }
var i int32 for i, file := range pcln.File {
for i = 0; i < int32(len(pcln.File)); i++ {
file := pcln.File[i]
if file == f { if file == f {
pcln.Lastfile = f pcln.Lastfile = f
pcln.Lastindex = int(i) pcln.Lastindex = i
return i return int32(i)
} }
} }
i := len(pcln.File)
pcln.File = append(pcln.File, f) pcln.File = append(pcln.File, f)
pcln.Lastfile = f pcln.Lastfile = f
pcln.Lastindex = int(i) pcln.Lastindex = i
return i return int32(i)
} }
// pctospadj computes the sp adjustment in effect. // pctospadj computes the sp adjustment in effect.

View File

@ -682,15 +682,11 @@ func machosymorder() {
} }
func machosymtab() { func machosymtab() {
var s *LSym
var o *LSym
var p string
symtab := Linklookup(Ctxt, ".machosymtab", 0) symtab := Linklookup(Ctxt, ".machosymtab", 0)
symstr := Linklookup(Ctxt, ".machosymstr", 0) symstr := Linklookup(Ctxt, ".machosymstr", 0)
for i := 0; i < nsortsym; i++ { for i := 0; i < nsortsym; i++ {
s = sortsym[i] s := sortsym[i]
Adduint32(Ctxt, symtab, uint32(symstr.Size)) Adduint32(Ctxt, symtab, uint32(symstr.Size))
// Only add _ to C symbols. Go symbols have dot in the name. // Only add _ to C symbols. Go symbols have dot in the name.
@ -699,20 +695,7 @@ func machosymtab() {
} }
// replace "·" as ".", because DTrace cannot handle it. // replace "·" as ".", because DTrace cannot handle it.
if !strings.Contains(s.Extname, "·") { Addstring(symstr, strings.Replace(s.Extname, "·", ".", -1))
Addstring(symstr, s.Extname)
} else {
for p = s.Extname; p != ""; p = p[1:] {
if p[0] == 0xc2 && (p[1:])[0] == 0xb7 {
Adduint8(Ctxt, symstr, '.')
p = p[1:]
} else {
Adduint8(Ctxt, symstr, p[0])
}
}
Adduint8(Ctxt, symstr, '\x00')
}
if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ { if s.Type == obj.SDYNIMPORT || s.Type == obj.SHOSTOBJ {
Adduint8(Ctxt, symtab, 0x01) // type N_EXT, external symbol Adduint8(Ctxt, symtab, 0x01) // type N_EXT, external symbol
@ -725,7 +708,7 @@ func machosymtab() {
} else { } else {
Adduint8(Ctxt, symtab, 0x0e) Adduint8(Ctxt, symtab, 0x0e)
} }
o = s o := s
for o.Outer != nil { for o.Outer != nil {
o = o.Outer o = o.Outer
} }