Skip to content

Commit 95f95f8

Browse files
committed
Ensure that object file section IDs are correct
1 parent edc9e07 commit 95f95f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/asm/output.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ static uint32_t getSectIDIfAny(Section *sect) {
6666
if (!sect)
6767
return UINT32_MAX;
6868

69-
if (auto search = sectionMap.find(sect->name); search != sectionMap.end())
70-
return static_cast<uint32_t>(search->second);
69+
// Search in `sectionList` instead of `sectionMap`, since section fragments share the
70+
// same name but have different IDs
71+
if (auto search =
72+
std::find_if(RANGE(sectionList), [&sect](Section const &s) { return &s == sect; });
73+
search != sectionList.end())
74+
return static_cast<uint32_t>(std::distance(sectionList.begin(), search));
7175

7276
fatalerror("Unknown section '%s'\n", sect->name.c_str());
7377
}

0 commit comments

Comments
 (0)