From 9dcbf460ff692c049e4d327afcbdbc39ba4e8c65 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 3 Sep 2025 19:08:05 +0200 Subject: Validate that memory access is done via variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The address sanitizer is now able to detect whenever in an instruction a memory access is done without using variables. This is now detected for all instructions except for branching, which falls outside of this scope. Moreover, simple arithmetics is allowed and bounds are checked for simple cases. That being said, more involved bound checks should be done with other tools (e.g. emulators). Signed-off-by: Miquel Sabaté Solà --- tests/bare_accesses.s | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/bare_accesses.s (limited to 'tests/bare_accesses.s') diff --git a/tests/bare_accesses.s b/tests/bare_accesses.s new file mode 100644 index 0000000..42a6409 --- /dev/null +++ b/tests/bare_accesses.s @@ -0,0 +1,37 @@ +.segment "HEADER" + .byte 'N', 'E', 'S', $1A + .byte $02 + .byte $01 + .byte $00 + .byte $00 + +.segment "CODE" + +.scope Scope + zp_valid = $02 + + .scope Inner + zp_valid_too = $03 + .endscope +.endscope + +zp_used = $00 ; asan:reserve $02 +whatever = $01 + +lda zp_used +lda $00 +lda whatever +lda Scope::zp_valid +lda Scope::Inner::zp_valid_too +lda zp_used + 1 +lda zp_used + 2 +lda zp_used - 1 + +@something: + beq @something + +ldx #0 +lda palettes, x + +palettes: + .byte $0F -- cgit v1.2.3