diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-04-21 13:07:22 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-04-22 15:14:44 +0000 |
commit | c33b7c75928ada72e52945336562afe4a5493bb4 (patch) | |
tree | 2b376687f1ee941df3a79386850094ae1356ebe4 /src/cmd/objdump | |
parent | 245a2f5780ebc956a84964c25804b50f27c2d984 (diff) | |
download | go-c33b7c75928ada72e52945336562afe4a5493bb4.tar.gz go-c33b7c75928ada72e52945336562afe4a5493bb4.zip |
[dev.link] cmd/internal/goobj: add index to symbol name for indexed symbols
With old object files, when objdump an object file which, for
example, contains a call of fmt.Fprintf, it shows a symbol
reference like
R_CALL:fmt.Fprintf
With new object files, as the symbol reference is indexed, the
reference becomes
R_CALL:fmt.#33
The object file does not contain information of what symbol #33
in the fmt package is.
To make this more useful, print the index when dumping the symbol
definitions. This way, when dumping the fmt package, e.g.
"go tool nm fmt.a", it will print
6c705 T fmt.Fprintf#33
So we can find out what symbol #33 actually is.
Change-Id: I320776597d28615ce18dd0617c352d2b8180db49
Reviewed-on: https://go-review.googlesource.com/c/go/+/229246
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/cmd/objdump')
-rw-r--r-- | src/cmd/objdump/objdump_test.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go index c974d6707b..814cbf4564 100644 --- a/src/cmd/objdump/objdump_test.go +++ b/src/cmd/objdump/objdump_test.go @@ -14,6 +14,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "runtime" "strings" "testing" @@ -284,9 +285,11 @@ func TestDisasmGoobj(t *testing.T) { if err != nil { t.Fatalf("go tool compile fmthello.go: %v\n%s", err, out) } + + // TODO(go115newobj): drop old object file support. need := []string{ - "main(SB)", - "fmthello.go:6", + `main(#\d+)?\(SB\)`, // either new or old object file + `fmthello\.go:6`, } args = []string{ @@ -302,8 +305,9 @@ func TestDisasmGoobj(t *testing.T) { text := string(out) ok := true for _, s := range need { - if !strings.Contains(text, s) { - t.Errorf("disassembly missing '%s'", s) + re := regexp.MustCompile(s) + if !re.MatchString(text) { + t.Errorf("disassembly missing %q", s) ok = false } } |