aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2025-12-15 22:15:09 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2025-12-15 22:15:09 +0100
commitec935330d4518829d01bbdf5670c4569fa07a567 (patch)
tree2ee487e1796d461b296e61791b7fdff43b14529d /tests
parentb7645c842f6c3fd718debe8de3e32ae346b17567 (diff)
downloadtools.nes-ec935330d4518829d01bbdf5670c4569fa07a567.tar.gz
tools.nes-ec935330d4518829d01bbdf5670c4569fa07a567.zip
Allow constants in asan:reserve statements
This way, if you define a constant like: MY_BUFFER_LEN_IN_BYTES = $10 You can then declare your buffer like so: zp_buffer = $00 ; asan:reserve MY_BUFFER_LEN_IN_BYTES And then further in the code you can rely on just using the constant for bound checking, and then the address sanitizer will check on bound checks via static analysis as well. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/asan_reserve_constant.s20
-rw-r--r--tests/expected/asan_reserve_constant.txt1
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/asan_reserve_constant.s b/tests/asan_reserve_constant.s
new file mode 100644
index 0000000..8af9cad
--- /dev/null
+++ b/tests/asan_reserve_constant.s
@@ -0,0 +1,20 @@
+.segment "HEADER"
+ .byte 'N', 'E', 'S', $1A
+ .byte $02
+ .byte $01
+ .byte $00
+ .byte $00
+
+.segment "CODE"
+
+CONST = $02
+
+zp_var = $00 ; asan:reserve CONST
+zp_another = $01
+zp_yet_another = $02
+zp_and_yet = $03
+
+lda zp_var
+lda zp_another
+lda zp_yet_another
+lda zp_and_yet
diff --git a/tests/expected/asan_reserve_constant.txt b/tests/expected/asan_reserve_constant.txt
new file mode 100644
index 0000000..e08f84f
--- /dev/null
+++ b/tests/expected/asan_reserve_constant.txt
@@ -0,0 +1 @@
+error: The variable 'zp_another' ($01) conflicts with 'zp_var' ($00-$01) (asan_reserve_constant.s)