name = MC_dwarf_attr_string(die, DW_AT_name);
frame->name = xbt_strdup(name);
+ // This is the base address for DWARF addresses.
+ // Relocated addresses are offset from this base address.
+ // See DWARF4 spec 7.5
+ void* base = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
+
// Variables are filled in the (recursive) call of MC_dwarf_handle_children:
frame->variables = xbt_dynar_new(sizeof(dw_variable_t), dw_variable_free_voidp);
- frame->high_pc = (void*) MC_dwarf_attr_addr(die, DW_AT_high_pc);
- frame->low_pc = (void*) MC_dwarf_attr_addr(die, DW_AT_low_pc);
+ frame->high_pc = ((char*) base) + MC_dwarf_attr_addr(die, DW_AT_high_pc);
+ frame->low_pc = ((char*) base) + MC_dwarf_attr_addr(die, DW_AT_low_pc);
frame->frame_base = MC_dwarf_at_location(die, DW_AT_frame_base);
frame->end = -1; // This one is now useless:
static void MC_make_functions_index(mc_object_info_t info) {
xbt_dynar_t index = xbt_dynar_new(sizeof(s_mc_function_index_item_t), NULL);
- // The base address of the function must be used to offset the addresses.
- // This should be fixed this in the frame_t structure instead.
- // Relocated addresses are offset for shared objets and constant for executables objects.
- // See DWARF4 spec 7.5
- void* offset = info->flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
-
// Populate the array:
dw_frame_t frame = NULL;
xbt_dict_cursor_t cursor = NULL;
if(frame->low_pc==NULL)
continue;
s_mc_function_index_item_t entry;
- entry.low_pc = (char*) frame->low_pc + (unsigned long) offset;
- entry.high_pc = (char*) frame->high_pc + (unsigned long) offset;
+ entry.low_pc = frame->low_pc;
+ entry.high_pc = frame->high_pc;
entry.function = frame;
xbt_dynar_push(index, &entry);
}