summaryrefslogtreecommitdiff
path: root/nasm.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2011-05-23 23:50:03 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2011-06-25 12:05:51 +0400
commit9fde335005c43ccd3309d33ce85a38fc16d3c0cb (patch)
tree6f82e5d7323f790a74826de34f9c0da9e201806f /nasm.c
parentcb00cd1ba7f07f60f0a94c43cfc4fa7b01e2ff95 (diff)
downloadnasm-9fde335005c43ccd3309d33ce85a38fc16d3c0cb.tar.gz
nasm-9fde335005c43ccd3309d33ce85a38fc16d3c0cb.tar.bz2
nasm-9fde335005c43ccd3309d33ce85a38fc16d3c0cb.zip
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>
Diffstat (limited to 'nasm.c')
-rw-r--r--nasm.c20
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);