]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/objdump: disassemble local text symbols
authorIan Lance Taylor <iant@golang.org>
Wed, 29 Oct 2014 03:25:55 +0000 (23:25 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 29 Oct 2014 03:25:55 +0000 (23:25 -0400)
Fixes #8803.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169720043

src/cmd/objdump/main.go
src/cmd/objdump/objdump_test.go

index aafc501110a82dca7bee7fb38e5ba3fc03bd2770..0f66f20a400131cf34b63559eb3eaa300b5d1c87 100644 (file)
@@ -159,7 +159,7 @@ func dump(tab *gosym.Table, lookup lookupFunc, disasm disasmFunc, goarch string,
 
        printed := false
        for _, sym := range syms {
-               if sym.Code != 'T' || sym.Size == 0 || sym.Name == "_text" || sym.Name == "text" || sym.Addr < textStart || symRE != nil && !symRE.MatchString(sym.Name) {
+               if (sym.Code != 'T' && sym.Code != 't') || sym.Size == 0 || sym.Name == "_text" || sym.Name == "text" || sym.Addr < textStart || symRE != nil && !symRE.MatchString(sym.Name) {
                        continue
                }
                if sym.Addr >= textStart+uint64(len(textData)) || sym.Addr+uint64(sym.Size) > textStart+uint64(len(textData)) {
index 541085626213b47cab00d2f2d3c33d73fad8179d..a9eeea1e0665e300a95bfd81d96a62e4d8ac42cb 100644 (file)
@@ -157,12 +157,15 @@ var armNeed = []string{
 // binary for the current system (only) and test that objdump
 // can handle that one.
 
-func TestDisasm(t *testing.T) {
+func testDisasm(t *testing.T, flags ...string) {
        tmp, exe := buildObjdump(t)
        defer os.RemoveAll(tmp)
 
        hello := filepath.Join(tmp, "hello.exe")
-       out, err := exec.Command("go", "build", "-o", hello, "testdata/fmthello.go").CombinedOutput()
+       args := []string{"build", "-o", hello}
+       args = append(args, flags...)
+       args = append(args, "testdata/fmthello.go")
+       out, err := exec.Command("go", args...).CombinedOutput()
        if err != nil {
                t.Fatalf("go build fmthello.go: %v\n%s", err, out)
        }
@@ -194,3 +197,15 @@ func TestDisasm(t *testing.T) {
                t.Logf("full disassembly:\n%s", text)
        }
 }
+
+func TestDisasm(t *testing.T) {
+       testDisasm(t)
+}
+
+func TestDisasmExtld(t *testing.T) {
+       switch runtime.GOOS {
+       case "windows":
+               t.Skipf("skipping on %s", runtime.GOOS)
+       }
+       testDisasm(t, "-ldflags=-linkmode=external")
+}