From 95f95f80cddefb1463ee093d4f42cc33f3e188db Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 8 Jan 2025 21:46:32 -0500 Subject: [PATCH] Ensure that object file section IDs are correct --- src/asm/output.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/asm/output.cpp b/src/asm/output.cpp index 57c359e21..800b1b24c 100644 --- a/src/asm/output.cpp +++ b/src/asm/output.cpp @@ -66,8 +66,12 @@ static uint32_t getSectIDIfAny(Section *sect) { if (!sect) return UINT32_MAX; - if (auto search = sectionMap.find(sect->name); search != sectionMap.end()) - return static_cast(search->second); + // Search in `sectionList` instead of `sectionMap`, since section fragments share the + // same name but have different IDs + 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)); fatalerror("Unknown section '%s'\n", sect->name.c_str()); }