mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-08 06:48:41 +00:00
fix DBI SC image-section range mapping
Log and skip section contributions that fail to map into the linked image. Keep a file-range-to-section-number map so compact file ranges produce the correct DBI section numbers.
This commit is contained in:
committed by
Ryan Fleury
parent
541727b819
commit
afd454b41f
+44
-50
@@ -3067,70 +3067,63 @@ THREAD_POOL_TASK_FUNC(lnk_push_dbi_sec_contrib_task)
|
|||||||
PDB_DbiModule *mod = task->mod_arr [obj_idx];
|
PDB_DbiModule *mod = task->mod_arr [obj_idx];
|
||||||
LNK_Obj *obj = task->cv->obj_arr[obj_idx];
|
LNK_Obj *obj = task->cv->obj_arr[obj_idx];
|
||||||
|
|
||||||
PDB_DbiSectionContribNode *sc_arr = push_array_no_zero(arena, PDB_DbiSectionContribNode, obj->header.section_count_no_null);
|
PDB_DbiSCNode *sc_arr = push_array_no_zero(arena, PDB_DbiSCNode, obj->header.section_count_no_null);
|
||||||
U64 sc_count = 0;
|
U64 sc_count = 0;
|
||||||
|
|
||||||
for EachIndex(sect_idx, obj->header.section_count_no_null) {
|
for EachIndex(sect_idx, obj->header.section_count_no_null) {
|
||||||
LNK_ObjSection section = lnk_obj_section_from_sect_idx(obj, sect_idx);
|
|
||||||
|
|
||||||
if (*section.flags & COFF_SectionFlag_LnkInfo) { continue; }
|
// filter by section flags
|
||||||
if (*section.flags & COFF_SectionFlag_LnkRemove) { continue; }
|
if (obj->section_flags[sect_idx] & (COFF_SectionFlag_LnkInfo | COFF_SectionFlag_LnkRemove | LNK_SECTION_FLAG_DEBUG)) { continue; }
|
||||||
if (*section.flags & LNK_SECTION_FLAG_DEBUG) { continue; }
|
|
||||||
|
|
||||||
|
// skip unwind info for the section contribution
|
||||||
String8 section_name = lnk_obj_section_name_from_sect_idx(obj, sect_idx);
|
String8 section_name = lnk_obj_section_name_from_sect_idx(obj, sect_idx);
|
||||||
if (str8_match(section_name, str8_lit(".pdata"), 0)) { continue; }
|
if (str8_match(section_name, str8_lit(".pdata"), 0)) { continue; }
|
||||||
|
|
||||||
U64 sect_number;
|
// load section and determine its type
|
||||||
String8 sect_data;
|
LNK_ObjSection section = lnk_obj_section_from_sect_idx(obj, sect_idx);
|
||||||
U32 sect_off;
|
B32 is_virt = !!(*section.flags & COFF_SectionFlag_CntUninitializedData);
|
||||||
U32 data_crc;
|
|
||||||
if (*section.flags & COFF_SectionFlag_CntUninitializedData) {
|
|
||||||
if (dim_1u64(section.vrange) == 0) { continue; }
|
|
||||||
|
|
||||||
U64 search_result = rng1u64_array_num_from_value__binary_search(&task->image_section_virt_ranges, section.vrange.min);
|
// pick section range
|
||||||
sect_number = search_result-1;
|
Rng1U64 section_range = is_virt ? section.vrange : section.frange;
|
||||||
Assert(sect_number < task->image_section_virt_ranges.count);
|
if (dim_1u64(section_range) == 0) { continue; }
|
||||||
|
|
||||||
sect_data = str8_zero();
|
// map the SC offset to the image section range that contains it
|
||||||
sect_off = section.vrange.min - task->image_section_virt_ranges.v[sect_number].min;
|
Rng1U64Array *image_ranges = is_virt ? &task->image_section_virt_ranges : &task->image_section_file_ranges;
|
||||||
data_crc = 0;
|
U64 search_result = rng1u64_array_num_from_value__binary_search(image_ranges, section_range.min);
|
||||||
} else {
|
|
||||||
if (dim_1u64(section.frange) == 0) { continue; }
|
|
||||||
|
|
||||||
U64 search_result = rng1u64_array_num_from_value__binary_search(&task->image_section_file_ranges, section.frange.min);
|
// log & skip SC offsets that failed to map
|
||||||
sect_number = search_result-1;
|
if (search_result == 0) {
|
||||||
Assert(sect_number < task->image_section_file_ranges.count);
|
Temp scratch = scratch_begin(0,0);
|
||||||
|
lnk_log(LNK_Log_Debug, "%S: failed to map section offset 0x%llx into the linked image; skipping this section", lnk_loc_from_obj(scratch.arena, obj), section_range.min);
|
||||||
sect_data = str8_substr(task->image_data, section.frange);
|
scratch_end(scratch);
|
||||||
sect_off = section.frange.min - task->image_section_file_ranges.v[sect_number].min;
|
continue;
|
||||||
data_crc = update_crc32(0, sect_data.str, sect_data.size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill out SC
|
// unpack image range index
|
||||||
PDB_DbiSectionContribNode *sc = sc_arr + sc_count++;
|
U64 range_idx = search_result - 1;
|
||||||
sc->data.base.sec = (U16)sect_number;
|
|
||||||
|
// fill out & push section contribution
|
||||||
|
PDB_DbiSCNode *sc = sc_arr + sc_count++;
|
||||||
|
sc->data.base.sec = (U16)(is_virt ? range_idx : task->image_section_file_section_numbers[range_idx]);
|
||||||
sc->data.base.pad0 = 0;
|
sc->data.base.pad0 = 0;
|
||||||
sc->data.base.sec_off = sect_off;
|
sc->data.base.sec_off = section_range.min - image_ranges->v[range_idx].min;
|
||||||
sc->data.base.size = dim_1u64(section.vrange);
|
sc->data.base.size = dim_1u64(section_range);
|
||||||
sc->data.base.flags = *section.flags;
|
sc->data.base.flags = *section.flags;
|
||||||
sc->data.base.mod = mod->imod;
|
sc->data.base.mod = mod->imod;
|
||||||
sc->data.base.pad1 = 0;
|
sc->data.base.pad1 = 0;
|
||||||
sc->data.data_crc = 0;
|
sc->data.data_crc = is_virt ? 0 : crc32_from_string(str8_substr(task->image_data, section_range));
|
||||||
sc->data.reloc_crc = 0;
|
sc->data.reloc_crc = 0;
|
||||||
|
|
||||||
dbi_sec_contrib_list_push_node(&task->sc_list[obj_idx], sc);
|
dbi_sec_contrib_list_push_node(&task->sc_list[obj_idx], sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mod1::fUpdateSecContrib
|
// find first code section contribution for the Mod1::fUpdateSecContrib
|
||||||
if (sc_count > 0) {
|
for EachIndex(i, sc_count) {
|
||||||
for (U64 sc_idx = 0; sc_idx < sc_count; ++sc_idx) {
|
if (sc_arr[i].data.base.flags & COFF_SectionFlag_CntCode) {
|
||||||
if (sc_arr[sc_idx].data.base.flags & COFF_SectionFlag_CntCode) {
|
mod->first_sc = sc_arr[i].data;
|
||||||
mod->first_sc = sc_arr[sc_idx].data;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
lnk_build_pdb(TP_Context *tp, TP_Arena *tp_arena, String8 image_data, LNK_Config *config, LNK_SymbolTable *symtab, LNK_CodeViewInput *cv, LNK_MergedTypes cv_types, LNK_PDB_BuilderFlags builder_flags)
|
lnk_build_pdb(TP_Context *tp, TP_Arena *tp_arena, String8 image_data, LNK_Config *config, LNK_SymbolTable *symtab, LNK_CodeViewInput *cv, LNK_MergedTypes cv_types, LNK_PDB_BuilderFlags builder_flags)
|
||||||
@@ -3154,6 +3147,7 @@ lnk_build_pdb(TP_Context *tp, TP_Arena *tp_arena, String8 image_data, LNK_Config
|
|||||||
.image_section_virt_ranges.count = task.image_section_table_count,
|
.image_section_virt_ranges.count = task.image_section_table_count,
|
||||||
.image_section_virt_ranges.v = push_array(scratch.arena, Rng1U64, task.image_section_table_count),
|
.image_section_virt_ranges.v = push_array(scratch.arena, Rng1U64, task.image_section_table_count),
|
||||||
.image_section_file_ranges.v = push_array(scratch.arena, Rng1U64, task.image_section_table_count),
|
.image_section_file_ranges.v = push_array(scratch.arena, Rng1U64, task.image_section_table_count),
|
||||||
|
.image_section_file_section_numbers = push_array(scratch.arena, U64, task.image_section_table_count),
|
||||||
};
|
};
|
||||||
|
|
||||||
// set min type indices
|
// set min type indices
|
||||||
@@ -3185,17 +3179,13 @@ lnk_build_pdb(TP_Context *tp, TP_Arena *tp_arena, String8 image_data, LNK_Config
|
|||||||
|
|
||||||
if (builder_flags & LNK_PDB_BuilderFlag_Modules) {
|
if (builder_flags & LNK_PDB_BuilderFlag_Modules) {
|
||||||
ProfScope ("Alloc Modules")
|
ProfScope ("Alloc Modules")
|
||||||
for EachIndex(obj_idx, cv->obj_count)
|
for EachIndex(obj_idx, cv->obj_count) {
|
||||||
task.mod_arr[obj_idx] = dbi_push_module(task.pdb->dbi, cv->obj_arr[obj_idx]->path, lnk_obj_get_lib_path(cv->obj_arr[obj_idx]));
|
task.mod_arr[obj_idx] = dbi_push_module(task.pdb->dbi, cv->obj_arr[obj_idx]->path, lnk_obj_get_lib_path(cv->obj_arr[obj_idx]));
|
||||||
|
}
|
||||||
|
|
||||||
ProfScope("Move Global Symbols")
|
ProfScope("Move Global Symbols") tp_for_parallel(tp, 0, tp->worker_count, lnk_move_global_symbols_to_gsi, &task);
|
||||||
tp_for_parallel(tp, 0, tp->worker_count, lnk_move_global_symbols_to_gsi, &task);
|
ProfScope("Build GSI and PSI") pdb_build_gsi_psi(tp, task.pdb);
|
||||||
|
ProfScope("Write Modules") tp_for_parallel(tp, 0, tp->worker_count, lnk_write_pdb_modules, &task);
|
||||||
ProfScope("Build GSI and PSI")
|
|
||||||
pdb_build_gsi_psi(tp, task.pdb);
|
|
||||||
|
|
||||||
ProfScope("Write Modules")
|
|
||||||
tp_for_parallel(tp, 0, tp->worker_count, lnk_write_pdb_modules, &task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfBegin("Add string tables");
|
ProfBegin("Add string tables");
|
||||||
@@ -3213,13 +3203,17 @@ lnk_build_pdb(TP_Context *tp, TP_Arena *tp_arena, String8 image_data, LNK_Config
|
|||||||
|
|
||||||
for EachIndex(i, task.image_section_table_count) {
|
for EachIndex(i, task.image_section_table_count) {
|
||||||
COFF_SectionHeader *sect_header = task.image_section_table[i];
|
COFF_SectionHeader *sect_header = task.image_section_table[i];
|
||||||
|
|
||||||
if (~sect_header->flags & COFF_SectionFlag_CntUninitializedData) {
|
if (~sect_header->flags & COFF_SectionFlag_CntUninitializedData) {
|
||||||
task.image_section_file_ranges.v[task.image_section_file_ranges.count++] = rng_1u64(sect_header->foff, sect_header->foff + sect_header->fsize);
|
U64 section_file_idx = task.image_section_file_ranges.count++;
|
||||||
|
task.image_section_file_ranges.v[section_file_idx] = r1u64s(sect_header->foff, sect_header->fsize);
|
||||||
|
task.image_section_file_section_numbers[section_file_idx] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
task.image_section_virt_ranges.v[i] = rng_1u64(sect_header->voff, sect_header->voff + sect_header->vsize);
|
task.image_section_virt_ranges.v[i] = rng_1u64(sect_header->voff, sect_header->voff + sect_header->vsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
task.sc_list = push_array(scratch.arena, PDB_DbiSectionContribList, cv->obj_count);
|
task.sc_list = push_array(scratch.arena, PDB_DbiSCList, cv->obj_count);
|
||||||
tp_for_parallel(tp, tp_arena, cv->obj_count, lnk_push_dbi_sec_contrib_task, &task);
|
tp_for_parallel(tp, tp_arena, cv->obj_count, lnk_push_dbi_sec_contrib_task, &task);
|
||||||
dbi_sec_list_concat_arr(&task.pdb->dbi->sec_contrib_list, cv->obj_count, task.sc_list);
|
dbi_sec_list_concat_arr(&task.pdb->dbi->sec_contrib_list, cv->obj_count, task.sc_list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,9 +218,10 @@ typedef struct
|
|||||||
PE_BinInfo pe;
|
PE_BinInfo pe;
|
||||||
COFF_SectionHeader **image_section_table;
|
COFF_SectionHeader **image_section_table;
|
||||||
U64 image_section_table_count;
|
U64 image_section_table_count;
|
||||||
Rng1U64Array image_section_file_ranges;
|
|
||||||
Rng1U64Array image_section_virt_ranges;
|
Rng1U64Array image_section_virt_ranges;
|
||||||
PDB_DbiSectionContribList *sc_list; // [obj_count]
|
Rng1U64Array image_section_file_ranges;
|
||||||
|
U64 *image_section_file_section_numbers;
|
||||||
|
PDB_DbiSCList *sc_list; // [obj_count]
|
||||||
} LNK_BuildPdb;
|
} LNK_BuildPdb;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@@ -2263,24 +2263,24 @@ psi_push(PDB_PsiContext *psi, CV_Pub32Flags flags, U32 offset, U16 isect, String
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dbi_sec_contrib_list_push_node(PDB_DbiSectionContribList *list, PDB_DbiSectionContribNode *node)
|
dbi_sec_contrib_list_push_node(PDB_DbiSCList *list, PDB_DbiSCNode *node)
|
||||||
{
|
{
|
||||||
node->next = 0;
|
node->next = 0;
|
||||||
SLLQueuePush(list->first, list->last, node);
|
SLLQueuePush(list->first, list->last, node);
|
||||||
list->count += 1;
|
list->count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal PDB_DbiSectionContribNode *
|
internal PDB_DbiSCNode *
|
||||||
dbi_sec_contrib_list_push(Arena *arena, PDB_DbiSectionContribList *list)
|
dbi_sec_contrib_list_push(Arena *arena, PDB_DbiSCList *list)
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContribNode *node = push_array_no_zero(arena, PDB_DbiSectionContribNode, 1);
|
PDB_DbiSCNode *node = push_array_no_zero(arena, PDB_DbiSCNode, 1);
|
||||||
node->next = 0;
|
node->next = 0;
|
||||||
dbi_sec_contrib_list_push_node(list, node);
|
dbi_sec_contrib_list_push_node(list, node);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
dbi_sec_list_concat_arr(PDB_DbiSectionContribList *list, U64 count, PDB_DbiSectionContribList *to_concat)
|
dbi_sec_list_concat_arr(PDB_DbiSCList *list, U64 count, PDB_DbiSCList *to_concat)
|
||||||
{
|
{
|
||||||
SLLConcatInPlaceArray(list, to_concat, count);
|
SLLConcatInPlaceArray(list, to_concat, count);
|
||||||
}
|
}
|
||||||
@@ -2405,14 +2405,14 @@ dbi_open_module_info(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_Db
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal PDB_DbiSectionContribList
|
internal PDB_DbiSCList
|
||||||
dbi_open_sec_contrib(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header)
|
dbi_open_sec_contrib(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
PDB_DbiSectionContribList sec_contrib = {0};
|
PDB_DbiSCList sec_contrib = {0};
|
||||||
|
|
||||||
if (dbi_header->sec_con_size > sizeof(PDB_DbiSectionContrib)) {
|
if (dbi_header->sec_con_size > sizeof(PDB_DbiSC)) {
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
|
||||||
// seek to start of section contrib info
|
// seek to start of section contrib info
|
||||||
@@ -2420,25 +2420,25 @@ dbi_open_sec_contrib(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_Db
|
|||||||
msf_stream_seek(msf, sn, sec_con_pos);
|
msf_stream_seek(msf, sn, sec_con_pos);
|
||||||
|
|
||||||
// read header
|
// read header
|
||||||
PDB_DbiSectionContribVersion version = 0;
|
PDB_DbiSCVersion version = 0;
|
||||||
msf_stream_read_struct(msf, sn, &version);
|
msf_stream_read_struct(msf, sn, &version);
|
||||||
|
|
||||||
// parse contrib items
|
// parse contrib items
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case PDB_DbiSectionContribVersion_1: {
|
case PDB_DbiSCVersion_1: {
|
||||||
U64 contrib_count = dbi_header->sec_con_size / sizeof(PDB_DbiSectionContrib);
|
U64 contrib_count = dbi_header->sec_con_size / sizeof(PDB_DbiSC);
|
||||||
PDB_DbiSectionContrib *src_contrib_array = push_array(scratch.arena, PDB_DbiSectionContrib, contrib_count);
|
PDB_DbiSC *src_contrib_array = push_array(scratch.arena, PDB_DbiSC, contrib_count);
|
||||||
MSF_UInt sec_con_read = msf_stream_read_array(msf, sn, &src_contrib_array[0], contrib_count);
|
MSF_UInt sec_con_read = msf_stream_read_array(msf, sn, &src_contrib_array[0], contrib_count);
|
||||||
Assert(sec_con_read == sizeof(src_contrib_array[0]) * contrib_count);
|
Assert(sec_con_read == sizeof(src_contrib_array[0]) * contrib_count);
|
||||||
|
|
||||||
PDB_DbiSectionContribNode *dst_contrib_array = push_array_no_zero(arena, PDB_DbiSectionContribNode, contrib_count);
|
PDB_DbiSCNode *dst_contrib_array = push_array_no_zero(arena, PDB_DbiSCNode, contrib_count);
|
||||||
for (U64 icontrib = 0; icontrib < contrib_count; icontrib += 1) {
|
for (U64 icontrib = 0; icontrib < contrib_count; icontrib += 1) {
|
||||||
dst_contrib_array[icontrib].next = 0;
|
dst_contrib_array[icontrib].next = 0;
|
||||||
dst_contrib_array[icontrib].data = src_contrib_array[icontrib];
|
dst_contrib_array[icontrib].data = src_contrib_array[icontrib];
|
||||||
dbi_sec_contrib_list_push_node(&sec_contrib, &dst_contrib_array[icontrib]);
|
dbi_sec_contrib_list_push_node(&sec_contrib, &dst_contrib_array[icontrib]);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case PDB_DbiSectionContribVersion_2: {
|
case PDB_DbiSCVersion_2: {
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
} break;
|
} break;
|
||||||
default: Assert(!"unknown section contrib version"); break;
|
default: Assert(!"unknown section contrib version"); break;
|
||||||
@@ -2595,7 +2595,7 @@ dbi_build_module_info(Arena *arena, PDB_DbiContext *dbi, MSF_Context *msf)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int
|
int
|
||||||
dbi_sc_compar(const PDB_DbiSectionContrib *a, const PDB_DbiSectionContrib *b)
|
dbi_sc_compar(const PDB_DbiSC *a, const PDB_DbiSC *b)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
int cmp = 0;
|
int cmp = 0;
|
||||||
@@ -2622,7 +2622,7 @@ dbi_sc_compar(const PDB_DbiSectionContrib *a, const PDB_DbiSectionContrib *b)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_count)
|
lnk_radix_sort_dbi_sc_array(PDB_DbiSC *arr, U64 sc_count, U64 sect_count)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
@@ -2638,9 +2638,9 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
|
|
||||||
Temp scratch = scratch_begin(0,0);
|
Temp scratch = scratch_begin(0,0);
|
||||||
|
|
||||||
PDB_DbiSectionContrib *temp_arr = push_array_no_zero(scratch.arena, PDB_DbiSectionContrib, sc_count);
|
PDB_DbiSC *temp_arr = push_array_no_zero(scratch.arena, PDB_DbiSC, sc_count);
|
||||||
PDB_DbiSectionContrib *src_arr = arr;
|
PDB_DbiSC *src_arr = arr;
|
||||||
PDB_DbiSectionContrib *dst_arr = temp_arr;
|
PDB_DbiSC *dst_arr = temp_arr;
|
||||||
|
|
||||||
ProfBegin("Count Memzero");
|
ProfBegin("Count Memzero");
|
||||||
U32 count_8lo[256]; MemoryZeroArray(count_8lo);
|
U32 count_8lo[256]; MemoryZeroArray(count_8lo);
|
||||||
@@ -2651,7 +2651,7 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
|
|
||||||
ProfBegin("Histogram");
|
ProfBegin("Histogram");
|
||||||
for (U64 i = 0; i < sc_count; i += 1) {
|
for (U64 i = 0; i < sc_count; i += 1) {
|
||||||
PDB_DbiSectionContrib *sc = src_arr + i;
|
PDB_DbiSC *sc = src_arr + i;
|
||||||
count_arr[sc->base.sec] += 1;
|
count_arr[sc->base.sec] += 1;
|
||||||
|
|
||||||
U64 digit_8lo = (sc->base.sec_off >> 0) % ArrayCount(count_8lo);
|
U64 digit_8lo = (sc->base.sec_off >> 0) % ArrayCount(count_8lo);
|
||||||
@@ -2693,7 +2693,7 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
|
|
||||||
ProfBegin("Order 8 Lo");
|
ProfBegin("Order 8 Lo");
|
||||||
for (U64 i = 0; i < sc_count; i += 1) {
|
for (U64 i = 0; i < sc_count; i += 1) {
|
||||||
PDB_DbiSectionContrib *sc = &src_arr[i];
|
PDB_DbiSC *sc = &src_arr[i];
|
||||||
U64 digit = (sc->base.sec_off >> 0) % ArrayCount(count_8lo);
|
U64 digit = (sc->base.sec_off >> 0) % ArrayCount(count_8lo);
|
||||||
dst_arr[count_8lo[digit]++] = *sc;
|
dst_arr[count_8lo[digit]++] = *sc;
|
||||||
}
|
}
|
||||||
@@ -2701,7 +2701,7 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
|
|
||||||
ProfBegin("Order 8 Hi");
|
ProfBegin("Order 8 Hi");
|
||||||
for (U64 i = 0; i < sc_count; i += 1) {
|
for (U64 i = 0; i < sc_count; i += 1) {
|
||||||
PDB_DbiSectionContrib *sc = &dst_arr[i];
|
PDB_DbiSC *sc = &dst_arr[i];
|
||||||
U64 digit = (sc->base.sec_off >> 8) % ArrayCount(count_8hi);
|
U64 digit = (sc->base.sec_off >> 8) % ArrayCount(count_8hi);
|
||||||
src_arr[count_8hi[digit]++] = *sc;
|
src_arr[count_8hi[digit]++] = *sc;
|
||||||
}
|
}
|
||||||
@@ -2709,7 +2709,7 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
|
|
||||||
ProfBegin("Order 16");
|
ProfBegin("Order 16");
|
||||||
for (U64 i = 0; i < sc_count; i += 1) {
|
for (U64 i = 0; i < sc_count; i += 1) {
|
||||||
PDB_DbiSectionContrib *sc = &src_arr[i];
|
PDB_DbiSC *sc = &src_arr[i];
|
||||||
U64 digit = (sc->base.sec_off >> 16) % ArrayCount(count_16);
|
U64 digit = (sc->base.sec_off >> 16) % ArrayCount(count_16);
|
||||||
dst_arr[count_16[digit]++] = *sc;
|
dst_arr[count_16[digit]++] = *sc;
|
||||||
}
|
}
|
||||||
@@ -2731,7 +2731,7 @@ lnk_radix_sort_dbi_sc_array(PDB_DbiSectionContrib *arr, U64 sc_count, U64 sect_c
|
|||||||
count_arr[0] = 0;
|
count_arr[0] = 0;
|
||||||
|
|
||||||
for (U64 i = 0; i < sc_count; i += 1) {
|
for (U64 i = 0; i < sc_count; i += 1) {
|
||||||
PDB_DbiSectionContrib *sc = dst_arr + i;
|
PDB_DbiSC *sc = dst_arr + i;
|
||||||
src_arr[count_arr[sc->base.sec]++] = *sc;
|
src_arr[count_arr[sc->base.sec]++] = *sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2758,14 +2758,14 @@ dbi_build_sec_con(Arena *arena, PDB_DbiContext *dbi)
|
|||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
PDB_DbiSectionContribVersion *version = push_array(arena, PDB_DbiSectionContribVersion, 1);
|
PDB_DbiSCVersion *version = push_array(arena, PDB_DbiSCVersion, 1);
|
||||||
*version = PDB_DbiSectionContribVersion_1;
|
*version = PDB_DbiSCVersion_1;
|
||||||
|
|
||||||
// push section contribs V1
|
// push section contribs V1
|
||||||
ProfBegin("Push sect contribs [Count %llu]", dbi->sec_contrib_list.count);
|
ProfBegin("Push sect contribs [Count %llu]", dbi->sec_contrib_list.count);
|
||||||
PDB_DbiSectionContrib *sc_array = push_array_no_zero(arena, PDB_DbiSectionContrib, dbi->sec_contrib_list.count);
|
PDB_DbiSC *sc_array = push_array_no_zero(arena, PDB_DbiSC, dbi->sec_contrib_list.count);
|
||||||
PDB_DbiSectionContrib *dst = &sc_array[0];
|
PDB_DbiSC *dst = &sc_array[0];
|
||||||
for (PDB_DbiSectionContribNode *src = dbi->sec_contrib_list.first; src != 0; src = src->next, dst += 1) {
|
for (PDB_DbiSCNode *src = dbi->sec_contrib_list.first; src != 0; src = src->next, dst += 1) {
|
||||||
*dst = src->data;
|
*dst = src->data;
|
||||||
}
|
}
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
@@ -2956,7 +2956,7 @@ dbi_module_push_section_contrib(PDB_DbiContext *dbi,
|
|||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
|
||||||
PDB_DbiSectionContrib sc;
|
PDB_DbiSC sc;
|
||||||
sc.base.sec = safe_cast_u16(isect_off.isect);
|
sc.base.sec = safe_cast_u16(isect_off.isect);
|
||||||
sc.base.sec_off = isect_off.off;
|
sc.base.sec_off = isect_off.off;
|
||||||
sc.base.size = size;
|
sc.base.size = size;
|
||||||
@@ -2965,7 +2965,7 @@ dbi_module_push_section_contrib(PDB_DbiContext *dbi,
|
|||||||
sc.data_crc = data_crc;
|
sc.data_crc = data_crc;
|
||||||
sc.reloc_crc = reloc_crc;
|
sc.reloc_crc = reloc_crc;
|
||||||
|
|
||||||
PDB_DbiSectionContribNode *node = push_array_no_zero(dbi->arena, PDB_DbiSectionContribNode, 1);
|
PDB_DbiSCNode *node = push_array_no_zero(dbi->arena, PDB_DbiSCNode, 1);
|
||||||
node->data = sc;
|
node->data = sc;
|
||||||
dbi_sec_contrib_list_push_node(&dbi->sec_contrib_list, node);
|
dbi_sec_contrib_list_push_node(&dbi->sec_contrib_list, node);
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ typedef struct PDB_DbiModule
|
|||||||
struct PDB_DbiModule *next;
|
struct PDB_DbiModule *next;
|
||||||
MSF_StreamNumber sn;
|
MSF_StreamNumber sn;
|
||||||
CV_ModIndex imod;
|
CV_ModIndex imod;
|
||||||
PDB_DbiSectionContrib first_sc;
|
PDB_DbiSC first_sc;
|
||||||
U64 sym_data_size;
|
U64 sym_data_size;
|
||||||
U64 c11_data_size;
|
U64 c11_data_size;
|
||||||
U64 c13_data_size;
|
U64 c13_data_size;
|
||||||
@@ -255,18 +255,18 @@ typedef struct PDB_DbiModuleList
|
|||||||
U64 count;
|
U64 count;
|
||||||
} PDB_DbiModuleList;
|
} PDB_DbiModuleList;
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionContribNode
|
typedef struct PDB_DbiSCNode
|
||||||
{
|
{
|
||||||
struct PDB_DbiSectionContribNode *next;
|
struct PDB_DbiSCNode *next;
|
||||||
PDB_DbiSectionContrib data;
|
PDB_DbiSC data;
|
||||||
} PDB_DbiSectionContribNode;
|
} PDB_DbiSCNode;
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionContribList
|
typedef struct PDB_DbiSCList
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContribNode *first;
|
PDB_DbiSCNode *first;
|
||||||
PDB_DbiSectionContribNode *last;
|
PDB_DbiSCNode *last;
|
||||||
U64 count;
|
U64 count;
|
||||||
} PDB_DbiSectionContribList;
|
} PDB_DbiSCList;
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionNode
|
typedef struct PDB_DbiSectionNode
|
||||||
{
|
{
|
||||||
@@ -290,7 +290,7 @@ typedef struct PDB_DbiContext
|
|||||||
MSF_StreamNumber publics_sn;
|
MSF_StreamNumber publics_sn;
|
||||||
MSF_StreamNumber symbols_sn;
|
MSF_StreamNumber symbols_sn;
|
||||||
PDB_DbiModuleList module_list;
|
PDB_DbiModuleList module_list;
|
||||||
PDB_DbiSectionContribList sec_contrib_list;
|
PDB_DbiSCList sec_contrib_list;
|
||||||
PDB_DbiSectionList section_list;
|
PDB_DbiSectionList section_list;
|
||||||
PDB_StringTable ec_names;
|
PDB_StringTable ec_names;
|
||||||
MSF_StreamNumber dbg_streams[PDB_DbiStream_COUNT];
|
MSF_StreamNumber dbg_streams[PDB_DbiStream_COUNT];
|
||||||
@@ -394,7 +394,7 @@ internal String8 dbi_module_read_c13_data(Arena *arena, MSF_Co
|
|||||||
internal void dbi_module_push_section_contrib(PDB_DbiContext *dbi, PDB_DbiModule *mod, ISectOff isect_off, U32 size, U32 data_crc, U32 reloc_crc, COFF_SectionFlags flags);
|
internal void dbi_module_push_section_contrib(PDB_DbiContext *dbi, PDB_DbiModule *mod, ISectOff isect_off, U32 size, U32 data_crc, U32 reloc_crc, COFF_SectionFlags flags);
|
||||||
internal String8List * dbi_open_file_info(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
internal String8List * dbi_open_file_info(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
||||||
internal PDB_DbiModuleList dbi_open_module_info(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header, String8List *file_info);
|
internal PDB_DbiModuleList dbi_open_module_info(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header, String8List *file_info);
|
||||||
internal PDB_DbiSectionContribList dbi_open_sec_contrib(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
internal PDB_DbiSCList dbi_open_sec_contrib(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
||||||
internal PDB_StringTable dbi_open_ec_names(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
internal PDB_StringTable dbi_open_ec_names(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
||||||
internal void dbi_open_dbg_streams(MSF_StreamNumber *dbg_streams, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
internal void dbi_open_dbg_streams(MSF_StreamNumber *dbg_streams, MSF_Context *msf, MSF_StreamNumber sn, PDB_DbiHeader *dbi_header);
|
||||||
internal PDB_DbiSectionList dbi_open_section_headers(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn);
|
internal PDB_DbiSectionList dbi_open_section_headers(Arena *arena, MSF_Context *msf, MSF_StreamNumber sn);
|
||||||
|
|||||||
+12
-12
@@ -223,11 +223,11 @@ typedef struct PDB_DbiHeader
|
|||||||
|
|
||||||
// "ModuleInfo" DBI range
|
// "ModuleInfo" DBI range
|
||||||
|
|
||||||
typedef U32 PDB_DbiSectionContribVersion;
|
typedef U32 PDB_DbiSCVersion;
|
||||||
#define PDB_DbiSectionContribVersion_1 (0xeffe0000u + 19970605u)
|
#define PDB_DbiSCVersion_1 (0xeffe0000u + 19970605u)
|
||||||
#define PDB_DbiSectionContribVersion_2 (0xeffe0000u + 20140516u)
|
#define PDB_DbiSCVersion_2 (0xeffe0000u + 20140516u)
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionContrib40
|
typedef struct PDB_DbiSC40
|
||||||
{
|
{
|
||||||
CV_SectionIndex sec;
|
CV_SectionIndex sec;
|
||||||
U16 pad0;
|
U16 pad0;
|
||||||
@@ -236,27 +236,27 @@ typedef struct PDB_DbiSectionContrib40
|
|||||||
U32 flags;
|
U32 flags;
|
||||||
CV_ModIndex mod;
|
CV_ModIndex mod;
|
||||||
U16 pad1;
|
U16 pad1;
|
||||||
} PDB_DbiSectionContrib40;
|
} PDB_DbiSC40;
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionContrib
|
typedef struct PDB_DbiSC
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContrib40 base;
|
PDB_DbiSC40 base;
|
||||||
U32 data_crc;
|
U32 data_crc;
|
||||||
U32 reloc_crc;
|
U32 reloc_crc;
|
||||||
} PDB_DbiSectionContrib;
|
} PDB_DbiSC;
|
||||||
|
|
||||||
typedef struct PDB_DbiSectionContrib2
|
typedef struct PDB_DbiSC2
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContrib40 base;
|
PDB_DbiSC40 base;
|
||||||
U32 data_crc;
|
U32 data_crc;
|
||||||
U32 reloc_crc;
|
U32 reloc_crc;
|
||||||
U32 sec_coff;
|
U32 sec_coff;
|
||||||
} PDB_DbiSectionContrib2;
|
} PDB_DbiSC2;
|
||||||
|
|
||||||
typedef struct PDB_DbiCompUnitHeader
|
typedef struct PDB_DbiCompUnitHeader
|
||||||
{
|
{
|
||||||
U32 unused;
|
U32 unused;
|
||||||
PDB_DbiSectionContrib contribution;
|
PDB_DbiSC contribution;
|
||||||
U16 flags; // unknown
|
U16 flags; // unknown
|
||||||
|
|
||||||
MSF_StreamNumber sn;
|
MSF_StreamNumber sn;
|
||||||
|
|||||||
+8
-8
@@ -700,9 +700,9 @@ pdb_comp_unit_contribution_array_from_data(Arena *arena, String8 data, COFF_Sect
|
|||||||
{
|
{
|
||||||
PDB_CompUnitContribution *contributions = 0;
|
PDB_CompUnitContribution *contributions = 0;
|
||||||
U64 count = 0;
|
U64 count = 0;
|
||||||
if(data.size >= sizeof(PDB_DbiSectionContribVersion))
|
if(data.size >= sizeof(PDB_DbiSCVersion))
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContribVersion *version = (PDB_DbiSectionContribVersion*)data.str;
|
PDB_DbiSCVersion *version = (PDB_DbiSCVersion*)data.str;
|
||||||
|
|
||||||
// determine array layout from version
|
// determine array layout from version
|
||||||
U32 item_size = 0;
|
U32 item_size = 0;
|
||||||
@@ -712,16 +712,16 @@ pdb_comp_unit_contribution_array_from_data(Arena *arena, String8 data, COFF_Sect
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// TODO(allen): do we have a test case for this?
|
// TODO(allen): do we have a test case for this?
|
||||||
item_size = sizeof(PDB_DbiSectionContrib40);
|
item_size = sizeof(PDB_DbiSC40);
|
||||||
}break;
|
}break;
|
||||||
case PDB_DbiSectionContribVersion_1:
|
case PDB_DbiSCVersion_1:
|
||||||
{
|
{
|
||||||
item_size = sizeof(PDB_DbiSectionContrib);
|
item_size = sizeof(PDB_DbiSC);
|
||||||
array_off = sizeof(*version);
|
array_off = sizeof(*version);
|
||||||
}break;
|
}break;
|
||||||
case PDB_DbiSectionContribVersion_2:
|
case PDB_DbiSCVersion_2:
|
||||||
{
|
{
|
||||||
item_size = sizeof(PDB_DbiSectionContrib2);
|
item_size = sizeof(PDB_DbiSC2);
|
||||||
array_off = sizeof(*version);
|
array_off = sizeof(*version);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
@@ -739,7 +739,7 @@ pdb_comp_unit_contribution_array_from_data(Arena *arena, String8 data, COFF_Sect
|
|||||||
U64 cursor = array_off;
|
U64 cursor = array_off;
|
||||||
for(; cursor + item_size <= data.size; cursor += item_size)
|
for(; cursor + item_size <= data.size; cursor += item_size)
|
||||||
{
|
{
|
||||||
PDB_DbiSectionContrib40 *sc = (PDB_DbiSectionContrib40*)(data.str + cursor);
|
PDB_DbiSC40 *sc = (PDB_DbiSC40*)(data.str + cursor);
|
||||||
if(sc->size > 0 && 1 <= sc->sec && sc->sec <= section_count)
|
if(sc->size > 0 && 1 <= sc->sec && sc->sec <= section_count)
|
||||||
{
|
{
|
||||||
U64 voff = section_headers[sc->sec - 1].voff + sc->sec_off;
|
U64 voff = section_headers[sc->sec - 1].voff + sc->sec_off;
|
||||||
|
|||||||
Reference in New Issue
Block a user