From 6612f4a32d680e5c5480bc35a7ef7918f79fde10 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Wed, 16 Oct 2024 10:15:06 -0700 Subject: [PATCH] hash image only when we have debug info building --- src/linker/lnk.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/linker/lnk.c b/src/linker/lnk.c index b4e51fa2..c1429a00 100644 --- a/src/linker/lnk.c +++ b/src/linker/lnk.c @@ -4087,20 +4087,24 @@ lnk_run(int argc, char **argv) ProfEnd(); } - switch (config->guid_type) { - case LNK_DebugInfoGuid_Null: break; - case Lnk_DebugInfoGuid_ImageBlake3: { - ProfBegin("Hash Image With Blake3"); - LNK_Symbol *guid_symbol = lnk_symbol_table_searchf(symtab, LNK_SymbolScopeFlag_Internal, LNK_CV_HEADER_GUID_SYMBOL_NAME); - U64 guid_foff = lnk_file_off_from_symbol(sect_id_map, guid_symbol); + LNK_Symbol *guid_symbol = lnk_symbol_table_searchf(symtab, LNK_SymbolScopeFlag_Internal, LNK_CV_HEADER_GUID_SYMBOL_NAME); + if (guid_symbol) { + Assert(build_debug_info); - U128 hash = lnk_blake3_hash_parallel(tp, 128, image_data); + switch (config->guid_type) { + case LNK_DebugInfoGuid_Null: break; + case Lnk_DebugInfoGuid_ImageBlake3: { + ProfBegin("Hash Image With Blake3"); - OS_Guid *guid_ptr = (OS_Guid *)(image_data.str + guid_foff); - MemoryCopy(guid_ptr, hash.u64, sizeof(hash.u64)); + U128 hash = lnk_blake3_hash_parallel(tp, 128, image_data); - ProfEnd(); - } break; + U64 guid_foff = lnk_file_off_from_symbol(sect_id_map, guid_symbol); + OS_Guid *guid_ptr = (OS_Guid *)(image_data.str + guid_foff); + MemoryCopy(guid_ptr, hash.u64, sizeof(hash.u64)); + + ProfEnd(); + } break; + } } LNK_WriteThreadContext *ctx = push_array(scratch.arena, LNK_WriteThreadContext, 1);