Skip to content

Commit 5e4ed22

Browse files
fixup symbol tree offsets in module stream
1 parent 5d21603 commit 5e4ed22

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/linker/lnk_debug_info.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,29 +2129,30 @@ THREAD_POOL_TASK_FUNC(lnk_write_pdb_modules)
21292129
U64 pos = 0;
21302130
lnk_write_debug_s_to_pdb_module(mod, debug_s, &buf, &pos);
21312131

2132-
// patch symbol offsets
2133-
//cv_patch_symbol_tree_offsets_new(dummy, sizeof(CV_Signature), PDB_SYMBOL_ALIGN);
2132+
// sub range symbol data pages and patch symbol tree offsets
2133+
String8List mod_symbols = str8_list_substr(temp.arena, mod_pages, r1u64(sizeof(CV_Signature), sizeof(CV_Signature) + mod->sym_data_size));
2134+
cv_patch_symbol_tree_offsets_new(mod_symbols, sizeof(CV_Signature), PDB_SYMBOL_ALIGN);
21342135

21352136
temp_end(temp);
21362137
}
21372138
barrier_wait(tp->barrier);
21382139

2139-
#if 0
2140-
// parse checksum data
2141-
String8List checksum_data = cv_sub_section_from_debug_s(debug_s, CV_C13SubSectionKind_FileChksms);
2142-
CV_ChecksumList checksum_list = cv_c13_parse_checksum_data_list(scratch.arena, checksum_data);
2143-
2144-
// get strings sub-section
2145-
String8 string_data = cv_string_table_from_debug_s(debug_s);
2146-
2147-
// collect source file names from checksum headers
2148-
String8List source_file_names_list = cv_c13_collect_source_file_names(arena, checksum_list, string_data);
2149-
PDB_DbiModule *mod = task->mod_arr[obj_idx];
2150-
str8_list_concat_in_place(&mod->source_file_list, &source_file_names_list);
2151-
2152-
// relocate checksum data
2153-
cv_c13_patch_string_offsets_in_checksum_list(checksum_list, string_data, task->pdb->info->strtab.size, task->string_ht);
2154-
#endif
2140+
for EachIndex(i, obj_indices.count) {
2141+
U64 obj_idx = obj_indices.v[i];
2142+
CV_DebugS debug_s = task->cv->debug_s_arr[obj_idx];
2143+
String8 string_table = cv_string_table_from_debug_s(debug_s);
2144+
String8List file_chksms_raw = cv_sub_section_from_debug_s(debug_s, CV_C13SubSectionKind_FileChksms);
2145+
CV_ChecksumList file_chksms = cv_c13_parse_checksum_data_list(scratch.arena, file_chksms_raw);
2146+
String8List src_file_names = cv_c13_collect_source_file_names(arena, file_chksms, string_table);
2147+
2148+
// collect source files module refs
2149+
str8_list_concat_in_place(&task->mod_arr[obj_idx]->source_file_list, &src_file_names);
2150+
2151+
// patch path offsets in file checksum headers (in obj the offsets point to a string table in .debug$S,
2152+
// and because linker merges string tables the old offsets need to be fixed up)
2153+
cv_c13_patch_string_offsets_in_checksum_list(file_chksms, string_table, task->pdb->info->strtab.size, task->string_ht);
2154+
}
2155+
barrier_wait(tp->barrier);
21552156

21562157
scratch_end(scratch);
21572158
}

0 commit comments

Comments
 (0)