mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-26 21:44:59 -07:00
guard against circular section merges
This commit is contained in:
committed by
Ryan Fleury
parent
2e531cd70a
commit
c2b3634e7a
@@ -36,6 +36,7 @@ typedef enum
|
||||
LNK_Error_SectRefsDiscardedMemory,
|
||||
LNK_Error_IllegalSectionMerge,
|
||||
LNK_Error_IllegalRelocation,
|
||||
LNK_Error_CircularMerge,
|
||||
LNK_Error_StopLast,
|
||||
|
||||
LNK_Error_First,
|
||||
|
||||
@@ -275,6 +275,19 @@ lnk_section_table_merge(LNK_SectionTable *sectab, LNK_MergeDirectiveList merge_l
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// guard against circular merges
|
||||
{
|
||||
if (str8_match(merge_node->data.dst, merge_node->data.src, 0)) {
|
||||
lnk_error(LNK_Error_CircularMerge, "detected circular /MERGE:%S=%S", merge_node->data.src, merge_node->data.dst);
|
||||
}
|
||||
for (LNK_SectionNode *sect_n = sectab->merge_list.first; sect_n != 0; sect_n = sect_n->next) {
|
||||
if (str8_match(sect_n->data.name, merge_node->data.dst, 0) ||
|
||||
str8_match(sect_n->data.name, merge_node->data.src, 0)) {
|
||||
lnk_error(LNK_Error_CircularMerge, "detected circular /MERGE:%S=%S", merge_node->data.src, merge_node->data.dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// are we trying to merge section that was already merged?
|
||||
LNK_Section *merge_sect = 0;
|
||||
|
||||
Reference in New Issue
Block a user