From: Cyrill G. <gor...@gm...> - 2011-05-23 19:55:49
|
On 05/22/2011 09:07 PM, H. Peter Anvin wrote: > On 05/22/2011 07:10 AM, Cyrill Gorcunov wrote: >> >> Well, indeed we better should have there expression evaluator called, this would allow us >> to write say >> >> align 1+7 >> >> or something like this. I'll take a look, but can;t guarantee i do this that soon :( >> Probably on next week. >> > > Yes, that would definitely be the better option. > > -hpa > OK, this is the patch I have in my queue atm. Please review. I also have some cleanup series for 2.09.xx, hope I manage to merge all this during the week. Cyrill --- From: Cyrill Gorcunov <gor...@gm...> Date: Mon, 23 May 2011 23:50:03 +0400 Subject: [PATCH] nassm.c: Use evaluate for section alignment This allow us to write the whole expressions on section alignments, such as align 0xa+6 or whatever math. Should be a way more convenient than hardnumbers scheme we had. Reported-by: Frank Kotler <fbk...@zy...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- nasm.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/nasm.c b/nasm.c index 36be46e..9baec18 100644 --- a/nasm.c +++ b/nasm.c @@ -1248,10 +1248,22 @@ static void assemble_file(char *fname, StrList **depend_ptr) } break; case D_SECTALIGN: /* [SECTALIGN n] */ - { - if (*value) { - unsigned int align = atoi(value); - if (!is_power2(align)) { + if (*value) { + stdscan_reset(); + stdscan_set(value); + tokval.t_type = TOKEN_INVALID; + e = evaluate(stdscan, NULL, &tokval, NULL, pass2, nasm_error, NULL); + if (e) { + unsigned int align = (unsigned int)e->value; + if ((uint64_t)e->value > 0x7fffffff) { + /* + * FIXME: Please make some sane message here + * ofmt should have some 'check' method which + * would report segment alignment bounds. + */ + nasm_error(ERR_FATAL, + "incorrect segment alignment `%s'", value); + } else if (!is_power2(align)) { nasm_error(ERR_NONFATAL, "segment alignment `%s' is not power of two", value); -- 1.7.5.1 |