From 77e371c079408e265f1dfd2b0620dd8e76c23371 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 15 Aug 2013 08:46:35 -0600 Subject: [PATCH] start change to progspace independence This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) : Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update. --- gdb/ChangeLog | 106 +++++++++++++++++++++++++++++++++++++++++ gdb/ada-lang.c | 4 +- gdb/ada-tasks.c | 4 +- gdb/aix-thread.c | 5 +- gdb/arm-tdep.c | 4 +- gdb/auxv.c | 3 +- gdb/avr-tdep.c | 4 +- gdb/ax-gdb.c | 3 +- gdb/blockframe.c | 8 ++-- gdb/breakpoint.c | 8 ++-- gdb/bsd-uthread.c | 2 +- gdb/c-valprint.c | 3 +- gdb/coff-pe-read.c | 2 +- gdb/common/agent.c | 3 +- gdb/dbxread.c | 4 +- gdb/dwarf2loc.c | 2 +- gdb/dwarf2read.c | 2 +- gdb/elfread.c | 4 +- gdb/findvar.c | 4 +- gdb/frame.c | 2 +- gdb/frv-tdep.c | 4 +- gdb/glibc-tdep.c | 2 +- gdb/gnu-v3-abi.c | 5 +- gdb/hppa-hpux-tdep.c | 8 ++-- gdb/hppa-tdep.c | 2 +- gdb/infcmd.c | 2 +- gdb/jit.c | 12 +++-- gdb/linespec.c | 11 +++-- gdb/linux-nat.c | 4 +- gdb/linux-thread-db.c | 2 +- gdb/m32c-tdep.c | 11 ++--- gdb/m32r-tdep.c | 4 +- gdb/m68hc11-tdep.c | 2 +- gdb/machoread.c | 2 +- gdb/maint.c | 2 +- gdb/minsyms.c | 80 ++++++++++++++++++++----------- gdb/mips-linux-tdep.c | 2 +- gdb/mips-tdep.c | 2 +- gdb/objc-lang.c | 2 +- gdb/objfiles.c | 2 +- gdb/obsd-tdep.c | 3 +- gdb/p-valprint.c | 3 +- gdb/parse.c | 4 +- gdb/ppc-linux-tdep.c | 8 ++-- gdb/ppc-sysv-tdep.c | 2 +- gdb/printcmd.c | 44 ++++++++--------- gdb/proc-service.c | 3 +- gdb/psymtab.c | 14 +++--- gdb/ravenscar-thread.c | 3 +- gdb/remote.c | 4 +- gdb/sh64-tdep.c | 2 +- gdb/sol2-tdep.c | 3 +- gdb/solib-dsbt.c | 2 +- gdb/solib-frv.c | 4 +- gdb/solib-irix.c | 4 +- gdb/solib-som.c | 18 +++---- gdb/solib-spu.c | 6 +-- gdb/solib-svr4.c | 10 ++-- gdb/spu-tdep.c | 8 ++-- gdb/stabsread.c | 9 ++-- gdb/stack.c | 3 +- gdb/symfile-debug.c | 4 +- gdb/symfile.c | 9 ++-- gdb/symfile.h | 2 +- gdb/symmisc.c | 3 +- gdb/symtab.c | 58 +++++++++++----------- gdb/symtab.h | 14 +++++- gdb/tracepoint.c | 2 +- gdb/tui/tui-disasm.c | 13 ++--- gdb/valops.c | 2 +- gdb/value.c | 4 +- 71 files changed, 383 insertions(+), 223 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 40b819b20b2..0ce3186102f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,109 @@ +2014-02-26 Tom Tromey + + * ada-lang.c (ada_main_name): Update. + (ada_add_standard_exceptions): Update. + * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. + * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. + * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. + * auxv.c (ld_so_xfer_auxv): Update. + * avr-tdep.c (avr_scan_prologue): Update. + * ax-gdb.c (gen_var_ref): Update. + * blockframe.c (get_pc_function_start) + (find_pc_partial_function_gnu_ifunc): Update. + * breakpoint.c (create_overlay_event_breakpoint) + (create_longjmp_master_breakpoint) + (create_std_terminate_master_breakpoint) + (create_exception_master_breakpoint): Update. + * bsd-uthread.c (bsd_uthread_lookup_address): Update. + * c-valprint.c (c_val_print): Update. + * coff-pe-read.c (add_pe_forwarded_sym): Update. + * common/agent.c (agent_look_up_symbols): Update. + * dbxread.c (find_stab_function_addr, end_psymtab): Update. + * dwarf2loc.c (call_site_to_target_addr): Update. + * dwarf2read.c (dw2_find_pc_sect_symtab): Update. + * elfread.c (elf_gnu_ifunc_record_cache) + (elf_gnu_ifunc_resolve_by_got): Update. + * findvar.c (default_read_var_value): Update. + * frame.c (inside_main_func): Update. + * frv-tdep.c (frv_frame_this_id): Update. + * glibc-tdep.c (glibc_skip_solib_resolver): Update. + * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): + Update. + * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) + (hppa_hpux_find_dummy_bpaddr): Update. + * hppa-tdep.c (hppa_symbol_address): Update. + * infcmd.c (until_next_command): Update. + * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): + Update. + * linespec.c (minsym_found, add_minsym): Update. + * linux-nat.c (get_signo): Update. + * linux-thread-db.c (inferior_has_bug): Update. + * m32c-tdep.c (m32c_return_value) + (m32c_m16c_address_to_pointer): Update. + * m32r-tdep.c (m32r_frame_this_id): Update. + * m68hc11-tdep.c (m68hc11_get_register_info): Update. + * machoread.c (macho_resolve_oso_sym_with_minsym): Update. + * maint.c (maintenance_translate_address): Update. + * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. + (frob_address): New function. + (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, + frob_address. Rename parameter to "pc_in". + (compare_minimal_symbols, compact_minimal_symbols): Use raw + addresses. + (find_solib_trampoline_target, minimal_symbol_upper_bound): + Update. + * mips-linux-tdep.c (mips_linux_skip_resolver): Update. + * mips-tdep.c (mips_skip_pic_trampoline_code): Update. + * objc-lang.c (find_objc_msgsend): Update. + * objfiles.c (objfile_relocate1): Update. + * obsd-tdep.c (obsd_skip_solib_resolver): Update. + * p-valprint.c (pascal_val_print): Update. + * parse.c (write_exp_msymbol): Update. + * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) + (ppc_elfv2_skip_entrypoint): Update. + * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. + * printcmd.c (build_address_symbolic, msym_info) + (address_info): Update. + * proc-service.c (ps_pglobal_lookup): Update. + * psymtab.c (find_pc_sect_psymtab_closer) + (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): + Change msymbol parameter to bound_minimal_symbol. + * ravenscar-thread.c (get_running_thread_id): Update. + * remote.c (remote_check_symbols): Update. + * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw + address. + * sol2-tdep.c (sol2_skip_solib_resolver): Update. + * solib-dsbt.c (lm_base): Update. + * solib-frv.c (lm_base, main_got): Update. + * solib-irix.c (locate_base): Update. + * solib-som.c (som_solib_create_inferior_hook) + (link_map_start): Update. + * solib-spu.c (spu_enable_break, ocl_enable_break): Update. + * solib-svr4.c (elf_locate_base, enable_break): Update. + * spu-tdep.c (spu_get_overlay_table, spu_catch_start) + (flush_ea_cache): Update. + * stabsread.c (define_symbol, scan_file_globals): Update. + * stack.c (find_frame_funname): Update. + * symfile-debug.c (debug_qf_expand_symtabs_matching) + (debug_qf_find_pc_sect_symtab): Update. + * symfile.c (simple_read_overlay_table) + (simple_overlay_update): Update. + * symfile.h (struct quick_symbol_functions) + : Change type of msymbol to + bound_minimal_symbol. + * symmisc.c (dump_msymbols): Update. + * symtab.c (find_pc_sect_symtab_via_partial) + (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) + (search_symbols, print_msymbol_info): Update. + * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. + (MSYMBOL_VALUE_ADDRESS): Redefine. + (BMSYMBOL_VALUE_ADDRESS): New macro. + * tracepoint.c (scope_info): Update. + * tui/tui-disasm.c (tui_find_disassembly_address) + (tui_get_begin_asm_address): Update. + * valops.c (find_function_in_inferior): Update. + * value.c (value_static_field, value_fn_field): Update. + 2014-02-26 Tom Tromey * ada-lang.c (ada_update_initial_language): Update. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index baa5d8ce10f..92f437fce2c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -922,7 +922,7 @@ ada_main_name (void) CORE_ADDR main_program_name_addr; int err_code; - main_program_name_addr = MSYMBOL_VALUE_ADDRESS (msym.minsym); + main_program_name_addr = BMSYMBOL_VALUE_ADDRESS (msym); if (main_program_name_addr == 0) error (_("Invalid address for Ada main program name.")); @@ -12673,7 +12673,7 @@ ada_add_standard_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions) if (msymbol.minsym != NULL) { struct ada_exc_info info - = {standard_exc[i], MSYMBOL_VALUE_ADDRESS (msymbol.minsym)}; + = {standard_exc[i], BMSYMBOL_VALUE_ADDRESS (msymbol)}; VEC_safe_push (ada_exc_info, *exceptions, &info); } diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 89bdac8d0f6..8b37f518900 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -859,7 +859,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) if (msym.minsym != NULL) { data->known_tasks_kind = ADA_TASKS_ARRAY; - data->known_tasks_addr = MSYMBOL_VALUE_ADDRESS (msym.minsym); + data->known_tasks_addr = BMSYMBOL_VALUE_ADDRESS (msym); /* Try to get pointer type and array length from the symtab. */ sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN, @@ -904,7 +904,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) if (msym.minsym != NULL) { data->known_tasks_kind = ADA_TASKS_LIST; - data->known_tasks_addr = MSYMBOL_VALUE_ADDRESS (msym.minsym); + data->known_tasks_addr = BMSYMBOL_VALUE_ADDRESS (msym); data->known_tasks_length = 1; sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN, diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 0202a2471eb..444a0253066 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -49,6 +49,7 @@ #include "ppc-tdep.h" #include #include "observer.h" +#include "objfiles.h" #include #include @@ -313,7 +314,7 @@ pdc_symbol_addrs (pthdb_user_t user, pthdb_symbol_t *symbols, int count) fprintf_unfiltered (gdb_stdlog, " returning PDC_FAILURE\n"); return PDC_FAILURE; } - symbols[i].addr = MSYMBOL_VALUE_ADDRESS (ms.minsym); + symbols[i].addr = BMSYMBOL_VALUE_ADDRESS (ms); } if (debug_aix_thread) fprintf_unfiltered (gdb_stdlog, " symbols[%d].addr = %s\n", @@ -912,7 +913,7 @@ pd_enable (void) ms = lookup_minimal_symbol (stub_name, NULL, NULL); if (ms.minsym == NULL) return; - pd_brk_addr = MSYMBOL_VALUE_ADDRESS (ms.minsym); + pd_brk_addr = BMSYMBOL_VALUE_ADDRESS (ms); if (!create_thread_event_breakpoint (target_gdbarch (), pd_brk_addr)) return; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 4df28464be8..e3b1c3d58c7 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -472,7 +472,7 @@ skip_prologue_function (struct gdbarch *gdbarch, CORE_ADDR pc, int is_thumb) msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym != NULL - && MSYMBOL_VALUE_ADDRESS (msym.minsym) == pc + && BMSYMBOL_VALUE_ADDRESS (msym) == pc && MSYMBOL_LINKAGE_NAME (msym.minsym) != NULL) { const char *name = MSYMBOL_LINKAGE_NAME (msym.minsym); @@ -9280,7 +9280,7 @@ arm_skip_stub (struct frame_info *frame, CORE_ADDR pc) objfile = (sec == NULL) ? NULL : sec->objfile; minsym = lookup_minimal_symbol (target_name, NULL, objfile); if (minsym.minsym != NULL) - return MSYMBOL_VALUE_ADDRESS (minsym.minsym); + return BMSYMBOL_VALUE_ADDRESS (minsym); else return 0; } diff --git a/gdb/auxv.c b/gdb/auxv.c index 23966278253..ce0a71c77a9 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -27,6 +27,7 @@ #include "gdbcore.h" #include "observer.h" #include "filestuff.h" +#include "objfiles.h" #include "auxv.h" #include "elf/common.h" @@ -105,7 +106,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf, resides. DATA_ADDRESS is the inferior value present in `_dl_auxv', therefore the real inferior AUXV address. */ - pointer_address = MSYMBOL_VALUE_ADDRESS (msym.minsym); + pointer_address = BMSYMBOL_VALUE_ADDRESS (msym); /* The location of the _dl_auxv symbol may no longer be correct if ld.so runs at a different address than the one present in the diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index a637cf832d9..6e58f045d67 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -36,6 +36,7 @@ #include "regcache.h" #include #include "dis-asm.h" +#include "objfiles.h" /* AVR Background: @@ -624,8 +625,7 @@ avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, /* Resolve offset (in words) from __prologue_saves__ symbol. Which is a pushes count in `-mcall-prologues' mode */ - num_pushes = (AVR_MAX_PUSHES - - (i - MSYMBOL_VALUE_ADDRESS (msymbol.minsym)) / 2); + num_pushes = AVR_MAX_PUSHES - (i - BMSYMBOL_VALUE_ADDRESS (msymbol)) / 2; if (num_pushes > AVR_MAX_PUSHES) { diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index f2bcefab7d3..b77716dd9a8 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -41,6 +41,7 @@ #include "arch-utils.h" #include "cli/cli-utils.h" #include "linespec.h" +#include "objfiles.h" #include "valprint.h" #include "c-lang.h" @@ -719,7 +720,7 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax, error (_("Couldn't resolve symbol `%s'."), SYMBOL_PRINT_NAME (var)); /* Push the address of the variable. */ - ax_const_l (ax, MSYMBOL_VALUE_ADDRESS (msym.minsym)); + ax_const_l (ax, BMSYMBOL_VALUE_ADDRESS (msym)); value->kind = axs_lvalue_memory; } break; diff --git a/gdb/blockframe.c b/gdb/blockframe.c index ddfc7d6a662..0a9381e1ec2 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -104,7 +104,7 @@ get_pc_function_start (CORE_ADDR pc) msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol.minsym) { - CORE_ADDR fstart = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + CORE_ADDR fstart = BMSYMBOL_VALUE_ADDRESS (msymbol); if (find_pc_section (fstart)) return fstart; @@ -221,7 +221,7 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name, ALL_OBJFILES (objfile) { if (objfile->sf) - symtab = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol.minsym, + symtab = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol, mapped_pc, section, 0); if (symtab) break; @@ -235,7 +235,7 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name, if (f != NULL && (msymbol.minsym == NULL || (BLOCK_START (SYMBOL_BLOCK_VALUE (f)) - >= MSYMBOL_VALUE_ADDRESS (msymbol.minsym)))) + >= BMSYMBOL_VALUE_ADDRESS (msymbol)))) { cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); @@ -269,7 +269,7 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name, return 0; } - cache_pc_function_low = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + cache_pc_function_low = BMSYMBOL_VALUE_ADDRESS (msymbol); cache_pc_function_name = MSYMBOL_LINKAGE_NAME (msymbol.minsym); cache_pc_function_section = section; cache_pc_function_is_gnu_ifunc = (MSYMBOL_TYPE (msymbol.minsym) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 7006beb62a9..488064d95e2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3243,7 +3243,7 @@ create_overlay_event_breakpoint (void) bp_objfile_data->overlay_msym = m; } - addr = MSYMBOL_VALUE_ADDRESS (bp_objfile_data->overlay_msym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->overlay_msym); b = create_internal_breakpoint (get_objfile_arch (objfile), addr, bp_overlay_event, &internal_breakpoint_ops); @@ -3360,7 +3360,7 @@ create_longjmp_master_breakpoint (void) bp_objfile_data->longjmp_msym[i] = m; } - addr = MSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i].minsym); + addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]); b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master, &internal_breakpoint_ops); b->addr_string = xstrdup (func_name); @@ -3415,7 +3415,7 @@ create_std_terminate_master_breakpoint (void) bp_objfile_data->terminate_msym = m; } - addr = MSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym); b = create_internal_breakpoint (get_objfile_arch (objfile), addr, bp_std_terminate_master, &internal_breakpoint_ops); @@ -3515,7 +3515,7 @@ create_exception_master_breakpoint (void) bp_objfile_data->exception_msym = debug_hook; } - addr = MSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym); addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target); b = create_internal_breakpoint (gdbarch, addr, bp_exception_master, diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 473acbaa048..c73932a8a49 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -129,7 +129,7 @@ bsd_uthread_lookup_address (const char *name, struct objfile *objfile) sym = lookup_minimal_symbol (name, NULL, objfile); if (sym.minsym) - return MSYMBOL_VALUE_ADDRESS (sym.minsym); + return BMSYMBOL_VALUE_ADDRESS (sym); return 0; } diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 5f950f8dff5..f4694b07ca8 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -28,6 +28,7 @@ #include "c-lang.h" #include "cp-abi.h" #include "target.h" +#include "objfiles.h" /* A helper for c_textual_element_type. This checks the name of the @@ -316,7 +317,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, /* If 'symbol_print' is set, we did the work above. */ if (!options->symbol_print && (msymbol.minsym != NULL) - && (vt_address == MSYMBOL_VALUE_ADDRESS (msymbol.minsym))) + && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol))) { if (want_space) fputs_filtered (" ", stream); diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 7e4618902e0..e1a61b7e65d 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -244,7 +244,7 @@ add_pe_forwarded_sym (const char *sym_name, const char *forward_dll_name, " \"%s\" in dll \"%s\", pointing to \"%s\"\n"), sym_name, dll_name, forward_qualified_name); - vma = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + vma = BMSYMBOL_VALUE_ADDRESS (msymbol); msymtype = MSYMBOL_TYPE (msymbol.minsym); section = MSYMBOL_SECTION (msymbol.minsym); diff --git a/gdb/common/agent.c b/gdb/common/agent.c index fdede74542c..f553b947dbb 100644 --- a/gdb/common/agent.c +++ b/gdb/common/agent.c @@ -23,6 +23,7 @@ #include "defs.h" #include "target.h" #include "inferior.h" /* for non_stop */ +#include "objfiles.h" #endif #include @@ -103,7 +104,7 @@ agent_look_up_symbols (void *arg) (struct objfile *) arg); if (sym.minsym != NULL) - *addrp = MSYMBOL_VALUE_ADDRESS (sym.minsym); + *addrp = BMSYMBOL_VALUE_ADDRESS (sym); else #endif { diff --git a/gdb/dbxread.c b/gdb/dbxread.c index ba8616f7bed..e0e5c481f73 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1170,7 +1170,7 @@ find_stab_function_addr (char *namestring, const char *filename, msym = lookup_minimal_symbol (p, NULL, objfile); } - return msym.minsym == NULL ? 0 : MSYMBOL_VALUE_ADDRESS (msym.minsym); + return msym.minsym == NULL ? 0 : BMSYMBOL_VALUE_ADDRESS (msym); } static void @@ -2278,7 +2278,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst, } if (minsym.minsym) - pst->texthigh = (MSYMBOL_VALUE_ADDRESS (minsym.minsym) + pst->texthigh = (BMSYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym.minsym)); last_function_name = NULL; diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index e109ff66e1a..e91b764065d 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -605,7 +605,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, : MSYMBOL_PRINT_NAME (msym.minsym))); } - return MSYMBOL_VALUE_ADDRESS (msym.minsym); + return BMSYMBOL_VALUE_ADDRESS (msym); } case FIELD_LOC_KIND_PHYSADDR: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 52208d6dd5e..8c20f15f0fb 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -3981,7 +3981,7 @@ recursively_find_pc_sect_symtab (struct symtab *symtab, CORE_ADDR pc) static struct symtab * dw2_find_pc_sect_symtab (struct objfile *objfile, - struct minimal_symbol *msymbol, + struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin) diff --git a/gdb/elfread.c b/gdb/elfread.c index 4d2e290e863..7c4b17505ff 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -765,7 +765,7 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr) msym = lookup_minimal_symbol_by_pc (addr); if (msym.minsym == NULL) return 0; - if (MSYMBOL_VALUE_ADDRESS (msym.minsym) != addr) + if (BMSYMBOL_VALUE_ADDRESS (msym) != addr) return 0; /* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */ sect = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym)->the_bfd_section; @@ -891,7 +891,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) continue; if (MSYMBOL_TYPE (msym.minsym) != mst_slot_got_plt) continue; - pointer_address = MSYMBOL_VALUE_ADDRESS (msym.minsym); + pointer_address = BMSYMBOL_VALUE_ADDRESS (msym); plt = bfd_get_section_by_name (obfd, ".plt"); if (plt == NULL) diff --git a/gdb/findvar.c b/gdb/findvar.c index 56cbb2c26d0..a2a7bb7d6d6 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -573,11 +573,11 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) if (msym == NULL) error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var)); if (overlay_debugging) - addr = symbol_overlayed_address (MSYMBOL_VALUE_ADDRESS (msym), + addr = symbol_overlayed_address (BMSYMBOL_VALUE_ADDRESS (lookup_data.result), MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym)); else - addr = MSYMBOL_VALUE_ADDRESS (msym); + addr = BMSYMBOL_VALUE_ADDRESS (lookup_data.result); obj_section = MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym); if (obj_section diff --git a/gdb/frame.c b/gdb/frame.c index 40dc1d5e3dd..97d54e91a92 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2018,7 +2018,7 @@ inside_main_func (struct frame_info *this_frame) /* Make certain that the code, and not descriptor, address is returned. */ maddr = gdbarch_convert_from_func_ptr_addr (get_frame_arch (this_frame), - MSYMBOL_VALUE_ADDRESS (msymbol.minsym), + BMSYMBOL_VALUE_ADDRESS (msymbol), ¤t_target); return maddr == get_frame_func (this_frame); } diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index acb0ba3eb50..bd4dbdb2c1b 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -39,6 +39,7 @@ #include "infcall.h" #include "solib.h" #include "frv-tdep.h" +#include "objfiles.h" extern void _initialize_frv_tdep (void); @@ -1399,8 +1400,7 @@ frv_frame_this_id (struct frame_info *this_frame, /* Check if the stack is empty. */ msym_stack = lookup_minimal_symbol ("_stack", NULL, NULL); - if (msym_stack.minsym - && info->base == MSYMBOL_VALUE_ADDRESS (msym_stack.minsym)) + if (msym_stack.minsym && info->base == BMSYMBOL_VALUE_ADDRESS (msym_stack)) return; /* Hopefully the prologue analysis either correctly determined the diff --git a/gdb/glibc-tdep.c b/gdb/glibc-tdep.c index 99b504fda86..6d16c33625b 100644 --- a/gdb/glibc-tdep.c +++ b/gdb/glibc-tdep.c @@ -66,7 +66,7 @@ glibc_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) if (! fixup.minsym) fixup = lookup_minimal_symbol ("fixup", NULL, resolver.objfile); - if (fixup.minsym && MSYMBOL_VALUE_ADDRESS (fixup.minsym) == pc) + if (fixup.minsym && BMSYMBOL_VALUE_ADDRESS (fixup) == pc) return frame_unwind_caller_pc (get_current_frame ()); } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 35f8e7bd00e..e0be32843a5 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1131,8 +1131,7 @@ gnuv3_get_typeid (struct value *value) if (minsym.minsym == NULL) error (_("could not find typeinfo symbol for '%s'"), typename); - result = value_at_lazy (typeinfo_type, - MSYMBOL_VALUE_ADDRESS (minsym.minsym)); + result = value_at_lazy (typeinfo_type, BMSYMBOL_VALUE_ADDRESS (minsym)); } do_cleanups (cleanup); @@ -1236,7 +1235,7 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc) if (fn_sym.minsym == NULL) return 0; - method_stop_pc = MSYMBOL_VALUE_ADDRESS (fn_sym.minsym); + method_stop_pc = BMSYMBOL_VALUE_ADDRESS (fn_sym); /* Some targets have minimal symbols pointing to function descriptors (powerpc 64 for example). Make sure to retrieve the address diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c index e9f067d68fd..8d4686f0ccc 100644 --- a/gdb/hppa-hpux-tdep.c +++ b/gdb/hppa-hpux-tdep.c @@ -973,7 +973,7 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc, gdb_byte buf[2 * HPPA_INSN_SIZE]; int offset; - find_pc_partial_function (MSYMBOL_VALUE_ADDRESS (msym), &name, + find_pc_partial_function (MSYMBOL_VALUE_ADDRESS (obj, msym), &name, &begin, &end); if (name == NULL || begin == 0 || end == 0) @@ -1096,10 +1096,10 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr) find_pc_partial_function (addr, NULL, &func, NULL); ALL_OBJFILE_MSYMBOLS (sec->objfile, msym) { - u = find_unwind_entry (MSYMBOL_VALUE_ADDRESS (msym)); - if (func != MSYMBOL_VALUE_ADDRESS (msym) + u = find_unwind_entry (MSYMBOL_VALUE_ADDRESS (sec->objfile, msym)); + if (func != MSYMBOL_VALUE_ADDRESS (sec->objfile, msym) && (!u || u->stub_unwind.stub_type == 0)) - return MSYMBOL_VALUE_ADDRESS (msym); + return MSYMBOL_VALUE_ADDRESS (sec->objfile, msym); } } diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 05ca007bed7..e302ebb55ab 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -166,7 +166,7 @@ hppa_symbol_address(const char *sym) minsym = lookup_minimal_symbol (sym, NULL, NULL); if (minsym.minsym) - return MSYMBOL_VALUE_ADDRESS (minsym.minsym); + return BMSYMBOL_VALUE_ADDRESS (minsym); else return (CORE_ADDR)-1; } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 23b02a3ce20..c59d0be83bc 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1335,7 +1335,7 @@ until_next_command (int from_tty) if (msymbol.minsym == NULL) error (_("Execution is not within a known function.")); - tp->control.step_range_start = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + tp->control.step_range_start = BMSYMBOL_VALUE_ADDRESS (msymbol); tp->control.step_range_end = pc; } else diff --git a/gdb/jit.c b/gdb/jit.c index 53394c459d2..db6c1b0f63c 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -357,7 +357,8 @@ jit_read_descriptor (struct gdbarch *gdbarch, if (jit_debug) fprintf_unfiltered (gdb_stdlog, "jit_read_descriptor, descriptor_addr = %s\n", - paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (objf_data->descriptor))); + paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (ps_data->objfile, + objf_data->descriptor))); /* Figure out how big the descriptor is on the remote and how to read it. */ ptr_type = builtin_type (gdbarch)->builtin_data_ptr; @@ -366,7 +367,8 @@ jit_read_descriptor (struct gdbarch *gdbarch, desc_buf = alloca (desc_size); /* Read the descriptor. */ - err = target_read_memory (MSYMBOL_VALUE_ADDRESS (objf_data->descriptor), + err = target_read_memory (MSYMBOL_VALUE_ADDRESS (ps_data->objfile, + objf_data->descriptor), desc_buf, desc_size); if (err) { @@ -1026,13 +1028,13 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, assume we are not attached to a JIT. */ reg_symbol = lookup_minimal_symbol_and_objfile (jit_break_name); if (reg_symbol.minsym == NULL - || MSYMBOL_VALUE_ADDRESS (reg_symbol.minsym) == 0) + || BMSYMBOL_VALUE_ADDRESS (reg_symbol) == 0) return 1; desc_symbol = lookup_minimal_symbol (jit_descriptor_name, NULL, reg_symbol.objfile); if (desc_symbol.minsym == NULL - || MSYMBOL_VALUE_ADDRESS (desc_symbol.minsym) == 0) + || BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0) return 1; objf_data = get_jit_objfile_data (reg_symbol.objfile); @@ -1044,7 +1046,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, else objf_data = get_jit_objfile_data (ps_data->objfile); - addr = MSYMBOL_VALUE_ADDRESS (objf_data->register_code); + addr = MSYMBOL_VALUE_ADDRESS (ps_data->objfile, objf_data->register_code); if (jit_debug) fprintf_unfiltered (gdb_stdlog, diff --git a/gdb/linespec.c b/gdb/linespec.c index 70495c6d3a7..610809d44a0 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3417,7 +3417,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, CORE_ADDR pc; struct symtab_and_line sal; - sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (msymbol), + sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (objfile, msymbol), (struct obj_section *) 0, 0); sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); @@ -3498,6 +3498,9 @@ add_minsym (struct minimal_symbol *minsym, void *d) struct collect_minsyms *info = d; bound_minimal_symbol_d mo; + mo.minsym = minsym; + mo.objfile = info->objfile; + /* Exclude data symbols when looking for breakpoint locations. */ if (!info->list_mode) switch (minsym->type) @@ -3513,16 +3516,14 @@ add_minsym (struct minimal_symbol *minsym, void *d) before we decide to discard it. */ struct gdbarch *gdbarch = get_objfile_arch (info->objfile); CORE_ADDR addr = gdbarch_convert_from_func_ptr_addr - (gdbarch, MSYMBOL_VALUE_ADDRESS (minsym), + (gdbarch, BMSYMBOL_VALUE_ADDRESS (mo), ¤t_target); - if (addr == MSYMBOL_VALUE_ADDRESS (minsym)) + if (addr == BMSYMBOL_VALUE_ADDRESS (mo)) return; } } - mo.minsym = minsym; - mo.objfile = info->objfile; VEC_safe_push (bound_minimal_symbol_d, info->msyms, &mo); } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 4702bf5dafc..006614171be 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -67,6 +67,7 @@ #include "buffer.h" #include "target-descriptions.h" #include "filestuff.h" +#include "objfiles.h" #ifndef SPUFS_MAGIC #define SPUFS_MAGIC 0x23c9b64e @@ -5038,8 +5039,7 @@ get_signo (const char *name) if (ms.minsym == NULL) return 0; - if (target_read_memory (MSYMBOL_VALUE_ADDRESS (ms.minsym), - (gdb_byte *) &signo, + if (target_read_memory (BMSYMBOL_VALUE_ADDRESS (ms), (gdb_byte *) &signo, sizeof (signo)) != 0) return 0; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index e1c5bce1e8e..ca614a3e72f 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -574,7 +574,7 @@ inferior_has_bug (const char *ver_symbol, int ver_major_min, int ver_minor_min) if (version_msym.minsym == NULL) return 0; - version_addr = MSYMBOL_VALUE_ADDRESS (version_msym.minsym); + version_addr = BMSYMBOL_VALUE_ADDRESS (version_msym); got = target_read_string (version_addr, &version, 32, &err); if (err == 0 && memchr (version, 0, got) == &version[got -1]) { diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index d6bc4820cd0..2c7dbb820f5 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -40,6 +40,7 @@ #include "reggroups.h" #include "prologue-value.h" #include "target.h" +#include "objfiles.h" /* The m32c tdep structure. */ @@ -2247,8 +2248,7 @@ m32c_return_value (struct gdbarch *gdbarch, error (_("The return value is stored in memory at 'mem0', " "but GDB cannot find\n" "its address.")); - read_memory (MSYMBOL_VALUE_ADDRESS (mem0.minsym), readbuf, - valtype_len); + read_memory (BMSYMBOL_VALUE_ADDRESS (mem0), readbuf, valtype_len); } } @@ -2280,8 +2280,7 @@ m32c_return_value (struct gdbarch *gdbarch, error (_("The return value is stored in memory at 'mem0', " "but GDB cannot find\n" " its address.")); - write_memory (MSYMBOL_VALUE_ADDRESS (mem0.minsym), writebuf, - valtype_len); + write_memory (BMSYMBOL_VALUE_ADDRESS (mem0), writebuf, valtype_len); } } @@ -2507,7 +2506,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch, else { /* The trampoline's address is our pointer. */ - addr = MSYMBOL_VALUE_ADDRESS (tramp_msym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (tramp_msym); } } @@ -2560,7 +2559,7 @@ m32c_m16c_pointer_to_address (struct gdbarch *gdbarch, /* If we do have such a symbol, return its value as the function's true address. */ if (func_msym.minsym) - ptr = MSYMBOL_VALUE_ADDRESS (func_msym.minsym); + ptr = BMSYMBOL_VALUE_ADDRESS (func_msym); } } else diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 2af57748cfa..838d3d9c9c2 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -36,6 +36,7 @@ #include "regcache.h" #include "trad-frame.h" #include "dis-asm.h" +#include "objfiles.h" #include "gdb_assert.h" @@ -844,8 +845,7 @@ m32r_frame_this_id (struct frame_info *this_frame, /* Check if the stack is empty. */ msym_stack = lookup_minimal_symbol ("_stack", NULL, NULL); - if (msym_stack.minsym - && info->base == MSYMBOL_VALUE_ADDRESS (msym_stack.minsym)) + if (msym_stack.minsym && info->base == BMSYMBOL_VALUE_ADDRESS (msym_stack)) return; /* Hopefully the prologue analysis either correctly determined the diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 6f0092bb46e..9b7e1af2e3a 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -204,7 +204,7 @@ m68hc11_get_register_info (struct m68hc11_soft_reg *reg, const char *name) msymbol = lookup_minimal_symbol (name, NULL, NULL); if (msymbol.minsym) { - reg->addr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + reg->addr = BMSYMBOL_VALUE_ADDRESS (msymbol); reg->name = xstrdup (name); /* Keep track of the address range for soft registers. */ diff --git a/gdb/machoread.c b/gdb/machoread.c index f189e99e10c..f7194e250ae 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -441,7 +441,7 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym) return 0; } else - return MSYMBOL_VALUE_ADDRESS (msym.minsym); + return BMSYMBOL_VALUE_ADDRESS (msym); } /* Add oso file OSO/ABFD as a symbol file. */ diff --git a/gdb/maint.c b/gdb/maint.c index b4225d95058..873c33cce9c 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -492,7 +492,7 @@ maintenance_translate_address (char *arg, int from_tty) { const char *symbol_name = MSYMBOL_PRINT_NAME (sym.minsym); const char *symbol_offset - = pulongest (address - MSYMBOL_VALUE_ADDRESS (sym.minsym)); + = pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym)); sect = MSYMBOL_OBJ_SECTION(sym.objfile, sym.minsym); if (sect != NULL) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 8335d51dc7b..aa6df11fc99 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -407,7 +407,7 @@ lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name, msymbol != NULL; msymbol = msymbol->hash_next) { - if (MSYMBOL_VALUE_ADDRESS (msymbol) == pc + if (MSYMBOL_VALUE_ADDRESS (objfile, msymbol) == pc && strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0) return msymbol; } @@ -454,6 +454,28 @@ lookup_minimal_symbol_solib_trampoline (const char *name, return found_symbol; } +/* A helper function that makes *PC section-relative. This searches + the sections of OBJFILE and if *PC is in a section, it subtracts + the section offset and returns true. Otherwise it returns + false. */ + +static int +frob_address (struct objfile *objfile, CORE_ADDR *pc) +{ + struct obj_section *iter; + + ALL_OBJFILE_OSECTIONS (objfile, iter) + { + if (*pc >= obj_section_addr (iter) && *pc < obj_section_endaddr (iter)) + { + *pc -= obj_section_offset (iter); + return 1; + } + } + + return 0; +} + /* Search through the minimal symbol table for each objfile and find the symbol whose address is the largest address that is still less than or equal to PC, and matches SECTION (which is not NULL). @@ -470,7 +492,7 @@ lookup_minimal_symbol_solib_trampoline (const char *name, Otherwise prefer mst_text symbols. */ static struct bound_minimal_symbol -lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, +lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in, struct obj_section *section, int want_trampoline) { @@ -502,6 +524,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, objfile != NULL; objfile = objfile_separate_debug_iterate (section->objfile, objfile)) { + CORE_ADDR pc = pc_in; + /* If this objfile has a minimal symbol table, go search it using a binary search. Note that a minimal symbol table always consists of at least two symbols, a "real" symbol and the terminating @@ -534,16 +558,16 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, Warning: this code is trickier than it would appear at first. */ - /* Should also require that pc is <= end of objfile. FIXME! */ - if (pc >= MSYMBOL_VALUE_ADDRESS (&msymbol[lo])) + if (frob_address (objfile, &pc) + && pc >= MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[lo])) { - while (MSYMBOL_VALUE_ADDRESS (&msymbol[hi]) > pc) + while (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) > pc) { /* pc is still strictly less than highest address. */ /* Note "new" will always be >= lo. */ new = (lo + hi) / 2; - if ((MSYMBOL_VALUE_ADDRESS (&msymbol[new]) >= pc) || - (lo == new)) + if ((MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[new]) >= pc) + || (lo == new)) { hi = new; } @@ -557,8 +581,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, hi to point to the last one. That way we can find the right symbol if it has an index greater than hi. */ while (hi < objfile->minimal_symbol_count - 1 - && (MSYMBOL_VALUE_ADDRESS (&msymbol[hi]) - == MSYMBOL_VALUE_ADDRESS (&msymbol[hi + 1]))) + && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) + == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi + 1]))) hi++; /* Skip various undesirable symbols. */ @@ -606,8 +630,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, && MSYMBOL_TYPE (&msymbol[hi - 1]) == want_type && (MSYMBOL_SIZE (&msymbol[hi]) == MSYMBOL_SIZE (&msymbol[hi - 1])) - && (MSYMBOL_VALUE_ADDRESS (&msymbol[hi]) - == MSYMBOL_VALUE_ADDRESS (&msymbol[hi - 1])) + && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) + == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi - 1])) && (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) == MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1]))) { @@ -636,9 +660,9 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, the cancellable variants, but both have sizes. */ if (hi > 0 && MSYMBOL_SIZE (&msymbol[hi]) != 0 - && pc >= (MSYMBOL_VALUE_ADDRESS (&msymbol[hi]) + && pc >= (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) + MSYMBOL_SIZE (&msymbol[hi])) - && pc < (MSYMBOL_VALUE_ADDRESS (&msymbol[hi - 1]) + && pc < (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi - 1]) + MSYMBOL_SIZE (&msymbol[hi - 1]))) { hi--; @@ -668,7 +692,7 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, if (hi >= 0 && MSYMBOL_SIZE (&msymbol[hi]) != 0 - && pc >= (MSYMBOL_VALUE_ADDRESS (&msymbol[hi]) + && pc >= (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) + MSYMBOL_SIZE (&msymbol[hi]))) { if (best_zero_sized != -1) @@ -684,8 +708,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, if (hi >= 0 && ((best_symbol == NULL) || - (MSYMBOL_VALUE_ADDRESS (best_symbol) < - MSYMBOL_VALUE_ADDRESS (&msymbol[hi])))) + (MSYMBOL_VALUE_RAW_ADDRESS (best_symbol) < + MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi])))) { best_symbol = &msymbol[hi]; best_objfile = objfile; @@ -981,11 +1005,11 @@ compare_minimal_symbols (const void *fn1p, const void *fn2p) fn1 = (const struct minimal_symbol *) fn1p; fn2 = (const struct minimal_symbol *) fn2p; - if (MSYMBOL_VALUE_ADDRESS (fn1) < MSYMBOL_VALUE_ADDRESS (fn2)) + if (MSYMBOL_VALUE_RAW_ADDRESS (fn1) < MSYMBOL_VALUE_RAW_ADDRESS (fn2)) { return (-1); /* addr 1 is less than addr 2. */ } - else if (MSYMBOL_VALUE_ADDRESS (fn1) > MSYMBOL_VALUE_ADDRESS (fn2)) + else if (MSYMBOL_VALUE_RAW_ADDRESS (fn1) > MSYMBOL_VALUE_RAW_ADDRESS (fn2)) { return (1); /* addr 1 is greater than addr 2. */ } @@ -1085,8 +1109,9 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount, copyfrom = copyto = msymbol; while (copyfrom < msymbol + mcount - 1) { - if (MSYMBOL_VALUE_ADDRESS (copyfrom) - == MSYMBOL_VALUE_ADDRESS ((copyfrom + 1)) + if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom) + == MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1)) + && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1) && strcmp (MSYMBOL_LINKAGE_NAME (copyfrom), MSYMBOL_LINKAGE_NAME ((copyfrom + 1))) == 0) { @@ -1326,7 +1351,7 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc) || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc) && strcmp (MSYMBOL_LINKAGE_NAME (msymbol), MSYMBOL_LINKAGE_NAME (tsymbol)) == 0) - return MSYMBOL_VALUE_ADDRESS (msymbol); + return MSYMBOL_VALUE_ADDRESS (objfile, msymbol); /* Also handle minimal symbols pointing to function descriptors. */ if (MSYMBOL_TYPE (msymbol) == mst_data @@ -1337,11 +1362,11 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc) func = gdbarch_convert_from_func_ptr_addr (get_objfile_arch (objfile), - MSYMBOL_VALUE_ADDRESS (msymbol), + MSYMBOL_VALUE_ADDRESS (objfile, msymbol), ¤t_target); /* Ignore data symbols that are not function descriptors. */ - if (func != MSYMBOL_VALUE_ADDRESS (msymbol)) + if (func != MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) return func; } } @@ -1367,7 +1392,7 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym) of the section, as the end of the function. */ if (MSYMBOL_SIZE (minsym.minsym) != 0) - return MSYMBOL_VALUE_ADDRESS (minsym.minsym) + MSYMBOL_SIZE (minsym.minsym); + return BMSYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym.minsym); /* Step over other symbols at this same address, and symbols in other sections, to find the next symbol in this section with a @@ -1377,16 +1402,17 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym) section = MSYMBOL_SECTION (msymbol); for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++) { - if (MSYMBOL_VALUE_ADDRESS (msymbol + i) != MSYMBOL_VALUE_ADDRESS (msymbol) + if ((MSYMBOL_VALUE_RAW_ADDRESS (msymbol + i) + != MSYMBOL_VALUE_RAW_ADDRESS (msymbol)) && MSYMBOL_SECTION (msymbol + i) == section) break; } obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym); if (MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL - && (MSYMBOL_VALUE_ADDRESS (msymbol + i) + && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i) < obj_section_endaddr (obj_section))) - result = MSYMBOL_VALUE_ADDRESS (msymbol + i); + result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i); else /* We got the start address from the last msymbol in the objfile. So the end address is the end of the section. */ diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 89c578e9706..61bea6c4d6f 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -826,7 +826,7 @@ mips_linux_skip_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) resolver = lookup_minimal_symbol ("__dl_runtime_resolve", NULL, NULL); - if (resolver.minsym && MSYMBOL_VALUE_ADDRESS (resolver.minsym) == pc) + if (resolver.minsym && BMSYMBOL_VALUE_ADDRESS (resolver) == pc) return frame_unwind_caller_pc (get_current_frame ()); return glibc_skip_solib_resolver (gdbarch, pc); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 7380ee12d64..606b150caac 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -7635,7 +7635,7 @@ mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc) which jumps to foo. */ msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym == NULL - || MSYMBOL_VALUE_ADDRESS (msym.minsym) != pc + || BMSYMBOL_VALUE_ADDRESS (msym) != pc || MSYMBOL_LINKAGE_NAME (msym.minsym) == NULL || strncmp (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.", 5) != 0) return 0; diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 54a5acfa8ce..43278956a4d 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1276,7 +1276,7 @@ find_objc_msgsend (void) continue; } - methcalls[i].begin = MSYMBOL_VALUE_ADDRESS (func.minsym); + methcalls[i].begin = BMSYMBOL_VALUE_ADDRESS (func); methcalls[i].end = minimal_symbol_upper_bound (func); } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index dba13fbbfba..db0c7206b00 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -805,7 +805,7 @@ objfile_relocate1 (struct objfile *objfile, ALL_OBJFILE_MSYMBOLS (objfile, msym) if (MSYMBOL_SECTION (msym) >= 0) - SET_MSYMBOL_VALUE_ADDRESS (msym, (MSYMBOL_VALUE_ADDRESS (msym) + SET_MSYMBOL_VALUE_ADDRESS (msym, (MSYMBOL_VALUE_ADDRESS (objfile, msym) + ANOFFSET (delta, MSYMBOL_SECTION (msym)))); } diff --git a/gdb/obsd-tdep.c b/gdb/obsd-tdep.c index fc100e22e1b..b94ee41ab69 100644 --- a/gdb/obsd-tdep.c +++ b/gdb/obsd-tdep.c @@ -20,6 +20,7 @@ #include "defs.h" #include "frame.h" #include "symtab.h" +#include "objfiles.h" #include "obsd-tdep.h" @@ -29,7 +30,7 @@ obsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) struct bound_minimal_symbol msym; msym = lookup_minimal_symbol("_dl_bind", NULL, NULL); - if (msym.minsym && MSYMBOL_VALUE_ADDRESS (msym.minsym) == pc) + if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc) return frame_unwind_caller_pc (get_current_frame ()); else return find_solib_trampoline_target (get_current_frame (), pc); diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 5300d6b5f16..70eb3a8c677 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -38,6 +38,7 @@ #include "cp-abi.h" #include "cp-support.h" #include "exceptions.h" +#include "objfiles.h" /* Decorations for Pascal. */ @@ -227,7 +228,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr, /* If 'symbol_print' is set, we did the work above. */ if (!options->symbol_print && (msymbol.minsym != NULL) - && (vt_address == MSYMBOL_VALUE_ADDRESS (msymbol.minsym))) + && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol))) { if (want_space) fputs_filtered (" ", stream); diff --git a/gdb/parse.c b/gdb/parse.c index a40fae57ee0..c6e25a9d8c7 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -502,7 +502,7 @@ write_exp_msymbol (struct bound_minimal_symbol bound_msym) struct objfile *objfile = bound_msym.objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); - CORE_ADDR addr = MSYMBOL_VALUE_ADDRESS (msymbol); + CORE_ADDR addr = BMSYMBOL_VALUE_ADDRESS (bound_msym); struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol); enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol); CORE_ADDR pc; @@ -519,7 +519,7 @@ write_exp_msymbol (struct bound_minimal_symbol bound_msym) if (ifunc_msym.minsym != NULL && MSYMBOL_TYPE (ifunc_msym.minsym) == mst_text_gnu_ifunc - && MSYMBOL_VALUE_ADDRESS (ifunc_msym.minsym) == pc) + && BMSYMBOL_VALUE_ADDRESS (ifunc_msym) == pc) { /* A function descriptor has been resolved but PC is still in the STT_GNU_IFUNC resolver body (such as because inferior does not diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index dee6938cf54..08c53427a0a 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -919,9 +919,9 @@ ppc_elfv2_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR pc) if (MSYMBOL_TARGET_FLAG_1 (fun.minsym)) local_entry_offset = 8; - if (MSYMBOL_VALUE_ADDRESS (fun.minsym) <= pc - && pc < MSYMBOL_VALUE_ADDRESS (fun.minsym) + local_entry_offset) - return MSYMBOL_VALUE_ADDRESS (fun.minsym) + local_entry_offset; + if (BMSYMBOL_VALUE_ADDRESS (fun) <= pc + && pc < BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset) + return BMSYMBOL_VALUE_ADDRESS (fun) + local_entry_offset; return pc; } @@ -1028,7 +1028,7 @@ ppc_linux_spe_context_lookup (struct objfile *objfile) { spe_context_objfile = objfile; spe_context_lm_addr = svr4_fetch_objfile_link_map (objfile); - spe_context_offset = MSYMBOL_VALUE_ADDRESS (sym.minsym); + spe_context_offset = BMSYMBOL_VALUE_ADDRESS (sym); spe_context_cache_ptid = minus_one_ptid; spe_context_cache_address = 0; return; diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 124e4fae39f..1a880a65754 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -1097,7 +1097,7 @@ convert_code_addr_to_desc_addr (CORE_ADDR code_addr, CORE_ADDR *desc_addr) if (fn.minsym == NULL) return 0; /* Found a descriptor. */ - (*desc_addr) = MSYMBOL_VALUE_ADDRESS (fn.minsym); + (*desc_addr) = BMSYMBOL_VALUE_ADDRESS (fn); return 1; } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index ec0d6c1188f..87b14488b0c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -631,7 +631,7 @@ build_address_symbolic (struct gdbarch *gdbarch, int *line, /* OUT */ int *unmapped) /* OUT */ { - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; struct symbol *symbol; CORE_ADDR name_location = 0; struct obj_section *section = NULL; @@ -661,7 +661,7 @@ build_address_symbolic (struct gdbarch *gdbarch, save some memory, but for many debug format--ELF/DWARF or anything/stabs--it would be inconvenient to eliminate those minimal symbols anyway). */ - msymbol = lookup_minimal_symbol_by_pc_section (addr, section).minsym; + msymbol = lookup_minimal_symbol_by_pc_section (addr, section); symbol = find_pc_sect_function (addr, section); if (symbol) @@ -680,40 +680,40 @@ build_address_symbolic (struct gdbarch *gdbarch, name_temp = SYMBOL_LINKAGE_NAME (symbol); } - if (msymbol != NULL - && MSYMBOL_HAS_SIZE (msymbol) - && MSYMBOL_SIZE (msymbol) == 0 - && MSYMBOL_TYPE (msymbol) != mst_text - && MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc - && MSYMBOL_TYPE (msymbol) != mst_file_text) - msymbol = NULL; + if (msymbol.minsym != NULL + && MSYMBOL_HAS_SIZE (msymbol.minsym) + && MSYMBOL_SIZE (msymbol.minsym) == 0 + && MSYMBOL_TYPE (msymbol.minsym) != mst_text + && MSYMBOL_TYPE (msymbol.minsym) != mst_text_gnu_ifunc + && MSYMBOL_TYPE (msymbol.minsym) != mst_file_text) + msymbol.minsym = NULL; - if (msymbol != NULL) + if (msymbol.minsym != NULL) { - if (MSYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL) + if (BMSYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL) { /* If this is a function (i.e. a code address), strip out any non-address bits. For instance, display a pointer to the first instruction of a Thumb function as ; the second instruction will be , even though the pointer is . This matches the ISA behavior. */ - if (MSYMBOL_TYPE (msymbol) == mst_text - || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc - || MSYMBOL_TYPE (msymbol) == mst_file_text - || MSYMBOL_TYPE (msymbol) == mst_solib_trampoline) + if (MSYMBOL_TYPE (msymbol.minsym) == mst_text + || MSYMBOL_TYPE (msymbol.minsym) == mst_text_gnu_ifunc + || MSYMBOL_TYPE (msymbol.minsym) == mst_file_text + || MSYMBOL_TYPE (msymbol.minsym) == mst_solib_trampoline) addr = gdbarch_addr_bits_remove (gdbarch, addr); /* The msymbol is closer to the address than the symbol; use the msymbol instead. */ symbol = 0; - name_location = MSYMBOL_VALUE_ADDRESS (msymbol); + name_location = BMSYMBOL_VALUE_ADDRESS (msymbol); if (do_demangle || asm_demangle) - name_temp = MSYMBOL_PRINT_NAME (msymbol); + name_temp = MSYMBOL_PRINT_NAME (msymbol.minsym); else - name_temp = MSYMBOL_LINKAGE_NAME (msymbol); + name_temp = MSYMBOL_LINKAGE_NAME (msymbol.minsym); } } - if (symbol == NULL && msymbol == NULL) + if (symbol == NULL && msymbol.minsym == NULL) return 1; /* If the nearest symbol is too far away, don't print anything symbolic. */ @@ -1126,7 +1126,7 @@ sym_info (char *arg, int from_tty) struct cleanup *old_chain; matches = 1; - offset = sect_addr - MSYMBOL_VALUE_ADDRESS (msymbol); + offset = sect_addr - MSYMBOL_VALUE_ADDRESS (objfile, msymbol); mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped"); sec_name = osect->the_bfd_section->name; msym_name = MSYMBOL_PRINT_NAME (msymbol); @@ -1225,7 +1225,7 @@ address_info (char *exp, int from_tty) struct objfile *objfile = msymbol.objfile; gdbarch = get_objfile_arch (objfile); - load_addr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + load_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); printf_filtered ("Symbol \""); fprintf_symbol_filtered (gdb_stdout, exp, @@ -1367,7 +1367,7 @@ address_info (char *exp, int from_tty) else { section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym); - load_addr = MSYMBOL_VALUE_ADDRESS (msym.minsym); + load_addr = BMSYMBOL_VALUE_ADDRESS (msym); if (section && (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) diff --git a/gdb/proc-service.c b/gdb/proc-service.c index 96e4fe0b48e..09cfc79198f 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -24,6 +24,7 @@ #include "symtab.h" #include "target.h" #include "regcache.h" +#include "objfiles.h" #include "gdb_proc_service.h" @@ -207,7 +208,7 @@ ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj, result = PS_NOSYM; else { - *sym_addr = core_addr_to_ps_addr (MSYMBOL_VALUE_ADDRESS (ms.minsym)); + *sym_addr = core_addr_to_ps_addr (BMSYMBOL_VALUE_ADDRESS (ms)); result = PS_OK; } diff --git a/gdb/psymtab.c b/gdb/psymtab.c index a1e584e844b..2787f4cf8d3 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -226,7 +226,7 @@ static struct partial_symtab * find_pc_sect_psymtab_closer (struct objfile *objfile, CORE_ADDR pc, struct obj_section *section, struct partial_symtab *pst, - struct minimal_symbol *msymbol) + struct bound_minimal_symbol msymbol) { struct partial_symtab *tpst; struct partial_symtab *best_pst = pst; @@ -242,7 +242,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, section == 0) /* Can't validate section this way. */ return pst; - if (msymbol == NULL) + if (msymbol.minsym == NULL) return (pst); /* The code range of partial symtabs sometimes overlap, so, in @@ -266,7 +266,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, p = find_pc_sect_psymbol (objfile, tpst, pc, section); if (p != NULL && SYMBOL_VALUE_ADDRESS (p) - == MSYMBOL_VALUE_ADDRESS (msymbol)) + == BMSYMBOL_VALUE_ADDRESS (msymbol)) return tpst; /* Also accept the textlow value of a psymtab as a @@ -305,7 +305,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile, static struct partial_symtab * find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, struct obj_section *section, - struct minimal_symbol *msymbol) + struct bound_minimal_symbol msymbol) { struct partial_symtab *pst; @@ -320,7 +320,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, /* FIXME: addrmaps currently do not handle overlayed sections, so fall back to the non-addrmap case if we're debugging overlays and the addrmap returned the wrong section. */ - if (overlay_debugging && msymbol && section) + if (overlay_debugging && msymbol.minsym && section) { struct partial_symbol *p; @@ -331,7 +331,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, p = find_pc_sect_psymbol (objfile, pst, pc, section); if (!p || SYMBOL_VALUE_ADDRESS (p) - != MSYMBOL_VALUE_ADDRESS (msymbol)) + != BMSYMBOL_VALUE_ADDRESS (msymbol)) goto next; } @@ -373,7 +373,7 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc, static struct symtab * find_pc_sect_symtab_from_partial (struct objfile *objfile, - struct minimal_symbol *msymbol, + struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin) { diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index d150412005b..01b5d811dda 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -30,6 +30,7 @@ #include "gdbcmd.h" #include "top.h" #include "regcache.h" +#include "objfiles.h" /* If non-null, ravenscar task support is enabled. */ static int ravenscar_task_support = 1; @@ -164,7 +165,7 @@ get_running_thread_id (void) if (!object_msym.minsym) return 0; - object_addr = MSYMBOL_VALUE_ADDRESS (object_msym.minsym); + object_addr = BMSYMBOL_VALUE_ADDRESS (object_msym); object_size = TYPE_LENGTH (builtin_type_void_data_ptr); buf_size = object_size; buf = alloca (buf_size); diff --git a/gdb/remote.c b/gdb/remote.c index 8e9ef64e3d3..e03d3bf988a 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3701,6 +3701,8 @@ remote_check_symbols (void) while (strncmp (reply, "qSymbol:", 8) == 0) { + struct bound_minimal_symbol sym; + tmp = &reply[8]; end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2); msg[end] = '\0'; @@ -3710,7 +3712,7 @@ remote_check_symbols (void) else { int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; - CORE_ADDR sym_addr = MSYMBOL_VALUE_ADDRESS (sym.minsym); + CORE_ADDR sym_addr = BMSYMBOL_VALUE_ADDRESS (sym); /* If this is a function address, return the start of code instead of any data function descriptor. */ diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c index cf93d53132e..9f115e0174d 100644 --- a/gdb/sh64-tdep.c +++ b/gdb/sh64-tdep.c @@ -224,7 +224,7 @@ sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym) if (((elf_symbol_type *)(sym))->internal_elf_sym.st_other == STO_SH5_ISA32) { MSYMBOL_TARGET_FLAG_1 (msym) = 1; - SET_MSYMBOL_VALUE_ADDRESS (msym, MSYMBOL_VALUE_ADDRESS (msym) | 1); + SET_MSYMBOL_VALUE_ADDRESS (msym, MSYMBOL_VALUE_RAW_ADDRESS (msym) | 1); } } diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c index a4efd42acf3..bf7d6a128f1 100644 --- a/gdb/sol2-tdep.c +++ b/gdb/sol2-tdep.c @@ -21,6 +21,7 @@ #include "frame.h" #include "symtab.h" #include "inferior.h" +#include "objfiles.h" #include "sol2-tdep.h" @@ -30,7 +31,7 @@ sol2_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) struct bound_minimal_symbol msym; msym = lookup_minimal_symbol("elf_bndr", NULL, NULL); - if (msym.minsym && MSYMBOL_VALUE_ADDRESS (msym.minsym) == pc) + if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc) return frame_unwind_caller_pc (get_current_frame ()); return 0; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 61ccc4a2cca..0217a94ef29 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -572,7 +572,7 @@ lm_base (void) if (got_sym.minsym != 0) { - addr = MSYMBOL_VALUE_ADDRESS (got_sym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (got_sym); if (solib_dsbt_debug) fprintf_unfiltered (gdb_stdlog, "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n", diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 0b111bccffd..9724a3c7475 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -292,7 +292,7 @@ lm_base (void) return 0; } - addr = MSYMBOL_VALUE_ADDRESS (got_sym.minsym) + 8; + addr = BMSYMBOL_VALUE_ADDRESS (got_sym) + 8; if (solib_frv_debug) fprintf_unfiltered (gdb_stdlog, @@ -926,7 +926,7 @@ main_got (void) if (got_sym.minsym == 0) return 0; - return MSYMBOL_VALUE_ADDRESS (got_sym.minsym); + return BMSYMBOL_VALUE_ADDRESS (got_sym); } /* Find the global pointer for the given function address ADDR. */ diff --git a/gdb/solib-irix.c b/gdb/solib-irix.c index d6a4c699149..6266ee00c3d 100644 --- a/gdb/solib-irix.c +++ b/gdb/solib-irix.c @@ -285,9 +285,9 @@ locate_base (void) CORE_ADDR address = 0; msymbol = lookup_minimal_symbol (DEBUG_BASE, NULL, symfile_objfile); - if ((msymbol.minsym != NULL) && (MSYMBOL_VALUE_ADDRESS (msymbol.minsym) != 0)) + if ((msymbol.minsym != NULL) && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) { - address = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + address = BMSYMBOL_VALUE_ADDRESS (msymbol); } return (address); } diff --git a/gdb/solib-som.c b/gdb/solib-som.c index d9e41190394..cba50d1886f 100644 --- a/gdb/solib-som.c +++ b/gdb/solib-som.c @@ -219,7 +219,7 @@ som_solib_create_inferior_hook (int from_tty) if (msymbol.minsym == NULL) goto keep_going; - anaddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol); store_unsigned_integer (buf, 4, byte_order, ptid_get_pid (inferior_ptid)); status = target_write_memory (anaddr, buf, 4); if (status != 0) @@ -251,7 +251,7 @@ Suggest linking with /opt/langtools/lib/end.o.\n\ GDB will be unable to track shl_load/shl_unload calls")); goto keep_going; } - anaddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol); dld_cache.hook.address = anaddr; /* Grrr, this might not be an export symbol! We have to find the @@ -275,7 +275,7 @@ Suggest linking with /opt/langtools/lib/end.o.\n\ GDB will be unable to track shl_load/shl_unload calls")); goto keep_going; } - anaddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol); status = target_write_memory (anaddr, buf, 4); /* Now set a shlib_event breakpoint at __d_trap so we can track @@ -290,7 +290,7 @@ GDB will be unable to track shl_load/shl_unload calls")); goto keep_going; } create_solib_event_breakpoint (target_gdbarch (), - MSYMBOL_VALUE_ADDRESS (msymbol.minsym)); + BMSYMBOL_VALUE_ADDRESS (msymbol)); /* We have all the support usually found in end.o, so we can track shl_load and shl_unload calls. */ @@ -306,7 +306,7 @@ keep_going: error (_("Unable to find __dld_flags symbol in object file.")); } - anaddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol); /* Read the current contents. */ status = target_read_memory (anaddr, buf, 4); @@ -351,7 +351,7 @@ manpage for methods to privately map shared library text.")); if (msymbol.minsym == NULL) error (_("Unable to find _start symbol in object file.")); - anaddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + anaddr = BMSYMBOL_VALUE_ADDRESS (msymbol); /* Make the breakpoint at "_start" a shared library event breakpoint. */ create_solib_event_breakpoint (target_gdbarch (), anaddr); @@ -537,7 +537,7 @@ link_map_start (void) sym = lookup_minimal_symbol ("__dld_flags", NULL, NULL); if (!sym.minsym) error (_("Unable to find __dld_flags symbol in object file.")); - addr = MSYMBOL_VALUE_ADDRESS (sym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (sym); read_memory (addr, buf, 4); dld_flags = extract_unsigned_integer (buf, 4, byte_order); if ((dld_flags & DLD_FLAGS_LISTVALID) == 0) @@ -554,10 +554,10 @@ link_map_start (void) error (_("Unable to find dynamic library list.")); return 0; } - addr = MSYMBOL_VALUE_ADDRESS (sym.minsym) - 8; + addr = BMSYMBOL_VALUE_ADDRESS (sym) - 8; } else - addr = MSYMBOL_VALUE_ADDRESS (sym.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (sym); read_memory (addr, buf, 4); addr = extract_unsigned_integer (buf, 4, byte_order); diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c index a4cefad3751..1c574b537b4 100644 --- a/gdb/solib-spu.c +++ b/gdb/solib-spu.c @@ -418,7 +418,7 @@ spu_enable_break (struct objfile *objfile) /* Place a solib_event breakpoint on the symbol. */ if (spe_event_sym.minsym) { - CORE_ADDR addr = MSYMBOL_VALUE_ADDRESS (spe_event_sym.minsym); + CORE_ADDR addr = BMSYMBOL_VALUE_ADDRESS (spe_event_sym); addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), addr, ¤t_target); @@ -448,7 +448,7 @@ ocl_enable_break (struct objfile *objfile) if (event_sym.minsym && addr_sym.minsym) { /* Place a solib_event breakpoint on the symbol. */ - CORE_ADDR event_addr = MSYMBOL_VALUE_ADDRESS (event_sym.minsym); + CORE_ADDR event_addr = BMSYMBOL_VALUE_ADDRESS (event_sym); create_solib_event_breakpoint (get_objfile_arch (objfile), event_addr); /* Store the address of the symbol that will point to OpenCL program @@ -459,7 +459,7 @@ ocl_enable_break (struct objfile *objfile) &objfile->objfile_obstack, objfile->sections_end - objfile->sections, CORE_ADDR); - *ocl_program_addr_base = MSYMBOL_VALUE_ADDRESS (addr_sym.minsym); + *ocl_program_addr_base = BMSYMBOL_VALUE_ADDRESS (addr_sym); set_objfile_data (objfile, ocl_program_data_key, ocl_program_addr_base); } diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 4be0807fe00..e2e173a4ca9 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -817,7 +817,7 @@ elf_locate_base (void) conventionally named _r_debug, as a last resort. */ msymbol = lookup_minimal_symbol ("_r_debug", NULL, symfile_objfile); if (msymbol.minsym != NULL) - return MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + return BMSYMBOL_VALUE_ADDRESS (msymbol); /* DT_DEBUG entry not found. */ return 0; @@ -2349,9 +2349,9 @@ enable_break (struct svr4_info *info, int from_tty) { msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile); if ((msymbol.minsym != NULL) - && (MSYMBOL_VALUE_ADDRESS (msymbol.minsym) != 0)) + && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) { - sym_addr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr, ¤t_target); @@ -2366,9 +2366,9 @@ enable_break (struct svr4_info *info, int from_tty) { msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile); if ((msymbol.minsym != NULL) - && (MSYMBOL_VALUE_ADDRESS (msymbol.minsym) != 0)) + && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) { - sym_addr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr, ¤t_target); diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index 157f37b933b..4967bcd1d72 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -1768,10 +1768,10 @@ spu_get_overlay_table (struct objfile *objfile) if (!ovly_buf_table_msym.minsym) return NULL; - ovly_table_base = MSYMBOL_VALUE_ADDRESS (ovly_table_msym.minsym); + ovly_table_base = BMSYMBOL_VALUE_ADDRESS (ovly_table_msym); ovly_table_size = MSYMBOL_SIZE (ovly_table_msym.minsym); - ovly_buf_table_base = MSYMBOL_VALUE_ADDRESS (ovly_buf_table_msym.minsym); + ovly_buf_table_base = BMSYMBOL_VALUE_ADDRESS (ovly_buf_table_msym); ovly_buf_table_size = MSYMBOL_SIZE (ovly_buf_table_msym.minsym); ovly_table = xmalloc (ovly_table_size); @@ -1923,7 +1923,7 @@ spu_catch_start (struct objfile *objfile) /* If we have debugging information, try to use it -- this will allow us to properly skip the prologue. */ - pc = MSYMBOL_VALUE_ADDRESS (minsym.minsym); + pc = BMSYMBOL_VALUE_ADDRESS (minsym); symtab = find_pc_sect_symtab (pc, MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym)); if (symtab != NULL) @@ -2002,7 +2002,7 @@ flush_ea_cache (void) type = objfile_type (obj)->builtin_void; type = lookup_function_type (type); type = lookup_pointer_type (type); - addr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (msymbol); call_function_by_hand (value_from_pointer (type, addr), 0, NULL); } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index b5bec10762a..b40cf78f49c 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1178,7 +1178,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, (gdbarch, SYMBOL_LINKAGE_NAME (sym)); SYMBOL_SET_LINKAGE_NAME (sym, new_name); - SYMBOL_VALUE_ADDRESS (sym) = MSYMBOL_VALUE_ADDRESS (msym.minsym); + SYMBOL_VALUE_ADDRESS (sym) = BMSYMBOL_VALUE_ADDRESS (msym); } } SYMBOL_DOMAIN (sym) = VAR_DOMAIN; @@ -1370,7 +1370,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, (gdbarch, SYMBOL_LINKAGE_NAME (sym)); SYMBOL_SET_LINKAGE_NAME (sym, new_name); - SYMBOL_VALUE_ADDRESS (sym) = MSYMBOL_VALUE_ADDRESS (msym.minsym); + SYMBOL_VALUE_ADDRESS (sym) = BMSYMBOL_VALUE_ADDRESS (msym); } } SYMBOL_DOMAIN (sym) = VAR_DOMAIN; @@ -4680,12 +4680,13 @@ scan_file_globals (struct objfile *objfile) if (SYMBOL_CLASS (sym) == LOC_BLOCK) { fix_common_block (sym, - MSYMBOL_VALUE_ADDRESS (msymbol)); + MSYMBOL_VALUE_ADDRESS (resolve_objfile, + msymbol)); } else { SYMBOL_VALUE_ADDRESS (sym) - = MSYMBOL_VALUE_ADDRESS (msymbol); + = MSYMBOL_VALUE_ADDRESS (resolve_objfile, msymbol); } SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msymbol); } diff --git a/gdb/stack.c b/gdb/stack.c index aec0e5d9cda..da7d9775101 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -47,6 +47,7 @@ #include "inline-frame.h" #include "linespec.h" #include "cli/cli-utils.h" +#include "objfiles.h" #include "gdb_assert.h" #include @@ -1076,7 +1077,7 @@ find_frame_funname (struct frame_info *frame, char **funname, memset (&msymbol, 0, sizeof (msymbol)); if (msymbol.minsym != NULL - && (MSYMBOL_VALUE_ADDRESS (msymbol.minsym) + && (BMSYMBOL_VALUE_ADDRESS (msymbol) > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) { /* We also don't know anything about the function besides diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index c247bd7e044..e8491c8f501 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -308,7 +308,7 @@ debug_qf_expand_symtabs_matching static struct symtab * debug_qf_find_pc_sect_symtab (struct objfile *objfile, - struct minimal_symbol *msymbol, + struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin) @@ -320,7 +320,7 @@ debug_qf_find_pc_sect_symtab (struct objfile *objfile, fprintf_filtered (gdb_stdlog, "qf->find_pc_sect_symtab (%s, %s, %s, %s, %d)\n", debug_objfile_name (objfile), - host_address_to_string (msymbol), + host_address_to_string (msymbol.minsym), hex_string (pc), host_address_to_string (section), warn_if_readin); diff --git a/gdb/symfile.c b/gdb/symfile.c index b8d4479117c..d5cb7cb227d 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3561,12 +3561,11 @@ simple_read_overlay_table (void) word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT; byte_order = gdbarch_byte_order (gdbarch); - cache_novlys - = read_memory_integer (MSYMBOL_VALUE_ADDRESS (novlys_msym.minsym), - 4, byte_order); + cache_novlys = read_memory_integer (BMSYMBOL_VALUE_ADDRESS (novlys_msym), + 4, byte_order); cache_ovly_table = (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table)); - cache_ovly_table_base = MSYMBOL_VALUE_ADDRESS (ovly_table_msym.minsym); + cache_ovly_table_base = BMSYMBOL_VALUE_ADDRESS (ovly_table_msym); read_target_long_array (cache_ovly_table_base, (unsigned int *) cache_ovly_table, cache_novlys * 4, word_size, byte_order); @@ -3642,7 +3641,7 @@ simple_overlay_update (struct obj_section *osect) "find `_ovly_table' array\n" "in inferior. Use `overlay manual' mode.")); - if (cache_ovly_table_base == MSYMBOL_VALUE_ADDRESS (minsym.minsym)) + if (cache_ovly_table_base == BMSYMBOL_VALUE_ADDRESS (minsym)) /* Then go ahead and try to look up this single section in the cache. */ if (simple_overlay_update_1 (osect)) diff --git a/gdb/symfile.h b/gdb/symfile.h index 17599bebb44..614af3c21c3 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -292,7 +292,7 @@ struct quick_symbol_functions symbol table that contains a symbol whose address is closest to PC. */ struct symtab *(*find_pc_sect_symtab) (struct objfile *objfile, - struct minimal_symbol *msymbol, + struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index fe324a009f2..0fc78d540dc 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -251,7 +251,8 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) break; } fprintf_filtered (outfile, "[%2d] %c ", index, ms_type); - fputs_filtered (paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (msymbol)), + fputs_filtered (paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (objfile, + msymbol)), outfile); fprintf_filtered (outfile, " %s", MSYMBOL_LINKAGE_NAME (msymbol)); if (section) diff --git a/gdb/symtab.c b/gdb/symtab.c index 65d7188a6c6..e267823bd30 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1074,18 +1074,18 @@ struct symtab * find_pc_sect_symtab_via_partial (CORE_ADDR pc, struct obj_section *section) { struct objfile *objfile; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; /* If we know that this is not a text address, return failure. This is necessary because we loop based on texthigh and textlow, which do not include the data ranges. */ - msymbol = lookup_minimal_symbol_by_pc_section (pc, section).minsym; - if (msymbol - && (MSYMBOL_TYPE (msymbol) == mst_data - || MSYMBOL_TYPE (msymbol) == mst_bss - || MSYMBOL_TYPE (msymbol) == mst_abs - || MSYMBOL_TYPE (msymbol) == mst_file_data - || MSYMBOL_TYPE (msymbol) == mst_file_bss)) + msymbol = lookup_minimal_symbol_by_pc_section (pc, section); + if (msymbol.minsym + && (MSYMBOL_TYPE (msymbol.minsym) == mst_data + || MSYMBOL_TYPE (msymbol.minsym) == mst_bss + || MSYMBOL_TYPE (msymbol.minsym) == mst_abs + || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data + || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss)) return NULL; ALL_OBJFILES (objfile) @@ -2149,20 +2149,20 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section) struct symtab *best_s = NULL; struct objfile *objfile; CORE_ADDR distance = 0; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; /* If we know that this is not a text address, return failure. This is necessary because we loop based on the block's high and low code addresses, which do not include the data ranges, and because we call find_pc_sect_psymtab which has a similar restriction based on the partial_symtab's texthigh and textlow. */ - msymbol = lookup_minimal_symbol_by_pc_section (pc, section).minsym; - if (msymbol - && (MSYMBOL_TYPE (msymbol) == mst_data - || MSYMBOL_TYPE (msymbol) == mst_bss - || MSYMBOL_TYPE (msymbol) == mst_abs - || MSYMBOL_TYPE (msymbol) == mst_file_data - || MSYMBOL_TYPE (msymbol) == mst_file_bss)) + msymbol = lookup_minimal_symbol_by_pc_section (pc, section); + if (msymbol.minsym + && (MSYMBOL_TYPE (msymbol.minsym) == mst_data + || MSYMBOL_TYPE (msymbol.minsym) == mst_bss + || MSYMBOL_TYPE (msymbol.minsym) == mst_abs + || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data + || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss)) return NULL; /* Search all symtabs for the one whose file contains our address, and which @@ -2289,7 +2289,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) struct symtab_and_line val; struct blockvector *bv; struct bound_minimal_symbol msymbol; - struct minimal_symbol *mfunsym; struct objfile *objfile; /* Info on best line seen so far, and where it starts, and its file. */ @@ -2377,10 +2376,11 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) if (msymbol.minsym != NULL) if (MSYMBOL_TYPE (msymbol.minsym) == mst_solib_trampoline) { - mfunsym + struct bound_minimal_symbol mfunsym = lookup_minimal_symbol_text (MSYMBOL_LINKAGE_NAME (msymbol.minsym), - NULL).minsym; - if (mfunsym == NULL) + NULL); + + if (mfunsym.minsym == NULL) /* I eliminated this warning since it is coming out * in the following situation: * gdb shmain // test program with shared libraries @@ -2394,8 +2394,8 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) SYMBOL_LINKAGE_NAME (msymbol)); */ ; /* fall through */ - else if (MSYMBOL_VALUE_ADDRESS (mfunsym) - == MSYMBOL_VALUE_ADDRESS (msymbol.minsym)) + else if (BMSYMBOL_VALUE_ADDRESS (mfunsym) + == BMSYMBOL_VALUE_ADDRESS (msymbol)) /* Avoid infinite recursion */ /* See above comment about why warning is commented out. */ /* warning ("In stub for %s; unable to find real function/line info", @@ -2403,7 +2403,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) ; /* fall through */ else - return find_pc_line (MSYMBOL_VALUE_ADDRESS (mfunsym), 0); + return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0); } @@ -2917,7 +2917,7 @@ skip_prologue_sal (struct symtab_and_line *sal) } objfile = msymbol.objfile; - pc = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + pc = BMSYMBOL_VALUE_ADDRESS (msymbol); section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym); name = MSYMBOL_LINKAGE_NAME (msymbol.minsym); } @@ -3665,7 +3665,8 @@ search_symbols (char *regexp, enum search_domain kind, is to expand the symbol table if msymbol is found, for the benefit of the next loop on ALL_PRIMARY_SYMTABS. */ if (kind == FUNCTIONS_DOMAIN - ? find_pc_symtab (MSYMBOL_VALUE_ADDRESS (msymbol)) == NULL + ? find_pc_symtab (MSYMBOL_VALUE_ADDRESS (objfile, + msymbol)) == NULL : (lookup_symbol_in_objfile_from_linkage_name (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN) == NULL)) @@ -3767,7 +3768,8 @@ search_symbols (char *regexp, enum search_domain kind, /* For functions we can do a quick check of whether the symbol might be found via find_pc_symtab. */ if (kind != FUNCTIONS_DOMAIN - || find_pc_symtab (MSYMBOL_VALUE_ADDRESS (msymbol)) == NULL) + || find_pc_symtab (MSYMBOL_VALUE_ADDRESS (objfile, + msymbol)) == NULL) { if (lookup_symbol_in_objfile_from_linkage_name (objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN) @@ -3848,11 +3850,11 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) char *tmp; if (gdbarch_addr_bit (gdbarch) <= 32) - tmp = hex_string_custom (MSYMBOL_VALUE_ADDRESS (msymbol.minsym) + tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol) & (CORE_ADDR) 0xffffffff, 8); else - tmp = hex_string_custom (MSYMBOL_VALUE_ADDRESS (msymbol.minsym), + tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol), 16); printf_filtered ("%s %s\n", tmp, MSYMBOL_PRINT_NAME (msymbol.minsym)); diff --git a/gdb/symtab.h b/gdb/symtab.h index bf1ef74185d..d80222b5d32 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -391,8 +391,18 @@ struct minimal_symbol #define MSYMBOL_TYPE(msymbol) (msymbol)->type #define MSYMBOL_VALUE(symbol) (symbol)->mginfo.value.ivalue -#define MSYMBOL_VALUE_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0) -#define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value) \ +/* The unrelocated address of the minimal symbol. */ +#define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0) +/* This weird definition lets us syntax-check without affecting the + results. It is a temporary measure until a later patch. */ +#define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \ + ((symbol)->mginfo.value.address \ + + (0 \ + * ANOFFSET ((objfile)->section_offsets, ((symbol)->mginfo.section)))) +/* For a bound minsym, we can easily compute the address directly. */ +#define BMSYMBOL_VALUE_ADDRESS(symbol) \ + MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym) +#define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value) \ ((symbol)->mginfo.value.address = (new_value)) #define MSYMBOL_VALUE_BYTES(symbol) (symbol)->mginfo.value.bytes #define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->mginfo.value.block diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index bd3e9d07732..08541c5cc65 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2831,7 +2831,7 @@ scope_info (char *args, int from_tty) printf_filtered ("static storage at address "); printf_filtered ("%s", paddress (gdbarch, - MSYMBOL_VALUE_ADDRESS (msym.minsym))); + BMSYMBOL_VALUE_ADDRESS (msym))); } break; case LOC_OPTIMIZED_OUT: diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index e0ea1837af1..8c48d66158f 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -37,6 +37,7 @@ #include "tui/tui-file.h" #include "tui/tui-disasm.h" #include "progspace.h" +#include "objfiles.h" #include "gdb_curses.h" @@ -113,7 +114,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) { CORE_ADDR last_addr; int pos; - struct minimal_symbol *msymbol; + struct bound_minimal_symbol msymbol; /* Find backward an address which is a symbol and for which disassembling from that address will fill completely the @@ -121,16 +122,16 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) pos = max_lines - 1; do { new_low -= 1 * max_lines; - msymbol = lookup_minimal_symbol_by_pc_section (new_low, 0).minsym; + msymbol = lookup_minimal_symbol_by_pc_section (new_low, 0); - if (msymbol) - new_low = MSYMBOL_VALUE_ADDRESS (msymbol); + if (msymbol.minsym) + new_low = BMSYMBOL_VALUE_ADDRESS (msymbol); else new_low += 1 * max_lines; tui_disassemble (gdbarch, asm_lines, new_low, max_lines); last_addr = asm_lines[pos].addr; - } while (last_addr > pc && msymbol); + } while (last_addr > pc && msymbol.minsym); /* Scan forward disassembling one instruction at a time until the last visible instruction of the window matches the pc. @@ -349,7 +350,7 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p) if (main_symbol.minsym == 0) main_symbol = lookup_minimal_symbol ("_start", NULL, NULL); if (main_symbol.minsym) - addr = MSYMBOL_VALUE_ADDRESS (main_symbol.minsym); + addr = BMSYMBOL_VALUE_ADDRESS (main_symbol); else addr = 0; } diff --git a/gdb/valops.c b/gdb/valops.c index cdbaecac8ac..9d2218fdc89 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -160,7 +160,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char); type = lookup_function_type (type); type = lookup_pointer_type (type); - maddr = MSYMBOL_VALUE_ADDRESS (msymbol.minsym); + maddr = BMSYMBOL_VALUE_ADDRESS (msymbol); if (objf_p) *objf_p = objfile; diff --git a/gdb/value.c b/gdb/value.c index 1dfc6d58f1d..4e8d1fe815e 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2758,7 +2758,7 @@ value_static_field (struct type *type, int fieldno) else { retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), - MSYMBOL_VALUE_ADDRESS (msym.minsym)); + BMSYMBOL_VALUE_ADDRESS (msym)); } } else @@ -2974,7 +2974,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, set_value_address (v, gdbarch_convert_from_func_ptr_addr - (gdbarch, MSYMBOL_VALUE_ADDRESS (msym.minsym), ¤t_target)); + (gdbarch, BMSYMBOL_VALUE_ADDRESS (msym), ¤t_target)); } if (arg1p) -- 2.39.5