aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir.c')
-rw-r--r--src/ir.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ir.c b/src/ir.c
index b7dbb2b..ce36e64 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -159,12 +159,21 @@ mksymref(internstr s, enum symflags symflags)
return newxcon(&con);
}
+static bool
+textdataok(void)
+{
+ /* openbsd enforces R^X for .text */
+ return target.os != OSopenbsd;
+}
+
Ref
mkdatref(internstr name, Type ctype, uint siz, uint align,
const void *bytes, uint n, bool deref, bool funclocal)
{
IRDat dat = { .ctype = ctype, .align = align, .siz = siz, .name = name, .section = Srodata };
- if (funclocal && objout.code && align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16)
+
+ if (funclocal && textdataok() && objout.code
+ && align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16)
dat.section = Stext;
assert(n <= siz && siz && align);