]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/internal/obj: print relocation type by name in -S output
authorCherry Mui <cherryyz@google.com>
Thu, 8 Jun 2023 02:28:20 +0000 (22:28 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 20 Jul 2023 19:42:11 +0000 (19:42 +0000)
The compiler/assembler's -S output prints relocation type
numerically, which is hard to understand. Every time I need to
count the relocation type constants to figure out which relocation
it actually is. Print the symbolic name instead.

Change-Id: I4866873bbae8b3dc0ee212609cb00280f9164243
Reviewed-on: https://go-review.googlesource.com/c/go/+/501856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

src/cmd/internal/obj/objfile.go
test/fixedbugs/issue9355.go

index 0113eddbfd92fe3c4f0da698dd03a25d2635d408..36001b06d7232b9e8eb994382924dedafaa3ac41 100644 (file)
@@ -914,9 +914,9 @@ func (ctxt *Link) writeSymDebugNamed(s *LSym, name string) {
                        name = "TLS"
                }
                if ctxt.Arch.InFamily(sys.ARM, sys.PPC64) {
-                       fmt.Fprintf(ctxt.Bso, "\trel %d+%d t=%d %s%s+%x\n", int(r.Off), r.Siz, r.Type, name, ver, uint64(r.Add))
+                       fmt.Fprintf(ctxt.Bso, "\trel %d+%d t=%v %s%s+%x\n", int(r.Off), r.Siz, r.Type, name, ver, uint64(r.Add))
                } else {
-                       fmt.Fprintf(ctxt.Bso, "\trel %d+%d t=%d %s%s+%d\n", int(r.Off), r.Siz, r.Type, name, ver, r.Add)
+                       fmt.Fprintf(ctxt.Bso, "\trel %d+%d t=%v %s%s+%d\n", int(r.Off), r.Siz, r.Type, name, ver, r.Add)
                }
        }
 }
index 2670f15574731c68306a04e62178226d1d39bb54..075e7ebbffba94045d348f9672c7c15e456000e0 100644 (file)
@@ -32,10 +32,10 @@ func main() {
 
        // 6g/8g print the offset as dec, but 5g/9g print the offset as hex.
        patterns := []string{
-               `rel 0\+\d t=1 p\.x\+8\r?\n`,       // y = &x.b
-               `rel 0\+\d t=1 p\.x\+(28|1c)\r?\n`, // z = &x.d.q
-               `rel 0\+\d t=1 p\.b\+5\r?\n`,       // c = &b[5]
-               `rel 0\+\d t=1 p\.x\+(88|58)\r?\n`, // w = &x.f[3].r
+               `rel 0\+\d t=R_ADDR p\.x\+8\r?\n`,       // y = &x.b
+               `rel 0\+\d t=R_ADDR p\.x\+(28|1c)\r?\n`, // z = &x.d.q
+               `rel 0\+\d t=R_ADDR p\.b\+5\r?\n`,       // c = &b[5]
+               `rel 0\+\d t=R_ADDR p\.x\+(88|58)\r?\n`, // w = &x.f[3].r
        }
        for _, p := range patterns {
                if ok, err := regexp.Match(p, out); !ok || err != nil {