mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
added missing debug comments for chunks
This commit is contained in:
+63
-49
@@ -2013,7 +2013,8 @@ lnk_build_base_relocs(TP_Context *tp,
|
||||
Assert(*block_size_ptr <= buf_size);
|
||||
|
||||
// push page chunk
|
||||
lnk_section_push_chunk_raw(base_reloc_sect, base_reloc_sect->root, buf, block_size, str8_zero());
|
||||
LNK_Chunk *page_chunk = lnk_section_push_chunk_raw(base_reloc_sect, base_reloc_sect->root, buf, block_size, str8_zero());
|
||||
lnk_chunk_set_debugf(base_reloc_sect->arena, page_chunk, "Base Reloc Page (VirtOff: %#x Size: %#x, Pads: %#x)", page->voff, block_size, pad_reloc_count);
|
||||
|
||||
// purge voffs for next run
|
||||
hash_table_purge(voff_ht);
|
||||
@@ -2278,11 +2279,11 @@ lnk_build_coff_section_table(LNK_SymbolTable *symtab, LNK_Section *header_sect,
|
||||
}
|
||||
|
||||
// push COFF header array chunk
|
||||
LNK_Chunk *COFF_FileHeader_array_chunk = lnk_section_push_chunk_list(header_sect, parent_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(header_sect->arena, COFF_FileHeader_array_chunk, LNK_COFF_SECT_HEADER_ARRAY_SYMBOL_NAME);
|
||||
LNK_Chunk *coff_section_array_chunk = lnk_section_push_chunk_list(header_sect, parent_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(header_sect->arena, coff_section_array_chunk, LNK_COFF_SECT_HEADER_ARRAY_SYMBOL_NAME);
|
||||
|
||||
// define symbol for COFF header array
|
||||
lnk_symbol_table_push_defined_chunk(symtab, str8_lit(LNK_COFF_SECT_HEADER_ARRAY_SYMBOL_NAME), LNK_DefinedSymbolVisibility_Internal, 0, COFF_FileHeader_array_chunk, 0, 0, 0);
|
||||
lnk_symbol_table_push_defined_chunk(symtab, str8_lit(LNK_COFF_SECT_HEADER_ARRAY_SYMBOL_NAME), LNK_DefinedSymbolVisibility_Internal, 0, coff_section_array_chunk, 0, 0, 0);
|
||||
|
||||
// push headers
|
||||
for (LNK_Section *sect = §_arr.v[0], *sect_opl = sect + sect_arr.count; sect < sect_opl; sect += 1) {
|
||||
@@ -2292,38 +2293,39 @@ lnk_build_coff_section_table(LNK_SymbolTable *symtab, LNK_Section *header_sect,
|
||||
if (!sect->has_layout) {
|
||||
continue;
|
||||
}
|
||||
COFF_SectionHeader *COFF_FileHeader = push_array_no_zero(header_sect->arena, COFF_SectionHeader, 1);
|
||||
COFF_SectionHeader *coff_section = push_array_no_zero(header_sect->arena, COFF_SectionHeader, 1);
|
||||
|
||||
// TODO: for objs we can store long name in string table and write here /offset
|
||||
if (sect->name.size > sizeof(COFF_FileHeader->name)) {
|
||||
if (sect->name.size > sizeof(coff_section->name)) {
|
||||
lnk_error(LNK_Warning_LongSectionName, "not enough space in COFF section header to store entire name \"%S\"", sect->name);
|
||||
}
|
||||
|
||||
MemorySet(&COFF_FileHeader->name[0], 0, sizeof(COFF_FileHeader->name));
|
||||
MemoryCopy(&COFF_FileHeader->name[0], sect->name.str, Min(sect->name.size, sizeof(COFF_FileHeader->name)));
|
||||
COFF_FileHeader->vsize = 0; // :vsize
|
||||
COFF_FileHeader->voff = 0; // :voff
|
||||
COFF_FileHeader->fsize = 0; // :fsize
|
||||
COFF_FileHeader->foff = 0; // :foff
|
||||
COFF_FileHeader->relocs_foff = 0; // :relocs_foff
|
||||
COFF_FileHeader->lines_foff = 0; // obsolete
|
||||
COFF_FileHeader->reloc_count = 0; // :reloc_count
|
||||
COFF_FileHeader->line_count = 0; // obsolete
|
||||
COFF_FileHeader->flags = sect->flags;
|
||||
MemorySet(&coff_section->name[0], 0, sizeof(coff_section->name));
|
||||
MemoryCopy(&coff_section->name[0], sect->name.str, Min(sect->name.size, sizeof(coff_section->name)));
|
||||
coff_section->vsize = 0; // :vsize
|
||||
coff_section->voff = 0; // :voff
|
||||
coff_section->fsize = 0; // :fsize
|
||||
coff_section->foff = 0; // :foff
|
||||
coff_section->relocs_foff = 0; // :relocs_foff
|
||||
coff_section->lines_foff = 0; // obsolete
|
||||
coff_section->reloc_count = 0; // :reloc_count
|
||||
coff_section->line_count = 0; // obsolete
|
||||
coff_section->flags = sect->flags;
|
||||
|
||||
// push chunk
|
||||
LNK_Chunk *COFF_FileHeader_chunk = lnk_section_push_chunk_raw(header_sect, COFF_FileHeader_array_chunk, COFF_FileHeader, sizeof(*COFF_FileHeader), str8_zero());
|
||||
LNK_Chunk *coff_section_chunk = lnk_section_push_chunk_raw(header_sect, coff_section_array_chunk, coff_section, sizeof(*coff_section), str8_zero());
|
||||
lnk_chunk_set_debugf(header_sect->arena, coff_section_chunk, "COFF_SECTION_HEADER %S", sect->name);
|
||||
|
||||
// :vsize
|
||||
lnk_section_push_reloc_undefined(header_sect, COFF_FileHeader_chunk, LNK_Reloc_CHUNK_SIZE_VIRT_32, OffsetOf(COFF_SectionHeader, vsize), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
lnk_section_push_reloc_undefined(header_sect, coff_section_chunk, LNK_Reloc_CHUNK_SIZE_VIRT_32, OffsetOf(COFF_SectionHeader, vsize), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
// :voff
|
||||
lnk_section_push_reloc_undefined(header_sect, COFF_FileHeader_chunk, LNK_Reloc_VIRT_OFF_32, OffsetOf(COFF_SectionHeader, voff), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
lnk_section_push_reloc_undefined(header_sect, coff_section_chunk, LNK_Reloc_VIRT_OFF_32, OffsetOf(COFF_SectionHeader, voff), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
|
||||
if (~sect->flags & COFF_SectionFlag_CntUninitializedData) {
|
||||
// :fsize
|
||||
lnk_section_push_reloc_undefined(header_sect, COFF_FileHeader_chunk, LNK_Reloc_CHUNK_SIZE_FILE_32, OffsetOf(COFF_SectionHeader, fsize), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
lnk_section_push_reloc_undefined(header_sect, coff_section_chunk, LNK_Reloc_CHUNK_SIZE_FILE_32, OffsetOf(COFF_SectionHeader, fsize), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
// :foff
|
||||
lnk_section_push_reloc_undefined(header_sect, COFF_FileHeader_chunk, LNK_Reloc_FILE_OFF_32, OffsetOf(COFF_SectionHeader, foff), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
lnk_section_push_reloc_undefined(header_sect, coff_section_chunk, LNK_Reloc_FILE_OFF_32, OffsetOf(COFF_SectionHeader, foff), sect->name, LNK_SymbolScopeFlag_Internal);
|
||||
}
|
||||
|
||||
// TODO: :reloc_off
|
||||
@@ -2331,10 +2333,10 @@ lnk_build_coff_section_table(LNK_SymbolTable *symtab, LNK_Section *header_sect,
|
||||
}
|
||||
|
||||
// push symbol for section header count
|
||||
U64 header_count = COFF_FileHeader_array_chunk->u.list->count;
|
||||
U64 header_count = coff_section_array_chunk->u.list->count;
|
||||
lnk_symbol_table_push_defined_va(symtab, str8_lit(LNK_COFF_SECT_HEADER_COUNT_SYMBOL_NAME), LNK_DefinedSymbolVisibility_Internal, 0, header_count);
|
||||
|
||||
return COFF_FileHeader_array_chunk;
|
||||
return coff_section_array_chunk;
|
||||
}
|
||||
|
||||
internal LNK_Chunk *
|
||||
@@ -3223,13 +3225,14 @@ lnk_build_rad_chunk_map(Arena *arena, String8 image_data, U64 thread_count, LNK_
|
||||
radsort(chunks, sect->layout.total_count, lnk_map_sort_on_chunk_file_off);
|
||||
|
||||
str8_list_pushf(arena, &map, "%S\n", sect->name);
|
||||
str8_list_pushf(arena, &map, "%-16s %-8s %-8s %-16s %-8s %s\n", "Sect:Offset", "VirtSize", "FileSize", "Blake3", "ChunkRef", "Source");
|
||||
str8_list_pushf(arena, &map, "%-8s %-8s %-8s %-8s %-16s %-8s %s\n", "FileOff", "VirtOff", "VirtSize", "FileSize", "Blake3", "ChunkRef", "Source");
|
||||
for (U64 chunk_idx = 0; chunk_idx < sect->layout.total_count; ++chunk_idx) {
|
||||
LNK_Chunk *chunk = chunks[chunk_idx];
|
||||
if (chunk->type == LNK_Chunk_Leaf && chunk != g_null_chunk_ptr) {
|
||||
if (chunk != g_null_chunk_ptr) {
|
||||
Temp temp = temp_begin(scratch.arena);
|
||||
|
||||
ISectOff sc = lnk_sc_from_chunk_ref(sect_id_map, chunk->ref);
|
||||
U64 file_off = lnk_file_off_from_chunk_ref(sect_id_map, chunk->ref);
|
||||
U64 virt_off = lnk_virt_off_from_chunk_ref(sect_id_map, chunk->ref);
|
||||
U64 virt_size = lnk_virt_size_from_chunk_ref(sect_id_map, chunk->ref);
|
||||
U64 file_size = lnk_file_size_from_chunk_ref(sect_id_map, chunk->ref);
|
||||
String8 chunk_data = lnk_data_from_chunk_ref(sect_id_map, image_data, chunk->ref);
|
||||
@@ -3241,40 +3244,51 @@ lnk_build_rad_chunk_map(Arena *arena, String8 image_data, U64 thread_count, LNK_
|
||||
blake3_hasher_finalize(&hasher, (U8 *)&chunk_hash, sizeof(chunk_hash));
|
||||
}
|
||||
|
||||
String8 address_str = push_str8f(temp.arena, "%04x:%08x", sc.isect, sc.off);
|
||||
String8 file_off_str = push_str8f(temp.arena, "%08x", file_off);
|
||||
String8 virt_off_str = push_str8f(temp.arena, "%08x", virt_off);
|
||||
String8 virt_size_str = push_str8f(temp.arena, "%08x", virt_size);
|
||||
String8 file_size_str = push_str8f(temp.arena, "%08x", file_size);
|
||||
String8 chunk_hash_str = push_str8f(temp.arena, "%08x%08x", chunk_hash.u64[0], chunk_hash.u64[1]);
|
||||
String8 chunk_ref_str = push_str8f(temp.arena, "{%llx,%llx}", chunk->ref.sect_id, chunk->ref.chunk_id);
|
||||
String8 source_str = {0};
|
||||
if (chunk->obj) {
|
||||
if (chunk->obj->lib_path.size) {
|
||||
String8 lib_name = chunk->obj->lib_path;
|
||||
lib_name = str8_skip_last_slash(lib_name);
|
||||
lib_name = str8_chop_last_dot(lib_name);
|
||||
String8 source_str;
|
||||
{
|
||||
String8List source_list = {0};
|
||||
|
||||
String8 obj_name = chunk->obj->path;
|
||||
obj_name = str8_skip_last_slash(obj_name);
|
||||
// chunk type
|
||||
str8_list_pushf(temp.arena, &source_list, "[%S]", lnk_string_from_chunk_type(chunk->type));
|
||||
|
||||
source_str = push_str8f(temp.arena, "%S:%S", lib_name, obj_name);
|
||||
} else {
|
||||
source_str = push_str8f(temp.arena, "%S", chunk->obj->path);
|
||||
// location
|
||||
if (chunk->obj) {
|
||||
if (chunk->obj->lib_path.size) {
|
||||
String8 lib_name = chunk->obj->lib_path;
|
||||
lib_name = str8_skip_last_slash(lib_name);
|
||||
lib_name = str8_chop_last_dot(lib_name);
|
||||
|
||||
String8 obj_name = chunk->obj->path;
|
||||
obj_name = str8_skip_last_slash(obj_name);
|
||||
|
||||
str8_list_pushf(temp.arena, &source_list, "%S:%S", lib_name, obj_name);
|
||||
} else {
|
||||
str8_list_push(temp.arena, &source_list, chunk->obj->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// debug comment
|
||||
#if LNK_DEBUG_CHUNKS
|
||||
if (chunk->debug.size) {
|
||||
if (source_str.size) {
|
||||
source_str = push_str8f(temp.arena, "%S (%S)", source_str, chunk->debug);
|
||||
} else if (chunk->debug.size) {
|
||||
source_str = push_str8f(temp.arena, "%S", chunk->debug);
|
||||
if (chunk->debug.size) {
|
||||
if (source_str.size) {
|
||||
str8_list_pushf(temp.arena, &source_list, "(%S)", chunk->debug);
|
||||
} else if (chunk->debug.size) {
|
||||
str8_list_push(temp.arena, &source_list, chunk->debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (source_str.size == 0) {
|
||||
source_str = str8_lit("\?\?\?");
|
||||
|
||||
// string join
|
||||
source_str = str8_list_join(temp.arena, &source_list, &(StringJoin){.sep=str8_lit(" ")});
|
||||
}
|
||||
|
||||
str8_list_pushf(arena, &map, "%-16S %-8S %-8S %-16S %-8S %S\n", address_str, virt_size_str, file_size_str, chunk_hash_str, chunk_ref_str, source_str);
|
||||
str8_list_pushf(arena, &map, "%-8S %-8S %-8S %-8S %-16S %-8S %S\n", file_off_str, virt_off_str, virt_size_str, file_size_str, chunk_hash_str, chunk_ref_str, source_str);
|
||||
|
||||
temp_end(temp);
|
||||
}
|
||||
|
||||
@@ -790,3 +790,15 @@ lnk_data_arr_from_chunk_ptr_list_arr(Arena *arena, LNK_ChunkList *list_arr, U64
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
lnk_string_from_chunk_type(LNK_ChunkType type)
|
||||
{
|
||||
switch (type) {
|
||||
case LNK_Chunk_Null: return str8_lit("Null");
|
||||
case LNK_Chunk_Leaf: return str8_lit("Leaf");
|
||||
case LNK_Chunk_LeafArray: return str8_lit("LeafArray");
|
||||
case LNK_Chunk_List: return str8_lit("List");
|
||||
default: InvalidPath;
|
||||
}
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
@@ -206,3 +206,5 @@ internal LNK_ChunkNode * lnk_chunk_ptr_list_reserve(Arena *arena, LNK_ChunkList
|
||||
internal String8Array lnk_data_arr_from_chunk_ptr_list(Arena *arena, LNK_ChunkList list);
|
||||
internal String8Array * lnk_data_arr_from_chunk_ptr_list_arr(Arena *arena, LNK_ChunkList *list_arr, U64 count);
|
||||
|
||||
internal String8 lnk_string_from_chunk_type(LNK_ChunkType type);
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@ lnk_import_table_alloc_static(LNK_SectionTable *st, LNK_SymbolTable *symtab, COF
|
||||
LNK_Chunk *iat_chunk = lnk_section_push_chunk_list(data_sect, data_sect->root, str8_zero());
|
||||
LNK_Chunk *ilt_chunk = lnk_section_push_chunk_list(data_sect, data_sect->root, str8_zero());
|
||||
LNK_Chunk *code_chunk = lnk_section_push_chunk_list(code_sect, code_sect->root, str8_zero());
|
||||
|
||||
lnk_chunk_set_debugf(data_sect->arena, dll_table_chunk, "DLL_TABLE" );
|
||||
lnk_chunk_set_debugf(data_sect->arena, int_chunk, "IMPORT_NAME_TABLE" );
|
||||
lnk_chunk_set_debugf(data_sect->arena, iat_chunk, "IMPORT_ADDRESS_TABLE");
|
||||
lnk_chunk_set_debugf(data_sect->arena, ilt_chunk, "IMPORT_LOOKUP_TABLE" );
|
||||
lnk_chunk_set_debugf(data_sect->arena, code_chunk, "IMPORT_TABLE_CODE" );
|
||||
|
||||
LNK_Chunk *null_dll_import = lnk_section_push_chunk_data(data_sect, dll_table_chunk, str8(0, sizeof(PE_ImportEntry)), str8_lit("zzzzz"));
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_dll_import, "DLL_DIRECTORY_TERMINATOR");
|
||||
|
||||
@@ -177,6 +182,10 @@ lnk_import_table_push_dll_static(LNK_ImportTable *imptab, LNK_SymbolTable *symta
|
||||
LNK_Chunk *ilt_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->ilt_chunk, str8_zero());
|
||||
LNK_Chunk *iat_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->iat_chunk, str8_zero());
|
||||
LNK_Chunk *code_table_chunk = lnk_section_push_chunk_list(code_sect, imptab->code_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, int_table_chunk, "%S.INT", dll_name);
|
||||
lnk_chunk_set_debugf(data_sect->arena, ilt_table_chunk, "%S.ILT", dll_name);
|
||||
lnk_chunk_set_debugf(data_sect->arena, iat_table_chunk, "%S.IAT", dll_name);
|
||||
lnk_chunk_set_debugf(data_sect->arena, code_table_chunk, "%S.CODE", dll_name);
|
||||
|
||||
String8 ilt_symbol_name = push_str8f(symtab->arena->v[0], "%S.lookup_table_voff", dll_name);
|
||||
LNK_Symbol *ilt_symbol = lnk_symbol_table_push_defined_chunk(symtab, ilt_symbol_name, LNK_DefinedSymbolVisibility_Internal, 0, ilt_table_chunk, 0, 0, 0);
|
||||
@@ -256,24 +265,26 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
// emit entry chunk
|
||||
String8 imp_desc_data = str8_struct(imp_desc);
|
||||
LNK_Chunk *imp_desc_chunk = lnk_section_push_chunk_data(data_sect, imptab->dll_table_chunk, imp_desc_data, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, imp_desc_chunk, "%S.IMP_DESC", dll_name);
|
||||
|
||||
// emit entry symbol
|
||||
String8 imp_desc_name = push_str8f(symtab->arena->v[0], "__DELAY_IMPORT_DESCRIPTOR_%S", dll_name);
|
||||
LNK_Symbol *imp_desc_symbol = lnk_symbol_table_push_defined_chunk(symtab, imp_desc_name, LNK_DefinedSymbolVisibility_Extern, 0, imp_desc_chunk, 0, 0, 0);
|
||||
|
||||
// emit string table chunk
|
||||
String8 int_table_chunk_debug = push_str8f(data_sect->arena, "delayed.%S.int", dll_name);
|
||||
LNK_Chunk *int_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->int_chunk, int_table_chunk_debug);
|
||||
LNK_Chunk *int_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->int_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, int_table_chunk, "%S.DELAY_INT", dll_name);
|
||||
|
||||
String8 int_table_symbol_name = push_str8f(symtab->arena->v[0], "delayed.%S.int", dll_name);
|
||||
LNK_Symbol *int_table_symbol = lnk_symbol_table_push_defined_chunk(symtab, int_table_symbol_name, LNK_DefinedSymbolVisibility_Internal, 0, int_table_chunk, 0, 0, 0);
|
||||
|
||||
LNK_Chunk *null_string_chunk = lnk_section_push_chunk_list(data_sect, int_table_chunk, str8_lit("zzzzz"));
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_string_chunk, "string table null");
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_string_chunk, "%S.STRING_TABLE_NULL", dll_name);
|
||||
|
||||
// emit DLL name chunk
|
||||
String8 name_chunk_data = push_cstr(data_sect->arena, dll_name);
|
||||
LNK_Chunk *name_chunk = lnk_section_push_chunk_data(data_sect, int_table_chunk, name_chunk_data, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, name_chunk, "%S.DELAY_NAME", dll_name);
|
||||
|
||||
String8 name_symbol_name = push_str8f(symtab->arena->v[0], "delayed.%S.name", dll_name);
|
||||
LNK_Symbol *name_symbol = lnk_symbol_table_push_defined_chunk(symtab, name_symbol_name, LNK_DefinedSymbolVisibility_Internal, 0, name_chunk, 0, 0, 0);
|
||||
@@ -283,6 +294,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
|
||||
// emit DLL handle chunk
|
||||
LNK_Chunk *handle_chunk = lnk_section_push_chunk_bss(data_sect, imptab->handle_table_chunk, handle_size, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, handle_chunk, "%S.DELAY_HANDLE", dll_name);
|
||||
|
||||
String8 handle_name = push_str8f(symtab->arena->v[0], "delayed.%S.handle", dll_name);
|
||||
LNK_Symbol *handle_symbol = lnk_symbol_table_push_defined_chunk(symtab, handle_name, LNK_DefinedSymbolVisibility_Internal, 0, handle_chunk, 0, 0, 0);
|
||||
@@ -292,18 +304,19 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
|
||||
// emit IAT chunk
|
||||
LNK_Chunk *iat_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->iat_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, iat_table_chunk, "%S.DELAY_IAT", dll_name);
|
||||
|
||||
String8 iat_table_name = push_str8f(symtab->arena->v[0], "delayed.%S.iat", dll_name);
|
||||
LNK_Symbol *iat_table_symbol = lnk_symbol_table_push_defined_chunk(symtab, iat_table_name, LNK_DefinedSymbolVisibility_Internal, 0, iat_table_chunk, 0, 0, 0);
|
||||
|
||||
LNK_Chunk *null_iat_chunk = lnk_section_push_chunk_bss(data_sect, iat_table_chunk, import_size, str8_lit("zzzzzz"));
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_iat_chunk, "%S: IAT terminator", dll_name);
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_iat_chunk, "%S.DELAY_IAT_TERMINATOR", dll_name);
|
||||
|
||||
// emit ILT chunk
|
||||
LNK_Chunk *ilt_table_chunk = lnk_section_push_chunk_list(data_sect, imptab->ilt_chunk, str8_zero());
|
||||
|
||||
LNK_Chunk *null_ilt_chunk = lnk_section_push_chunk_bss(data_sect, ilt_table_chunk, import_size, str8_lit("zzzzzz"));
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_ilt_chunk, "%S: ILT terminator", dll_name);
|
||||
lnk_chunk_set_debugf(data_sect->arena, null_ilt_chunk, "%S.DELAY_ILT_TERMINATOR", dll_name);
|
||||
|
||||
String8 ilt_table_name = push_str8f(symtab->arena->v[0], "delayed.%S.ilt", dll_name);
|
||||
LNK_Symbol *ilt_table_symbol = lnk_symbol_table_push_defined_chunk(symtab, ilt_table_name, LNK_DefinedSymbolVisibility_Extern, 0, ilt_table_chunk, 0, 0, 0);
|
||||
@@ -318,6 +331,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
LNK_Chunk *biat_chunk = 0;
|
||||
if (imptab->flags & LNK_ImportTableFlag_EmitBiat) {
|
||||
biat_chunk = lnk_section_push_chunk_list(data_sect, imptab->biat_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, biat_chunk, "%S.DELAY_BIAT", dll_name);
|
||||
|
||||
String8 biat_symbol_name = push_str8f(symtab->arena->v[0], "delayed.%S.BIAT", dll_name);
|
||||
LNK_Symbol *biat_symbol = lnk_symbol_table_push_defined_chunk(symtab, biat_symbol_name, LNK_DefinedSymbolVisibility_Internal, 0, biat_chunk, 0, 0, 0);
|
||||
@@ -330,6 +344,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
LNK_Chunk *uiat_chunk = NULL;
|
||||
if (imptab->flags & LNK_ImportTableFlag_EmitUiat) {
|
||||
uiat_chunk = lnk_section_push_chunk_list(data_sect, imptab->uiat_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, uiat_chunk, "%S.DELAY_UIAT", dll_name);
|
||||
|
||||
String8 uiat_symbol_name = push_str8f(symtab->arena->v[0], "delayed.%S.UIAT", dll_name);
|
||||
LNK_Symbol *uiat_symbol = lnk_symbol_table_push_defined_chunk(symtab, uiat_symbol_name, LNK_DefinedSymbolVisibility_Internal, 0, uiat_chunk, 0, 0, 0);
|
||||
@@ -340,7 +355,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
|
||||
// emit chunk for DLL thunk/load code
|
||||
LNK_Chunk *code_chunk = lnk_section_push_chunk_list(code_sect, imptab->code_chunk, str8_zero());
|
||||
lnk_chunk_set_debugf(code_sect->arena, code_chunk, "code for %S", dll_name);
|
||||
lnk_chunk_set_debugf(code_sect->arena, code_chunk, "%S.DLAY_CODE", dll_name);
|
||||
|
||||
// emit tail merge
|
||||
LNK_Chunk *tail_merge_chunk = 0;
|
||||
@@ -348,6 +363,7 @@ lnk_import_table_push_dll_delayed(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
case COFF_MachineType_X64: {
|
||||
LNK_Symbol *delay_load_helper_symbol = lnk_make_undefined_symbol(symtab->arena->v[0], str8_lit(LNK_DELAY_LOAD_HELPER2_SYMBOL_NAME), LNK_SymbolScopeFlag_Main);
|
||||
tail_merge_chunk = lnk_emit_tail_merge_thunk_x64(code_sect, code_chunk, imp_desc_symbol, delay_load_helper_symbol);
|
||||
lnk_chunk_set_debugf(code_sect->arena, code_chunk, "%S.X64_TAIL_MERGE", dll_name);
|
||||
} break;
|
||||
default: {
|
||||
lnk_not_implemented("TODO: __tailMerge for %S", coff_string_from_machine_type(machine));
|
||||
@@ -402,6 +418,8 @@ lnk_import_table_push_func_static(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
String8 ordinal_data = lnk_ordinal_data_from_hint(data_sect->arena, dll->machine, header->hint_or_ordinal);
|
||||
ilt_chunk = lnk_section_push_chunk_data(data_sect, ilt_table_chunk, ordinal_data, sort_index);
|
||||
iat_chunk = lnk_section_push_chunk_data(data_sect, iat_table_chunk, ordinal_data, sort_index);
|
||||
lnk_chunk_set_debugf(data_sect->arena, ilt_chunk, "ILT entry for %S.%u", dll->name, header->hint_or_ordinal);
|
||||
lnk_chunk_set_debugf(data_sect->arena, iat_chunk, "IAT entry for %S.%u", dll->name, header->hint_or_ordinal);
|
||||
|
||||
// associate chunks
|
||||
lnk_section_associate_chunks(data_sect, iat_chunk, ilt_chunk);
|
||||
@@ -410,6 +428,7 @@ lnk_import_table_push_func_static(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
// put together name look up entry
|
||||
String8 int_data = coff_make_import_lookup(data_sect->arena, header->hint_or_ordinal, header->func_name);
|
||||
LNK_Chunk *int_chunk = lnk_section_push_chunk_data(data_sect, int_table_chunk, int_data, str8_zero());
|
||||
lnk_chunk_set_debugf(data_sect->arena, int_chunk, "INT entry for %S.%S (Hint: %u)", dll->name, header->func_name, header->hint_or_ordinal);
|
||||
|
||||
// create symbol for lookup chunk
|
||||
String8 int_symbol_name = push_str8f(symtab->arena->v[0], "static.%S.%S.name", dll->name, header->func_name);
|
||||
@@ -450,6 +469,7 @@ lnk_import_table_push_func_static(LNK_ImportTable *imptab, LNK_SymbolTable *symt
|
||||
// generate jump thunk
|
||||
LNK_Chunk *jmp_thunk_chunk = lnk_emit_indirect_jump_thunk_x64(code_sect, code_table_chunk, iat_symbol);
|
||||
lnk_section_associate_chunks(data_sect, iat_chunk, jmp_thunk_chunk);
|
||||
lnk_chunk_set_debugf(data_sect->arena, jmp_thunk_chunk, "Jump thunk to %S.%S", dll->name, iat_symbol->name);
|
||||
|
||||
// push jump thunk symbol
|
||||
String8 jmp_thunk_symbol_name = push_str8_copy(symtab->arena->v[0], header->func_name);
|
||||
|
||||
@@ -411,7 +411,7 @@ THREAD_POOL_TASK_FUNC(lnk_obj_initer)
|
||||
chunk->flags = coff_sect->flags;
|
||||
chunk->u.leaf = data;
|
||||
chunk->obj = obj;
|
||||
lnk_chunk_set_debugf(arena, chunk, "%S: name: %S, obj_idx: 0x%llX isect: 0x%llX", cached_path, sect_name_arr[sect_idx], obj_idx, sect_idx);
|
||||
lnk_chunk_set_debugf(arena, chunk, "obj_idx %llx isect %llx", obj_idx, sect_idx);
|
||||
}
|
||||
|
||||
// :common_block
|
||||
@@ -427,7 +427,7 @@ THREAD_POOL_TASK_FUNC(lnk_obj_initer)
|
||||
master_common_block->associate = 0;
|
||||
master_common_block->u.list = push_array(arena, LNK_ChunkList, 1);
|
||||
master_common_block->obj = obj;
|
||||
lnk_chunk_set_debugf(arena, master_common_block, "%S: master common block", cached_path);
|
||||
lnk_chunk_set_debugf(arena, master_common_block, "master common block");
|
||||
|
||||
LNK_ChunkPtr *chunk_ptr_arr = push_array_no_zero(arena, LNK_ChunkPtr, chunk_count);
|
||||
for (U64 i = 0; i < chunk_count; ++i) {
|
||||
@@ -790,7 +790,7 @@ lnk_symbol_array_from_coff(Arena *arena,
|
||||
chunk_list->flags = chunk->flags;
|
||||
chunk_list->u.list = push_array(arena, LNK_ChunkList, 1);
|
||||
chunk_list->obj = obj;
|
||||
lnk_chunk_set_debugf(arena, chunk_list, "%S: function chunk list for %S", obj_path, symbol.name);
|
||||
lnk_chunk_set_debugf(arena, chunk_list, "function chunk list for %S", symbol.name);
|
||||
|
||||
// update properties on first chunk
|
||||
chunk->min_size = function_pad_min;
|
||||
@@ -838,7 +838,7 @@ lnk_symbol_array_from_coff(Arena *arena,
|
||||
split_chunk->flags = current->data->flags;
|
||||
split_chunk->u.leaf = right_data;
|
||||
split_chunk->obj = obj;
|
||||
lnk_chunk_set_debugf(arena, split_chunk, "%S: chunk split on function %S SECT%x SPLIT_POS %#llx", obj_path, symbol.name, symbol.section_number, split_pos);
|
||||
lnk_chunk_set_debugf(arena, split_chunk, "chunk split on function %S sect %x split pos %#llx", symbol.name, symbol.section_number, split_pos);
|
||||
|
||||
LNK_ChunkNode *split_node = push_array(arena, LNK_ChunkNode, 1);
|
||||
split_node->data = split_chunk;
|
||||
@@ -990,7 +990,7 @@ lnk_symbol_array_from_coff(Arena *arena,
|
||||
chunk->flags = master_common_block->flags;
|
||||
chunk->u.leaf = str8(0, parsed_symbol.value);
|
||||
chunk->obj = obj;
|
||||
lnk_chunk_set_debugf(arena, chunk, "%S: common block %S", obj_path, parsed_symbol.name);
|
||||
lnk_chunk_set_debugf(arena, chunk, "common block %S", parsed_symbol.name);
|
||||
lnk_chunk_list_push(arena, master_common_block->u.list, chunk);
|
||||
|
||||
LNK_DefinedSymbolFlags flags = 0;
|
||||
|
||||
@@ -338,6 +338,7 @@ lnk_section_table_push(LNK_SectionTable *st, String8 name, COFF_SectionFlags fla
|
||||
sect->is_loose = 1;
|
||||
|
||||
lnk_chunk_set_debugf(sect->arena, sect->root, "root chunk for %S", name);
|
||||
lnk_chunk_set_debugf(sect->arena, sect->nosort_chunk, "nosort chunk for %S", name);
|
||||
|
||||
ProfEnd();
|
||||
return sect;
|
||||
|
||||
Reference in New Issue
Block a user