[nasm:master] Fix wrong size calculation for "Dx ?" larger than DB
nasm-bot for Marco Bonelli
marco at mebeim.net
Mon Nov 7 17:12:18 PST 2022
Commit-ID: d167b3d4f3dd011bd3e8995ee5f38aa5d646b5ee
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=d167b3d4f3dd011bd3e8995ee5f38aa5d646b5ee
Author: Marco Bonelli <marco at mebeim.net>
AuthorDate: Sat, 20 Nov 2021 23:53:27 +0300
Committer: Cyrill Gorcunov <gorcunov at gmail.com>
CommitDate: Sat, 20 Nov 2021 23:53:40 +0300
Fix wrong size calculation for "Dx ?" larger than DB
The size calculation done in len_extops() (called by insn_size()) for
EOT_DB_RESERVE (i.e. uninitialized storage "?" token) does not take
into account the element size (e->elem), thus calculating a wrong
size for any Dx larger than DB (DW, DQ, etc).
The bug is silent, but it makes NASM error out if a "Dx ?" (larger
than DB) is followed by any label because the label offset gets
mismatched in the final code generation stage:
$ cat test.asm
[section .bss]
DW ?
x:
$ nasm test.asm
test.asm:3: error: label `x' changed during code generation [-w+error=label-redef-late]
See also: https://stackoverflow.com/q/70012188/3889449
Signed-off-by: Marco Bonelli <marco at mebeim.net>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
asm/assemble.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/asm/assemble.c b/asm/assemble.c
index 593045bf..cd3f4693 100644
--- a/asm/assemble.c
+++ b/asm/assemble.c
@@ -1111,7 +1111,7 @@ static int64_t len_extops(const extop *e)
break;
case EOT_DB_RESERVE:
- isize += e->dup;
+ isize += e->dup * e->elem;
break;
}
More information about the Nasm-commits
mailing list