From e936a75e2527d5ee058e70b426ef1e65787c0aa3 Mon Sep 17 00:00:00 2001 From: Yaroslav Veremenko Date: Thu, 26 Aug 2021 23:27:53 -0600 Subject: [PATCH] Address the issue when absolute RAM addresses overlap with relative ROM --- src/wiz/format/debug/mlb_debug_format.cpp | 11 ++++++----- src/wiz/format/debug/mlb_debug_format.h | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/wiz/format/debug/mlb_debug_format.cpp b/src/wiz/format/debug/mlb_debug_format.cpp index 8e75c3d..3ff2229 100644 --- a/src/wiz/format/debug/mlb_debug_format.cpp +++ b/src/wiz/format/debug/mlb_debug_format.cpp @@ -68,7 +68,7 @@ namespace wiz { return ""_sv; } - void dumpAddress(Writer* writer, const Definition* definition, DebugFormatContext& context) { + void dumpAddress(Writer* writer, const Definition* definition, DebugFormatContext& context, MlbAddressOwnership& addressOwnership) { const auto outputContext = context.outputContext; const auto address = definition->getAddress(); @@ -104,11 +104,11 @@ namespace wiz { : startValue; for (std::size_t i = startValue; i <= endValue; i++) { - const auto match = context.addressOwnership.find(i); - if (match != context.addressOwnership.end()) { + const auto match = addressOwnership.find({ i, labelTypes }); + if (match != addressOwnership.end()) { return; } else { - context.addressOwnership[i] = definition; + addressOwnership[{ i, labelTypes }] = definition; } } @@ -149,11 +149,12 @@ namespace wiz { MlbDebugFormat::~MlbDebugFormat() {} bool MlbDebugFormat::generate(DebugFormatContext& context) { + MlbAddressOwnership addressOwnership; const auto debugName = path::stripExtension(context.outputName).toString() + ".mlb"; if (auto writer = context.resourceManager->openWriter(StringView(debugName))) { for (const auto& definition : context.definitions) { - dumpAddress(writer.get(), definition, context); + dumpAddress(writer.get(), definition, context, addressOwnership); } } diff --git a/src/wiz/format/debug/mlb_debug_format.h b/src/wiz/format/debug/mlb_debug_format.h index 051e5c8..ebc5549 100644 --- a/src/wiz/format/debug/mlb_debug_format.h +++ b/src/wiz/format/debug/mlb_debug_format.h @@ -4,6 +4,14 @@ #include namespace wiz { + typedef std::pair OwnershipKey; + struct OwnershipKeyHash { + std::size_t operator() (const OwnershipKey& pair) const { + return std::hash()(pair.first) ^ std::hash()(pair.second); + } + }; + typedef std::unordered_map MlbAddressOwnership; + class MlbDebugFormat : public DebugFormat { public: MlbDebugFormat();