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

cmd/cgo: mark cgo generated wrappers hidden #28340

Open
eliasnaur opened this Issue Oct 23, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@eliasnaur
Contributor

eliasnaur commented Oct 23, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version devel +c2a8d5972f Sat Sep 22 10:58:54 2018 +0200 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/elias/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/elias/dev/go"
GOPROXY=""
GORACE=""
GOROOT="/home/elias/dev/go-release"
GOTMPDIR=""
GOTOOLDIR="/home/elias/dev/go-release/pkg/tool/linux_amd64"
GCCGO="gccgo"
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-build186016377=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ cat test.go
package main

/*
__attribute__ ((visibility ("hidden"))) void some_c_func() {
}
*/
import "C"

func main() {
	C.some_c_func()
}
$ go build test.go
$ objdump -t test|grep some_c_func

What did you expect to see?

All cgo wrappers for some_c_func marked local.

What did you see instead?

00000000006bd160 l     O .data	0000000000000008              main._cgo_1622f853b35c_Cfunc_some_c_func
000000000044fb20 l     F .text	0000000000000052              main._Cfunc_some_c_func
000000000044fc10 l     F .text	0000000000000001              some_c_func
000000000044fc20 g     F .text	0000000000000001              _cgo_1622f853b35c_Cfunc_some_c_func

The _cgo_1622f853b35c_Cfunc_some_c_func function is global, not local as I would expect. I would expect it to be local even if some_c_func itself is not.

@ianlancetaylor ianlancetaylor changed the title from cgo: mark cgo generated wrappers hidden to cmd/cgo: mark cgo generated wrappers hidden Oct 23, 2018

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment