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

mlton-script: OpenBSD link-opt for no xonly text #555

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

dancrossnyc
Copy link
Contributor

Add a -target-link-opt for OpenBSD that disables "xonly" text.

OpenBSD's linker, by default, makes a program's text segment executable-only ("xonly"): that is, executable but not readable. However, MLton needs to be able to read the text segment when mapping return addresses to stack frame indices, possibly among other things. This causes programs compiled with MLton's native code generator to fault and die with SIGSEGV.

However, the default "xonly" behavior can be disabled with a linker option (--no-execute-only), so we can turn it off with a -target-link-opt specific to OpenBSD in mlton-script. Binaries built in this configuration run as expected.

Fixes #538

Add a `-target-link-opt` for OpenBSD that disables "xonly" text.

OpenBSD's linker, by default, makes a program's text segment
executable-only ("xonly"): that is, executable but not readable.
However, MLton needs to be able to read the text segment when
mapping return addresses to stack frame indices, possibly among
other things.  This causes programs compiled with MLton's native
code generator to fault and die with `SIGSEGV`.

However, the default "xonly" behavior can be disabled with a
linker option (`--no-execute-only`), so we can turn it off with
a `-target-link-opt` specific to OpenBSD in `mlton-script`.
Binaries built in this configuration run as expected.

Fixes MLton#538

Signed-off-by: Dan Cross <cross@gajendra.net>
@MatthewFluet MatthewFluet merged commit d688f0e into MLton:master Mar 28, 2024
9 checks passed
@dancrossnyc dancrossnyc deleted the openbsd-link-opt branch March 28, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GC dumps core under OpenBSD
2 participants