aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/objdump/objdump_test.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-10-15 18:04:08 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-16 14:40:50 +0000
commit20819440fc65d28fabe8f7410ea8fe193cdc53c6 (patch)
tree5931d686fceff113e541b5214a664db7bce708ae /src/cmd/objdump/objdump_test.go
parent771f5f2e487db4eb2bcf6fa1660dc8cef1feaf14 (diff)
downloadgo-20819440fc65d28fabe8f7410ea8fe193cdc53c6.tar.xz
cmd/internal/objfile: correct file table reading for Go object file
Apparently I never actually understood the new file table in Go object files. The PC value stream actually encodes the file index in the per-CU table. I thought it was indexing into a per-function table, which then contains index to the per-CU table. Remove the extra indirection. Change-Id: I0aea5629f7b3888ebe3a04fea437aa15ce89519e Reviewed-on: https://go-review.googlesource.com/c/go/+/262779 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/cmd/objdump/objdump_test.go')
-rw-r--r--src/cmd/objdump/objdump_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go
index 85d1a2efb0..d136e2e6c3 100644
--- a/src/cmd/objdump/objdump_test.go
+++ b/src/cmd/objdump/objdump_test.go
@@ -333,3 +333,41 @@ func TestDisasmGoobj(t *testing.T) {
t.Logf("full disassembly:\n%s", text)
}
}
+
+func TestGoobjFileNumber(t *testing.T) {
+ // Test that file table in Go object file is parsed correctly.
+ testenv.MustHaveGoBuild(t)
+
+ t.Parallel()
+
+ tmpdir, err := ioutil.TempDir("", "TestGoobjFileNumber")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpdir)
+
+ obj := filepath.Join(tmpdir, "p.a")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", obj)
+ cmd.Dir = filepath.Join("testdata/testfilenum")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("build failed: %v\n%s", err, out)
+ }
+
+ cmd = exec.Command(exe, obj)
+ out, err = cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("objdump failed: %v\n%s", err, out)
+ }
+
+ text := string(out)
+ for _, s := range []string{"a.go", "b.go", "c.go"} {
+ if !strings.Contains(text, s) {
+ t.Errorf("output missing '%s'", s)
+ }
+ }
+
+ if t.Failed() {
+ t.Logf("output:\n%s", text)
+ }
+}