Skip to content

Commit

Permalink
Ensure that object file section IDs are correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Jan 17, 2025
1 parent edc9e07 commit 95f95f8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/asm/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(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), [&sect](Section const &s) { return &s == sect; });
search != sectionList.end())
return static_cast<uint32_t>(std::distance(sectionList.begin(), search));

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

0 comments on commit 95f95f8

Please sign in to comment.