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 <fbkotler@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2011-05-23 23:50:03 +04:00
parent cb00cd1ba7
commit 9fde335005

20
nasm.c
View File

@ -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);