From caf3e504af18d8329af4d6ce6ed43e314251e01a Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 14 Dec 2025 12:30:20 +0100 Subject: only put dats can in .text now when emitting it --- c/c.c | 4 ++-- ir/dump.c | 4 ++-- ir/ir.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c/c.c b/c/c.c index 4c4868b..d96ea5c 100644 --- a/c/c.c +++ b/c/c.c @@ -4308,8 +4308,8 @@ function(struct comp *cm, struct function *fn, const char **pnames, const struct if (!ifunc) ifunc = intern("__func__"); union type ty = mkarrtype(mktype(TYCHAR), QCONST, strlen(fn->name) + 1); const char *sym = mkhiddensym(fn->name, ifunc, 1); - uint off = objnewdat(sym, Stext, 0, typesize(ty), typealign(ty)); - uchar *p = objout.textbegin + off; + uint off = objnewdat(sym, objout.code ? Stext : Srodata, 0, typesize(ty), typealign(ty)); + uchar *p = objout.code ? objout.textbegin + off : objout.rodata.p + off; memcpy(p, fn->name, typearrlen(ty)-1); putdecl(cm, &(struct decl) { .ty = ty, .qual = QCONST, diff --git a/ir/dump.c b/ir/dump.c index d580a26..a2faf27 100644 --- a/ir/dump.c +++ b/ir/dump.c @@ -9,7 +9,7 @@ static struct wbuf *out = &bstdout; static bool prilitdat(const struct irdat *dat, const char *prefix) { - uchar *p = (dat->section == Sdata ? objout.data.p : objout.rodata.p) + dat->off; + uchar *p = (dat->section == Sdata ? objout.data.p : objout.rodata.p) + dat->off; if (dat->ctype.t == TYARRAY && typechild(dat->ctype).t == TYCHAR && dat->siz-1 < 60 && p[dat->siz-1] == 0) { bfmt(out, "%s%'S", prefix, p, dat->siz-1); } else if (dat->ctype.t == TYFLOAT) { @@ -25,7 +25,7 @@ prilitdat(const struct irdat *dat, const char *prefix) static void pridat(const struct irdat *dat) { - uchar *p = (dat->section == Sdata ? objout.data.p : objout.rodata.p) + dat->off; + uchar *p = (dat->section == Sdata ? objout.data.p : objout.rodata.p) + dat->off; enum { MINZERO = 4, MAXLINE = 60, diff --git a/ir/ir.c b/ir/ir.c index 5bc94aa..13b309d 100644 --- a/ir/ir.c +++ b/ir/ir.c @@ -148,7 +148,7 @@ union ref mkdatref(const char *name, union type ctype, uint siz, uint align, const void *bytes, uint n, bool deref) { struct irdat dat = { .ctype = ctype, .align = align, .siz = siz, .name = name }; - dat.section = align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16 ? Stext : Srodata; + dat.section = objout.code && align >= 4 && align <= targ_primsizes[TYPTR] && siz <= 16 ? Stext : Srodata; assert(n <= siz && siz && align); if (!name) { -- cgit v1.2.3