Commit cda0aa16 authored by David Crawshaw's avatar David Crawshaw

cmd/link: cleanup Datablk debug printing

(Split out from CL 22205.)

Change-Id: I45838dda8ea8c451b4388b8aade2c209cde2c0e1
Reviewed-on: https://go-review.googlesource.com/22299Reviewed-by: 's avatarMichael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0fec75f5
...@@ -665,11 +665,9 @@ func dynrelocsym(s *LSym) { ...@@ -665,11 +665,9 @@ func dynrelocsym(s *LSym) {
if s == rel { if s == rel {
return return
} }
var r *Reloc
var targ *LSym
for ri := 0; ri < len(s.R); ri++ { for ri := 0; ri < len(s.R); ri++ {
r = &s.R[ri] r := &s.R[ri]
targ = r.Sym targ := r.Sym
if targ == nil { if targ == nil {
continue continue
} }
...@@ -704,9 +702,8 @@ func dynrelocsym(s *LSym) { ...@@ -704,9 +702,8 @@ func dynrelocsym(s *LSym) {
return return
} }
var r *Reloc
for ri := 0; ri < len(s.R); ri++ { for ri := 0; ri < len(s.R); ri++ {
r = &s.R[ri] r := &s.R[ri]
if r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT || r.Type >= 256 { if r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT || r.Type >= 256 {
if r.Sym != nil && !r.Sym.Attr.Reachable() { if r.Sym != nil && !r.Sym.Attr.Reachable() {
Diag("internal inconsistency: dynamic symbol %s is not reachable.", r.Sym.Name) Diag("internal inconsistency: dynamic symbol %s is not reachable.", r.Sym.Name)
...@@ -748,7 +745,6 @@ func blk(start *LSym, addr int64, size int64) { ...@@ -748,7 +745,6 @@ func blk(start *LSym, addr int64, size int64) {
} }
eaddr := addr + size eaddr := addr + size
var p []byte
for ; sym != nil; sym = sym.Next { for ; sym != nil; sym = sym.Next {
if sym.Type&obj.SSUB != 0 { if sym.Type&obj.SSUB != 0 {
continue continue
...@@ -766,8 +762,7 @@ func blk(start *LSym, addr int64, size int64) { ...@@ -766,8 +762,7 @@ func blk(start *LSym, addr int64, size int64) {
strnput("", int(sym.Value-addr)) strnput("", int(sym.Value-addr))
addr = sym.Value addr = sym.Value
} }
p = sym.P Cwrite(sym.P)
Cwrite(p)
addr += int64(len(sym.P)) addr += int64(len(sym.P))
if addr < sym.Value+sym.Size { if addr < sym.Value+sym.Size {
strnput("", int(sym.Value+sym.Size-addr)) strnput("", int(sym.Value+sym.Size-addr))
...@@ -874,12 +869,6 @@ func Datblk(addr int64, size int64) { ...@@ -874,12 +869,6 @@ func Datblk(addr int64, size int64) {
} }
eaddr := addr + size eaddr := addr + size
var ep []byte
var i int64
var p []byte
var r *Reloc
var rsname string
var typ string
for ; sym != nil; sym = sym.Next { for ; sym != nil; sym = sym.Next {
if sym.Value >= eaddr { if sym.Value >= eaddr {
break break
...@@ -889,15 +878,12 @@ func Datblk(addr int64, size int64) { ...@@ -889,15 +878,12 @@ func Datblk(addr int64, size int64) {
addr = sym.Value addr = sym.Value
} }
fmt.Fprintf(Bso, "%s\n\t%.8x|", sym.Name, uint(addr)) fmt.Fprintf(Bso, "%s\n\t%.8x|", sym.Name, uint64(addr))
p = sym.P for i, b := range sym.P {
ep = p[len(sym.P):] if i > 0 && i%16 == 0 {
for -cap(p) < -cap(ep) { fmt.Fprintf(Bso, "\n\t%.8x|", uint64(addr)+uint64(i))
if -cap(p) > -cap(sym.P) && (-cap(p)+cap(sym.P))%16 == 0 {
fmt.Fprintf(Bso, "\n\t%.8x|", uint(addr+int64(-cap(p)+cap(sym.P))))
} }
fmt.Fprintf(Bso, " %.2x", p[0]) fmt.Fprintf(Bso, " %.2x", b)
p = p[1:]
} }
addr += int64(len(sym.P)) addr += int64(len(sym.P))
...@@ -906,27 +892,24 @@ func Datblk(addr int64, size int64) { ...@@ -906,27 +892,24 @@ func Datblk(addr int64, size int64) {
} }
fmt.Fprintf(Bso, "\n") fmt.Fprintf(Bso, "\n")
if Linkmode == LinkExternal { if Linkmode != LinkExternal {
for i = 0; i < int64(len(sym.R)); i++ { continue
r = &sym.R[i] }
rsname = "" for _, r := range sym.R {
if r.Sym != nil { rsname := ""
rsname = r.Sym.Name if r.Sym != nil {
} rsname = r.Sym.Name
typ = "?" }
switch r.Type { typ := "?"
case obj.R_ADDR: switch r.Type {
typ = "addr" case obj.R_ADDR:
typ = "addr"
case obj.R_PCREL: case obj.R_PCREL:
typ = "pcrel" typ = "pcrel"
case obj.R_CALL:
case obj.R_CALL: typ = "call"
typ = "call"
}
fmt.Fprintf(Bso, "\treloc %.8x/%d %s %s+%#x [%#x]\n", uint(sym.Value+int64(r.Off)), r.Siz, typ, rsname, r.Add, r.Sym.Value+r.Add)
} }
fmt.Fprintf(Bso, "\treloc %.8x/%d %s %s+%#x [%#x]\n", uint(sym.Value+int64(r.Off)), r.Siz, typ, rsname, r.Add, r.Sym.Value+r.Add)
} }
} }
......
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