Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug/macho: no SymtabCmd data in *macho.Symtab Load after calling macho.Open() #38556

Open
ClarkGuan opened this issue Apr 21, 2020 · 4 comments
Open

Comments

@ClarkGuan
Copy link

@ClarkGuan ClarkGuan commented Apr 21, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/didi/Library/Caches/go-build"
GOENV="/Users/didi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/didi/dev/source/golang/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n5/26_m50tn4_j2n3gmvt19300h0000gn/T/go-build965858086=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

file, _ := macho.Open("xxx.o")    // which has Mach-O format with MH_OBJECT type
for i, l := range file.Loads {
    switch lo := l.(type) {
        case *macho.Symtab:
            fmt.Println(lo.SymtabCmd)    // nothing but zero value
    }
}

What did you expect to see?

Non-zero value of lo.SymtabCmd.

What did you see instead?

Zero value of lo.SymtabCmd.

Possible causes

parseSymtab() function in debug/macho/file.go:

        ...
	st := new(Symtab)
	st.LoadBytes = LoadBytes(cmddat)
	st.Syms = symtab
	return st, nil
}

ignore st.SymtabCmd ? It cound be:

        ...
	st := new(Symtab)
	st.LoadBytes = LoadBytes(cmddat)
	st.Syms = symtab
        st.SymtabCmd = *hdr
	return st, nil
}
@andybons andybons changed the title no SymtabCmd data in *macho.Symtab Load after calling macho.Open() debug/macho: no SymtabCmd data in *macho.Symtab Load after calling macho.Open() Apr 21, 2020
@andybons andybons added this to the Unplanned milestone Apr 21, 2020
@andybons
Copy link
Member

@andybons andybons commented Apr 21, 2020

Does this issue reproduce with the latest release?
No.

I’m confused. Are you saying this doesn‘t reproduce on tip? 1.14.2 is the latest release.

Loading

@ClarkGuan
Copy link
Author

@ClarkGuan ClarkGuan commented Apr 22, 2020

Does this issue reproduce with the latest release?
No.

I’m confused. Are you saying this doesn‘t reproduce on tip? 1.14.2 is the latest release.

Sorry, wrong input... I mean I can reproduce with the latest release.

Loading

@andybons
Copy link
Member

@andybons andybons commented Apr 22, 2020

Got it. Thanks.

@griesemer @rsc

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 7, 2020

Change https://golang.org/cl/241237 mentions this issue: debug/macho: add SymtabCmd data to *macho.Symtab in parseSymtab

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants