mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00: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_SectRefsDiscardedMemory,
|
||||||
LNK_Error_IllegalSectionMerge,
|
LNK_Error_IllegalSectionMerge,
|
||||||
LNK_Error_IllegalRelocation,
|
LNK_Error_IllegalRelocation,
|
||||||
|
LNK_Error_CircularMerge,
|
||||||
LNK_Error_StopLast,
|
LNK_Error_StopLast,
|
||||||
|
|
||||||
LNK_Error_First,
|
LNK_Error_First,
|
||||||
|
|||||||
@@ -276,6 +276,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?
|
// are we trying to merge section that was already merged?
|
||||||
LNK_Section *merge_sect = 0;
|
LNK_Section *merge_sect = 0;
|
||||||
hash_table_search_string_raw(sectab->sect_ht, merge->src, &merge_sect);
|
hash_table_search_string_raw(sectab->sect_ht, merge->src, &merge_sect);
|
||||||
|
|||||||
Reference in New Issue
Block a user