Skip to content

Unable to access function arguments and local variables for linkshared binary #44982

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

Closed
ManojKumarChauhan opened this issue Mar 13, 2021 · 1 comment

Comments

@ManojKumarChauhan
Copy link

ManojKumarChauhan commented Mar 13, 2021

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

$ go version
1.15

Does this issue reproduce with the latest release?

Yes with every version of go

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build531678036=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Using dyninst, I tried to access local variables and arguments of a function which is part of a go binary compiled with linkshared option. To get local variables, dyninst uses libdw library to find all the modules. It uses dwarf_nextcu function of libdw to find all the modules of binary.
When I compile a go binary using "go build filename.go" then dwarf_nextcu finds all the modules (almost 118) and dyninst is able to access local variables and arguments of any function.
But when I compile a go binary with linkshared option "go build -linkshared filename.go" then dwarf_nextcu finds only 5 modules. Due to that, dyninst is not able to access any variable of a function.

When I contact libdw team, they checked the symbols of both the binaries and gave a response.

//go binary without linkshared
$ eu-readelf --debug-dump=info wrapecho.txt | grep producer | sort | uniq -c
1 producer (string) "GNU AS 2.25"
147 producer (string) "Go cmd/compile go1.15.1"
2 producer (strp) "GNU C11 6.5.0 20181026"
16 producer (strp) "GNU C 4.9.2"

//go binry with linkshared
$ eu-readelf --debug-dump=info wrapecho_linkshared.txt | grep producer | sort | uniq -c
1 producer (string) "GNU AS 2.26.1"
18 producer (strp) "GNU C11 6.5.0 20181026"

Response from libdw team:
"So the information you want to extract from them is simply not there for the Go compiler generated functions. This is probably a bug you should produce to the Go language team or Ubuntu (if it is specific to their packaging)."

Is this a bug in go or there is any other way to read the symbols.

What did you expect to see?

I should be able to access variables of a function of go linkshared binary

What did you see instead?

Could not access variable of a function.

@cherrymui
Copy link
Member

I believe currently debug info generation is not enabled for shared libraries. See #38378. I think we can close this and combine it into that issue. Thanks.

@golang golang locked and limited conversation to collaborators Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants