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/link: when building with buildmode=pie the DF_1_PIE flag should be added to the resulting elf #46747

Closed
GlenPickle opened this issue Jun 14, 2021 · 3 comments
Assignees
Labels
Milestone

Comments

@GlenPickle
Copy link

@GlenPickle GlenPickle commented Jun 14, 2021

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

1.6.2

Does this issue reproduce with the latest release?

Yes

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

Ubuntu 21.04 amd64

go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jawn-smith/.cache/go-build"
GOENV="/home/jawn-smith/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jawn-smith/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jawn-smith/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.16"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.16/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jawn-smith/jira_issues/fr-1133/golang-rewrite/retry/ubuntu-image/go.mod"
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-build3996539644=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Built an executable file with go build --buildmode=pie and ran readelf -d to examine it

What did you expect to see?

The flag DF_1_PIE in the section FLAGS_1

What did you see instead?

Nothing in FLAGS_1

This flag is relevant to how the file command determines the difference between shared objects and position independent executable files as documented here: https://cirosantilli.com/elf-hello-world/df-1-pie.

@ianlancetaylor ianlancetaylor changed the title When building with buildmode=pie the DF_1_PIE flag should be added to the resulting elf cmd/link: when building with buildmode=pie the DF_1_PIE flag should be added to the resulting elf Jun 14, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 14, 2021

Loading

@ianlancetaylor ianlancetaylor added this to the Backlog milestone Jun 14, 2021
@thanm thanm self-assigned this Jun 15, 2021
@thanm
Copy link
Contributor

@thanm thanm commented Jun 15, 2021

I'll take a look.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 15, 2021

Change https://golang.org/cl/328089 mentions this issue: cmd/link: set correct flags in .dynamic for PIE buildmode

Loading

@gopherbot gopherbot closed this in 723f199 Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants