-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: unable to execute go binaries on a FreeBSD system with W^X enabled #48112
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
Comments
Addendum: With
not only that,
|
kib@ explained at least part of the issue: It seems |
We can modify our ports system to set However, we cannot seem to be able to produce a go compiler that is PIE. Put differently: we can build packages with go on a system with WX disabled, that will work on a system with WX enabled, but we cannot produce a go compiler that will work on such a system. |
We already set |
Yes, we need
I believe so, yes. I'm not completely familiar with go's linking/tool chain use, but I assume that |
Change https://golang.org/cl/346872 mentions this issue: |
CC @dmgk, FreeBSD's lang/go port maintainer |
with that patch it now works with w^x enabled:
(this means that whenever the bootstrap compiler switches to Go1.18, we could start building lang/go on w^x enabled systems) |
Do we want to backport this, so Go 1.16 and 1.17 will work on newer FreeBSD? Thanks. |
I guess that depends on how often people enable W^X mode. My intuition is not very often, or we'd have seen this before. |
You're right that it's not enabled often at present. Right now it's really "adventurous" users trying it out; I expect we will make a more comprehensive effort within the FreeBSD developer community to find showstoppers (e.g. major runtimes that fail with it enabled, as here), before a broader call for testing and any discussion of defaults. That said, independent of W^X with no |
@ cherrymui Our "quarterly" branch currently has 1.16 and our "latest" branch has 1.17, so i think it would make sense to backport it to both of those. I'll also open an issue to have NT_FREEBSD_FEATURE_CTL note added, as @emaste mentioned in the review for https://golang.org/cl/346872 |
I don't think this qualifies for backporting. https://github.com/golang/go/wiki/MinorReleases |
Aye. |
Any specific blockers on why we cannot have a go compiler that is PIE? Currently, go itself builds fail if set kern.elf64.allow_wx=0. |
I don't know why the Go tools would fail with You should be able to build the Go tools with pie by running something like |
Oh, I see, the problem is the missing If you still have problems on tip, please open a new bug. Thanks. |
Switch to the newer go1.17.9 bootstrap with backported CL346872 [1,2], fixes ports 259709. [1] https://go-review.googlesource.com/c/go/+/346872/ [2] golang/go#48112 PR: 263726 PR: 259709 Approved by: ygy@ (maintainer)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This is the latest version.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I compiled a simple hello world program:
, and tried to run it in a FreeBSD 13 environment with W^X enabled:
What did you expect to see?
What did you see instead?
This also happens if you run any go program:
Data Execution Prevention Windows is supported since go 1.14:
https://golang.org/doc/go1.14#windows "Go binaries on Windows now have DEP (Data Execution Prevention) enabled."
I also don't hear any complaints from OpenBSD people, who have W^X enabled for about 20 years now.
Note that workarounds of marking a binary as
wxneeded
withelfctl(1)
also don't work:Somebody managed to extract that "Note" and link it against their rclone: https://forums.freebsd.org/threads/rclone-not-working-with-w-x.80279/ which allowed them to work around this.
I have not yet been able to reproduce that work-around.
The text was updated successfully, but these errors were encountered: