aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/nm
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-04-21 13:07:22 -0400
committerCherry Zhang <cherryyz@google.com>2020-04-22 15:14:44 +0000
commitc33b7c75928ada72e52945336562afe4a5493bb4 (patch)
tree2b376687f1ee941df3a79386850094ae1356ebe4 /src/cmd/nm
parent245a2f5780ebc956a84964c25804b50f27c2d984 (diff)
downloadgo-c33b7c75928ada72e52945336562afe4a5493bb4.tar.xz
[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/nm')
-rw-r--r--src/cmd/nm/nm_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go
index bcfd054150..7dfb482b18 100644
--- a/src/cmd/nm/nm_test.go
+++ b/src/cmd/nm/nm_test.go
@@ -315,7 +315,7 @@ func testGoLib(t *testing.T, iscgo bool) {
}
for i := range syms {
sym := &syms[i]
- if sym.Type == typ && sym.Name == name && sym.CSym == csym {
+ if sym.Type == typ && matchSymName(name, sym.Name) && sym.CSym == csym {
if sym.Found {
t.Fatalf("duplicate symbol %s %s", sym.Type, sym.Name)
}
@@ -334,6 +334,14 @@ func TestGoLib(t *testing.T) {
testGoLib(t, false)
}
+// Check that a symbol has a given name, accepting both
+// new and old objects.
+// TODO(go115newobj): remove.
+func matchSymName(symname, want string) bool {
+ return symname == want ||
+ strings.HasPrefix(symname, want+"#") // new style, with index
+}
+
const testexec = `
package main