mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 05:18:40 +00:00
guard against merges with resource and base reloc sections
This commit is contained in:
committed by
Ryan Fleury
parent
86fe2ddd38
commit
2c5fb7e7ef
@@ -1306,6 +1306,20 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
}
|
||||
} break;
|
||||
|
||||
case LNK_CmdSwitch_Merge: {
|
||||
if (value_strings.node_count == 1) {
|
||||
LNK_MergeDirective merge = {0};;
|
||||
if (lnk_parse_merge_directive(push_str8_copy(arena, value_strings.first->string), &merge)) {
|
||||
lnk_merge_directive_list_push(arena, &config->merge_list, merge);
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Warning_InvalidMergeDirectiveFormat, obj_path, lib_path, cmd_switch, "invalid merge directive format expected \"/MERGE:FROM=TO\" but got \"%S\"",
|
||||
value_strings.first->string);
|
||||
}
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "invalid number of parameters %d", value_strings.node_count);
|
||||
}
|
||||
} break;
|
||||
|
||||
case LNK_CmdSwitch_Natvis: {
|
||||
// warn about invalid natvis extension
|
||||
for (String8Node *node = value_strings.first; node != 0; node = node->next) {
|
||||
|
||||
@@ -34,6 +34,7 @@ typedef enum
|
||||
LNK_Error_InvalidPath,
|
||||
LNK_Error_MultiplyDefinedSymbol,
|
||||
LNK_Error_SectRefsDiscardedMemory,
|
||||
LNK_Error_IllegalSectionMerge,
|
||||
LNK_Error_StopLast,
|
||||
|
||||
LNK_Error_First,
|
||||
@@ -54,6 +55,7 @@ typedef enum
|
||||
LNK_Error_Last,
|
||||
|
||||
LNK_Warning_First,
|
||||
LNK_Warning_InvalidMergeDirectiveFormat,
|
||||
LNK_Warning_AmbiguousMerge,
|
||||
LNK_Warning_AtypicalStartIndex,
|
||||
LNK_Warning_Cmdl,
|
||||
|
||||
@@ -240,9 +240,26 @@ lnk_section_table_merge(LNK_SectionTable *sectab, LNK_MergeDirectiveList merge_l
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
LNK_Section **src_dst = push_array(scratch.arena, LNK_Section *, sectab->id_max);
|
||||
for (LNK_MergeDirectiveNode *merge_node = merge_list.first; merge_node != 0; merge_node = merge_node->next) {
|
||||
LNK_MergeDirective *merge = &merge_node->data;
|
||||
|
||||
// guard against illegal merges
|
||||
{
|
||||
local_persist String8 illegal_merge_sections[] = {
|
||||
str8_lit_comp(".rsrc"),
|
||||
str8_lit_comp(".reloc"),
|
||||
};
|
||||
for (U64 i = 0; i < ArrayCount(illegal_merge_sections); i += 1) {
|
||||
if (str8_match(merge->src, illegal_merge_sections[i], 0)) {
|
||||
lnk_error(LNK_Error_IllegalSectionMerge, "illegal to merge %S with %S", illegal_merge_sections[i], merge->dst);
|
||||
}
|
||||
if (str8_match(merge->dst, illegal_merge_sections[i], 0)) {
|
||||
lnk_error(LNK_Error_IllegalSectionMerge, "illegal to merge %S with %S", merge->src, illegal_merge_sections[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// are we trying to merge section that was already merged?
|
||||
LNK_Section *merge_sect = 0;
|
||||
|
||||
Reference in New Issue
Block a user