From 063a22ddf9c822e3a060e45746175a75c6395cc9 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 16 Dec 2020 11:32:03 -0500 Subject: [PATCH] `LOAD` blocks cannot create a ROM section Fixes #576 --- src/asm/section.c | 3 +++ test/asm/load-rom.asm | 5 +++++ test/asm/load-rom.err | 3 +++ test/asm/load-rom.out | 0 4 files changed, 11 insertions(+) create mode 100644 test/asm/load-rom.asm create mode 100644 test/asm/load-rom.err create mode 100644 test/asm/load-rom.out diff --git a/src/asm/section.c b/src/asm/section.c index 2776efe1..912e96a5 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -339,6 +339,9 @@ void out_SetLoadSection(char const *name, uint32_t type, uint32_t org, if (currentLoadSection) fatalerror("`LOAD` blocks cannot be nested\n"); + if (sect_HasData(type)) + error("`LOAD` blocks cannot create a ROM section\n"); + struct Section *sect = getSection(name, type, org, attribs, false); loadOffset = curOffset; diff --git a/test/asm/load-rom.asm b/test/asm/load-rom.asm new file mode 100644 index 00000000..90445881 --- /dev/null +++ b/test/asm/load-rom.asm @@ -0,0 +1,5 @@ +SECTION "Hello", ROM0 + ld a, 1 +LOAD "Wello", ROM0 + ld a, 2 +ENDL diff --git a/test/asm/load-rom.err b/test/asm/load-rom.err new file mode 100644 index 00000000..32654082 --- /dev/null +++ b/test/asm/load-rom.err @@ -0,0 +1,3 @@ +ERROR: load-rom.asm(3): + `LOAD` blocks cannot create a ROM section +error: Assembly aborted (1 errors)! diff --git a/test/asm/load-rom.out b/test/asm/load-rom.out new file mode 100644 index 00000000..e69de29b