From e34b2e8f223f8ca966031c22d32a8b04ca8fc5ad Mon Sep 17 00:00:00 2001 From: Peter Oberndorfer Date: Sat, 10 Mar 2007 11:13:23 +0100 Subject: [PATCH 1/1] dbghelp: use elf load_offset passed to dwarf2_parse to relocate addresses MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.5.0.2" This is a multi-part message in MIME format. --------------1.5.0.2 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit this is needed, because for prelinked binaries addresses in dwarf2 debug info are already relocated --- dlls/dbghelp/dwarf.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) --------------1.5.0.2 Content-Type: text/x-patch; name="e34b2e8f223f8ca966031c22d32a8b04ca8fc5ad.diff" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="e34b2e8f223f8ca966031c22d32a8b04ca8fc5ad.diff" diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index e4944e3..88d6a3f 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -178,6 +178,7 @@ typedef struct dwarf2_parse_context_s const struct elf_thunk_area*thunks; struct sparse_array abbrev_table; struct sparse_array debug_info_table; + unsigned long load_offset; unsigned long ref_offset; unsigned char word_size; } dwarf2_parse_context_t; @@ -1300,7 +1301,7 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, ext.u.uvalue = 0; symt_new_global_variable(subpgm->ctx->module, subpgm->compiland, name.u.string, !ext.u.uvalue, - subpgm->ctx->module->module.BaseOfImage + loc.offset, + subpgm->ctx->load_offset + loc.offset, 0, param_type); break; default: @@ -1383,7 +1384,7 @@ static void dwarf2_parse_subprogram_label(dwarf2_subprogram_t* subpgm, name.u.string = NULL; loc.kind = loc_absolute; - loc.offset = subpgm->ctx->module->module.BaseOfImage + low_pc.u.uvalue, + loc.offset = subpgm->ctx->load_offset + low_pc.u.uvalue, symt_add_function_point(subpgm->ctx->module, subpgm->func, SymTagLabel, &loc, name.u.string); } @@ -1406,7 +1407,7 @@ static void dwarf2_parse_inlined_subroutine(dwarf2_subprogram_t* subpgm, if (!dwarf2_find_attribute(subpgm->ctx, di, DW_AT_high_pc, &high_pc)) high_pc.u.uvalue = 0; block = symt_open_func_block(subpgm->ctx->module, subpgm->func, parent_block, - subpgm->ctx->module->module.BaseOfImage + low_pc.u.uvalue - subpgm->func->address, + subpgm->ctx->load_offset + low_pc.u.uvalue - subpgm->func->address, high_pc.u.uvalue - low_pc.u.uvalue); if (di->abbrev->have_child) /** any interest to not have child ? */ @@ -1459,7 +1460,7 @@ static void dwarf2_parse_subprogram_block(dwarf2_subprogram_t* subpgm, high_pc.u.uvalue = 0; block = symt_open_func_block(subpgm->ctx->module, subpgm->func, parent_block, - subpgm->ctx->module->module.BaseOfImage + low_pc.u.uvalue - subpgm->func->address, + subpgm->ctx->load_offset + low_pc.u.uvalue - subpgm->func->address, high_pc.u.uvalue - low_pc.u.uvalue); if (di->abbrev->have_child) /** any interest to not have child ? */ @@ -1546,7 +1547,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_parse_context_t* ctx, * (not the case for stabs), we just drop Wine's thunks here... * Actual thunks will be created in elf_module from the symbol table */ - if (elf_is_in_thunk_area(ctx->module->module.BaseOfImage + low_pc.u.uvalue, + if (elf_is_in_thunk_area(ctx->load_offset + low_pc.u.uvalue, ctx->thunks) >= 0) return NULL; if (!dwarf2_find_attribute(ctx, di, DW_AT_declaration, &is_decl)) @@ -1560,7 +1561,7 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_parse_context_t* ctx, if (!is_decl.u.uvalue) { subpgm.func = symt_new_function(ctx->module, compiland, name.u.string, - ctx->module->module.BaseOfImage + low_pc.u.uvalue, + ctx->load_offset + low_pc.u.uvalue, high_pc.u.uvalue - low_pc.u.uvalue, &sig_type->symt); di->symt = &subpgm.func->symt; @@ -1906,7 +1907,7 @@ static BOOL dwarf2_parse_line_numbers(const dwarf2_section_t* sections, end_sequence = TRUE; break; case DW_LNE_set_address: - address = ctx->module->module.BaseOfImage + dwarf2_parse_addr(&traverse); + address = ctx->load_offset + dwarf2_parse_addr(&traverse); break; case DW_LNE_define_file: FIXME("not handled %s\n", traverse.data); @@ -1936,7 +1937,8 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections, const dwarf2_comp_unit_t* comp_unit, struct module* module, const struct elf_thunk_area* thunks, - const unsigned char* comp_unit_cursor) + const unsigned char* comp_unit_cursor, + unsigned long load_offset) { dwarf2_parse_context_t ctx; dwarf2_traverse_context_t traverse; @@ -1964,6 +1966,7 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections, ctx.module = module; ctx.word_size = comp_unit->word_size; ctx.thunks = thunks; + ctx.load_offset = load_offset; ctx.ref_offset = comp_unit_cursor - sections[section_debug].address; traverse.start_data = comp_unit_cursor + sizeof(dwarf2_comp_unit_stream_t); @@ -1997,7 +2000,7 @@ static BOOL dwarf2_parse_compilation_unit(const dwarf2_section_t* sections, if (!dwarf2_find_attribute(&ctx, di, DW_AT_low_pc, &low_pc)) low_pc.u.uvalue = 0; di->symt = &symt_new_compiland(module, - module->module.BaseOfImage + low_pc.u.uvalue, + ctx.load_offset + low_pc.u.uvalue, source_new(module, comp_dir.u.string, name.u.string))->symt; if (di->abbrev->have_child) @@ -2206,7 +2209,7 @@ BOOL dwarf2_parse(struct module* module, unsigned long load_offset, comp_unit.word_size = *(unsigned char*) comp_unit_stream->word_size; dwarf2_parse_compilation_unit(section, &comp_unit, module, - thunks, comp_unit_cursor); + thunks, comp_unit_cursor, load_offset); comp_unit_cursor += comp_unit.length + sizeof(unsigned); } module->module.SymType = SymDia; --------------1.5.0.2--