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

cmd/go: add --as-needed and --no-as-needed to the linker flags whitelist #23743

Closed
dmitris opened this issue Feb 8, 2018 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@dmitris
Copy link
Contributor

dmitris commented Feb 8, 2018

Please answer these questions before submitting your issue. Thanks!

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

go1.9.4

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dsavints/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build379375121=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

build github.com/miekg/pkcs11 package

$ go get github.com/miekg/pkcs11
go build github.com/miekg/pkcs11: invalid flag in #cgo LDFLAGS: -Wl,--no-as-needed

caused by #23672 and link flag whitelist on https://github.com/golang/go/blob/master/src/cmd/go/internal/work/security.go#L88-L89 missing -Wl,--no-as-needed. Suggested fix - add -Wl,--(no)?-as-needed to the whitelist (will send a PR shortly). See also miekg/pkcs11#63 and miekg/pkcs11#66.

About --as-needed and --no-as-needed flags, see https://sourceware.org/binutils/docs/ld/Options.html

--as-needed
--no-as-needed
This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the command line after the --as-needed option. Normally the linker will add a DT_NEEDED tag for each dynamic library mentioned on the command line, regardless of whether the library is actually needed or not. --as-needed causes a DT_NEEDED tag to only be emitted for a library that at that point in the link satisfies a non-weak undefined symbol reference from a regular object file or, if the library is not found in the DT_NEEDED lists of other needed libraries, a non-weak undefined symbol reference from another needed dynamic library. Object files or libraries appearing on the command line after the library in question do not affect whether the library is seen as needed. This is similar to the rules for extraction of object files from archives. --no-as-needed restores the default behaviour.

@gopherbot
Copy link

Change https://golang.org/cl/92795 mentions this issue: cmd/go: add --as-needed and --no-as-needed to allowed linker flags

@tklauser tklauser changed the title add --as-needed and --no-as-needed to the linker flags whitelist cmd/go: add --as-needed and --no-as-needed to the linker flags whitelist Feb 8, 2018
@tklauser tklauser added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 8, 2018
@ianlancetaylor
Copy link
Contributor

Closing in favor of a general issue for all whitelist changes in #23749.

@golang golang locked and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

4 participants