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
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ClarkGuan
Copy link

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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 21, 2020
@andybons andybons added this to the Unplanned milestone Apr 21, 2020
@andybons
Copy link
Member

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.

@andybons andybons added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 21, 2020
@ClarkGuan
Copy link
Author

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.

@andybons andybons removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 22, 2020
@andybons
Copy link
Member

Got it. Thanks.

@griesemer @rsc

@gopherbot
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants