-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/compile: support -buildmode=pie on OpenBSD #59866
Comments
(attn @golang/openbsd) |
Around 2020-02-01 I started working on PIE mode for Go amd64. Here is the diff. I got everything working:
However, about 50% of the time binaries produced with it die with a SIGSEGV. Interestingly it works fine on single CPU machines. |
Awesome! Your patch allows/fixes the necessary flags as it seems. Does the patch work against 1.20.1 that is currently in ports? Did you try with 7.3 yet? mmap/mprotect was SMP unlocked. |
I haven't updated the patch to work with newer Go versions. |
Is there more information somewhere? Why was PIE disabled in the first place? There must be a reason? The patch definitely needs some work and I doubt that enabling the flags will just make everything work. |
I think I found the origin in #17847 But could DT_TEXTREL really be the issue here? OpenBSD builds PIE by default and Go does call the external linker on OpenBSD. Maybe this was just collateral damage? |
Indeed it did with with enabling the flags .. just inconsistently on MP machines. The bins were PIE and ran as expected on single proc machines. I can't speak to why it was disabled in the first place. |
Also running into this issue |
The PIE buildmode works correctly on openbsd/arm64, hence enable it. Updates #59866 Change-Id: I2f3c2839893659391539fafa12891d64f867e189 Reviewed-on: https://go-review.googlesource.com/c/go/+/570375 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Joel Sing <joel@sing.id.au>
Change https://go.dev/cl/570375 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I think so.
What operating system and processor architecture are you using (
go env
)?OpenBSD 7.3 on amd64
What did you do?
I tried to build a PIE binary with -buildmode=pie
What did you expect to see?
I was expecting to build a binary with PIE enabled.
What did you see instead?
Is there any particular reason that buildmode=pie is not supported on openbsd? Building with that buildmode returns that the buildmode=pie is not supported.
clang on OpenBSD/amd64 defaults and produces PIE static/dynamic binaries without issue. But even external linking in Go suppresses PIE with LDFlags -Wl,-nopie. You can append -Wl,-pie through -extldflags option, the result will be expectedly an invalid function entry symbol table or a segmentation fault.
I could not find an open issue that works on this or explains the situation for the missing support. There are some that are years old and closed or some old mailing list entries. I get that openbsd is a secondary port, but why is there not even an issue that addresses the state/progress and situation?
I'm just genuinely interested to see progress at this.
Thank you.
The text was updated successfully, but these errors were encountered: