diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-10-01 10:08:57 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-10-01 10:08:57 -0700 |
commit | 75e30d2faa3480ae8810856d6527089ba88346a5 (patch) | |
tree | b7a4f345b5ae7c2be97f333acac36c6ca7ea6399 /subx | |
parent | 9527eda90cfd99faccb859458d93a5effa2303b8 (diff) | |
download | mu-75e30d2faa3480ae8810856d6527089ba88346a5.tar.gz |
4633
Detect overlapping segments when loading SubX source code. This will start to become more of a risk as we start loading multiple files, juggling multiple segments, etc.
Diffstat (limited to 'subx')
-rw-r--r-- | subx/011run.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/subx/011run.cc b/subx/011run.cc index c4bf9fe8..f210f141 100644 --- a/subx/011run.cc +++ b/subx/011run.cc @@ -217,11 +217,13 @@ void load(const program& p) { raise << "no code to run\n" << end(); return; } + // You should keep your segments disjoint. + // Tests sometimes don't, but it should still be an error to use the + // overlapping regions. + set<uint32_t> overlap; for (int i = 0; i < SIZE(p.segments); ++i) { const segment& seg = p.segments.at(i); uint32_t addr = seg.start; - // you should probably keep your segments disjoint - // but tests sometimes don't if (!already_allocated(addr)) Mem.push_back(vma(seg.start)); trace(99, "load") << "loading segment " << i << " from " << HEXWORD << addr << end(); @@ -231,7 +233,9 @@ void load(const program& p) { const word& w = l.words.at(k); uint8_t val = hex_byte(w.data); if (trace_contains_errors()) return; + assert(overlap.find(addr) == overlap.end()); write_mem_u8(addr, val); + overlap.insert(addr); trace(99, "load") << "0x" << HEXWORD << addr << " -> " << HEXBYTE << NUM(read_mem_u8(addr)) << end(); ++addr; } |