From eea532ded1abcfb71f991fec4468cda51e2a5afd Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Mon, 21 Jul 2025 20:20:04 -0400 Subject: [PATCH] Make `sectionMap` not `extern` --- include/asm/section.hpp | 1 - src/asm/output.cpp | 4 +--- src/asm/section.cpp | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/asm/section.hpp b/include/asm/section.hpp index 52791060..11d9503d 100644 --- a/include/asm/section.hpp +++ b/include/asm/section.hpp @@ -50,7 +50,6 @@ struct SectionSpec { }; extern std::deque
sectionList; -extern std::unordered_map sectionMap; // Indexes into `sectionList` extern Section *currentSection; Section *sect_FindSectionByName(std::string const &name); diff --git a/src/asm/output.cpp b/src/asm/output.cpp index f154a99b..ef9fdcb9 100644 --- a/src/asm/output.cpp +++ b/src/asm/output.cpp @@ -66,15 +66,13 @@ static uint32_t getSectIDIfAny(Section *sect) { return UINT32_MAX; } - // Search in `sectionList` instead of `sectionMap`, since section fragments share the - // same name but have different IDs + // Section fragments share the same name but have different IDs, so search by identity if (auto search = std::find_if(RANGE(sectionList), [§](Section const &s) { return &s == sect; }); search != sectionList.end()) { return static_cast(std::distance(sectionList.begin(), search)); } - // Every section that exists should be in `sectionMap` fatal("Unknown section '%s'", sect->name.c_str()); // LCOV_EXCL_LINE } diff --git a/src/asm/section.cpp b/src/asm/section.cpp index df5013eb..060efb77 100644 --- a/src/asm/section.cpp +++ b/src/asm/section.cpp @@ -38,9 +38,9 @@ struct SectionStackEntry { std::stack unionStack; }; -std::deque
sectionList; -std::unordered_map sectionMap; // Indexes into `sectionList` Section *currentSection = nullptr; +std::deque
sectionList; +static std::unordered_map sectionMap; // Indexes into `sectionList` static uint32_t curOffset; // Offset into the current section (see `sect_GetSymbolOffset`)