diff options
| author | 2026-03-19 19:26:08 +0100 | |
|---|---|---|
| committer | 2026-03-19 19:26:08 +0100 | |
| commit | 5d68766b983213a8750d59cc24dc844c6170626b (patch) | |
| tree | ab1b836091103bad19d8949595d28b4924e2ef1f /src/ir.c | |
| parent | 49ba7f066faa6e73e8f09e2e7ed6a077f6ba0258 (diff) | |
ir: do not always try to put small literals in .text
OpenBSD enforces read xor execute (XOM) even in x86-64. Not aware of any
other platforms that do this.
Diffstat (limited to 'src/ir.c')
| -rw-r--r-- | src/ir.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); |