diff options
author | Drew DeVault <sir@cmpwn.com> | 2020-08-10 12:28:48 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2021-03-02 10:00:08 +0100 |
commit | 83c210834197b7ad3208214a4f9d8669134c4a3c (patch) | |
tree | 82b5e49cf07c1f4453819ad9a317480d0cddc328 /parse.c | |
parent | cdee1d81c4c73113eb293bf2ac816bee53047f36 (diff) | |
download | roux-83c210834197b7ad3208214a4f9d8669134c4a3c.tar.gz |
add data $name = section "section" ...
This allows you to explicitly specify the section to emit the data directive for, allowing for sections other than .data: for example, .bss or .init_array.
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/parse.c b/parse.c index b279ff4..48f2f6e 100644 --- a/parse.c +++ b/parse.c @@ -41,6 +41,7 @@ enum { Tfunc, Ttype, Tdata, + Tsection, Talign, Tl, Tw, @@ -90,6 +91,7 @@ static char *kwmap[Ntok] = { [Tfunc] = "function", [Ttype] = "type", [Tdata] = "data", + [Tsection] = "section", [Talign] = "align", [Tl] = "l", [Tw] = "w", @@ -984,29 +986,36 @@ parsedatstr(Dat *d) static void parsedat(void cb(Dat *), int export) { - char s[NString]; + char name[NString] = {0}; int t; Dat d; - d.type = DStart; - d.isstr = 0; - d.isref = 0; - d.export = export; - cb(&d); if (nextnl() != Tglo || nextnl() != Teq) err("data name, then = expected"); - strcpy(s, tokval.str); + strncpy(name, tokval.str, NString-1); t = nextnl(); + d.u.str = 0; + if (t == Tsection) { + if (nextnl() != Tstr) + err("section \"name\" expected"); + d.u.str = tokval.str; + t = nextnl(); + } + d.type = DStart; + cb(&d); if (t == Talign) { if (nextnl() != Tint) err("alignment expected"); d.type = DAlign; d.u.num = tokval.num; + d.isstr = 0; + d.isref = 0; cb(&d); t = nextnl(); } d.type = DName; - d.u.str = s; + d.u.str = name; + d.export = export; cb(&d); if (t != Tlbrace) @@ -1025,8 +1034,8 @@ parsedat(void cb(Dat *), int export) } t = nextnl(); do { - d.isref = 0; d.isstr = 0; + d.isref = 0; memset(&d.u, 0, sizeof d.u); if (t == Tflts) d.u.flts = tokval.flts; |