skip linker info sections during relocation patching, also log a message

when encountering an unsupported machine type
This commit is contained in:
Nikita Smith
2025-09-16 10:31:01 -07:00
committed by Ryan Fleury
parent 488849792c
commit 3224c5e0aa
3 changed files with 13 additions and 4 deletions
+6 -4
View File
@@ -2830,9 +2830,9 @@ THREAD_POOL_TASK_FUNC(lnk_obj_reloc_patcher)
LNK_Obj *obj = task->objs[task_id];
COFF_FileHeaderInfo obj_header = obj->header;
COFF_SectionHeader *section_table = (COFF_SectionHeader *)str8_substr(obj->data, obj_header.section_table_range).str;
String8 symbol_table = str8_substr(obj->data, obj_header.symbol_table_range);
String8 string_table = str8_substr(obj->data, obj_header.string_table_range);
COFF_SectionHeader *section_table = lnk_coff_section_table_from_obj(obj);
String8 symbol_table = lnk_coff_symbol_table_from_obj(obj);
String8 string_table = lnk_coff_string_table_from_obj(obj);
U32 closest_sect = 0;
U32 closest_reloc = 0;
@@ -2841,6 +2841,7 @@ THREAD_POOL_TASK_FUNC(lnk_obj_reloc_patcher)
for EachIndex(sect_idx, obj_header.section_count_no_null) {
COFF_SectionHeader *section_header = &section_table[sect_idx];
if (section_header->flags & COFF_SectionFlag_LnkInfo) { continue; }
if (section_header->flags & COFF_SectionFlag_LnkRemove) { continue; }
if (section_header->flags & COFF_SectionFlag_CntUninitializedData) { continue; }
@@ -2860,7 +2861,8 @@ THREAD_POOL_TASK_FUNC(lnk_obj_reloc_patcher)
lnk_error_obj(LNK_Error_IllegalRelocation, obj, "unknown relocation type 0x%x", reloc->type);
}
} else if (obj->header.machine != COFF_MachineType_Unknown) {
NotImplemented;
lnk_not_implemented("relocation patching is not implemented for %S", coff_string_from_machine_type(obj->header.machine));
continue;
}
// compute virtual offsets
+6
View File
@@ -527,6 +527,12 @@ lnk_coff_string_table_from_obj(LNK_Obj *obj)
return str8_substr(obj->data, obj->header.string_table_range);
}
internal String8
lnk_coff_symbol_table_from_obj(LNK_Obj *obj)
{
return str8_substr(obj->data, obj->header.symbol_table_range);
}
internal COFF_RelocArray
lnk_coff_reloc_info_from_section_number(LNK_Obj *obj, U64 section_number)
{
+1
View File
@@ -119,6 +119,7 @@ internal COFF_SectionHeader * lnk_coff_section_header_from_section_number(LNK_Ob
internal COFF_RelocArray lnk_coff_relocs_from_section_header(LNK_Obj *obj, COFF_SectionHeader *section_header);
internal COFF_SectionHeader * lnk_coff_section_table_from_obj(LNK_Obj *obj);
internal String8 lnk_coff_string_table_from_obj(LNK_Obj *obj);
internal String8 lnk_coff_symbol_table_from_obj(LNK_Obj *obj);
internal B32 lnk_try_comdat_props_from_section_number(LNK_Obj *obj, U32 section_number, COFF_ComdatSelectType *select_out, U32 *section_number_out, U32 *section_length_out, U32 *check_sum_out);
internal B32 lnk_is_coff_section_debug(LNK_Obj *obj, U64 sect_idx);