X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fsolib-svr4.c;h=893da86e27ea5309ce3f5b7c52a80a2e866d1c32;hb=9e468e953cd2f605a3f51d6ef6532e46b8fdd7b4;hp=2624ec286a0ba40336fcc62f324542ebe5f23ff4;hpb=6cb06a8cdaaf30f5d879f24d37100cf1d25c6a3a;p=binutils-gdb.git diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 2624ec286a0..893da86e27e 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -51,9 +51,9 @@ static int svr4_have_link_map_offsets (void); static void svr4_relocate_main_executable (void); static void svr4_free_library_list (void *p_list); static void probes_table_remove_objfile_probes (struct objfile *objfile); -static void svr4_iterate_over_objfiles_in_search_order ( - struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype *cb, - void *cb_data, struct objfile *objfile); +static void svr4_iterate_over_objfiles_in_search_order + (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, + objfile *current_objfile); /* On SVR4 systems, a list of symbols in the dynamic linker where @@ -365,7 +365,7 @@ struct svr4_info }; /* Per-program-space data key. */ -static const struct program_space_key solib_svr4_pspace_data; +static const registry::key solib_svr4_pspace_data; /* Free the probes table. */ @@ -713,7 +713,7 @@ elf_locate_base (void) msymbol = lookup_minimal_symbol ("_r_debug", NULL, current_program_space->symfile_object_file); if (msymbol.minsym != NULL) - return BMSYMBOL_VALUE_ADDRESS (msymbol); + return msymbol.value_address (); /* DT_DEBUG entry not found. */ return 0; @@ -1453,11 +1453,6 @@ svr4_fetch_objfile_link_map (struct objfile *objfile) if (objfile == current_program_space->symfile_object_file) return info->main_lm_addr; - /* If OBJFILE is a separate debug object file, look for the - original object file. */ - if (objfile->separate_debug_objfile_backlink != NULL) - objfile = objfile->separate_debug_objfile_backlink; - /* The other link map addresses may be found by examining the list of shared libraries. */ for (struct so_list *so : current_program_space->solibs ()) @@ -2175,7 +2170,7 @@ enable_break (struct svr4_info *info, int from_tty) bfd *tmp_bfd; CORE_ADDR load_addr; - tmp_bfd = os->objfile->obfd; + tmp_bfd = os->objfile->obfd.get (); load_addr = os->objfile->text_section_offset (); interp_sect = bfd_get_section_by_name (tmp_bfd, ".text"); @@ -2374,9 +2369,9 @@ enable_break (struct svr4_info *info, int from_tty) { msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, objf); if ((msymbol.minsym != NULL) - && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) + && (msymbol.value_address () != 0)) { - sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); + sym_addr = msymbol.value_address (); sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr, current_inferior ()->top_target ()); svr4_create_solib_event_breakpoints (info, target_gdbarch (), @@ -2391,9 +2386,9 @@ enable_break (struct svr4_info *info, int from_tty) { msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, objf); if ((msymbol.minsym != NULL) - && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) + && (msymbol.value_address () != 0)) { - sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); + sym_addr = msymbol.value_address (); sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr, current_inferior ()->top_target ()); @@ -3000,24 +2995,23 @@ svr4_relocate_section_addresses (struct so_list *so, /* Architecture-specific operations. */ -/* Per-architecture data key. */ -static struct gdbarch_data *solib_svr4_data; - struct solib_svr4_ops { /* Return a description of the layout of `struct link_map'. */ - struct link_map_offsets *(*fetch_link_map_offsets)(void); + struct link_map_offsets *(*fetch_link_map_offsets)(void) = nullptr; }; +/* Per-architecture data key. */ +static const registry::key solib_svr4_data; + /* Return a default for the architecture-specific operations. */ -static void * -solib_svr4_init (struct obstack *obstack) +static struct solib_svr4_ops * +get_ops (struct gdbarch *gdbarch) { - struct solib_svr4_ops *ops; - - ops = OBSTACK_ZALLOC (obstack, struct solib_svr4_ops); - ops->fetch_link_map_offsets = NULL; + struct solib_svr4_ops *ops = solib_svr4_data.get (gdbarch); + if (ops == nullptr) + ops = solib_svr4_data.emplace (gdbarch); return ops; } @@ -3028,12 +3022,11 @@ void set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch, struct link_map_offsets *(*flmo) (void)) { - struct solib_svr4_ops *ops - = (struct solib_svr4_ops *) gdbarch_data (gdbarch, solib_svr4_data); + struct solib_svr4_ops *ops = get_ops (gdbarch); ops->fetch_link_map_offsets = flmo; - set_solib_ops (gdbarch, &svr4_so_ops); + set_gdbarch_so_ops (gdbarch, &svr4_so_ops); set_gdbarch_iterate_over_objfiles_in_search_order (gdbarch, svr4_iterate_over_objfiles_in_search_order); } @@ -3044,9 +3037,7 @@ set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch, static struct link_map_offsets * svr4_fetch_link_map_offsets (void) { - struct solib_svr4_ops *ops - = (struct solib_svr4_ops *) gdbarch_data (target_gdbarch (), - solib_svr4_data); + struct solib_svr4_ops *ops = get_ops (target_gdbarch ()); gdb_assert (ops->fetch_link_map_offsets); return ops->fetch_link_map_offsets (); @@ -3057,9 +3048,7 @@ svr4_fetch_link_map_offsets (void) static int svr4_have_link_map_offsets (void) { - struct solib_svr4_ops *ops - = (struct solib_svr4_ops *) gdbarch_data (target_gdbarch (), - solib_svr4_data); + struct solib_svr4_ops *ops = get_ops (target_gdbarch ()); return (ops->fetch_link_map_offsets != NULL); } @@ -3140,9 +3129,8 @@ struct target_so_ops svr4_so_ops; static void svr4_iterate_over_objfiles_in_search_order - (struct gdbarch *gdbarch, - iterate_over_objfiles_in_search_order_cb_ftype *cb, - void *cb_data, struct objfile *current_objfile) + (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, + objfile *current_objfile) { bool checked_current_objfile = false; if (current_objfile != nullptr) @@ -3155,13 +3143,13 @@ svr4_iterate_over_objfiles_in_search_order if (current_objfile == current_program_space->symfile_object_file) abfd = current_program_space->exec_bfd (); else - abfd = current_objfile->obfd; + abfd = current_objfile->obfd.get (); if (abfd != nullptr && gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1) { checked_current_objfile = true; - if (cb (current_objfile, cb_data) != 0) + if (cb (current_objfile)) return; } } @@ -3170,7 +3158,7 @@ svr4_iterate_over_objfiles_in_search_order { if (checked_current_objfile && objfile == current_objfile) continue; - if (cb (objfile, cb_data) != 0) + if (cb (objfile)) return; } } @@ -3179,8 +3167,6 @@ void _initialize_svr4_solib (); void _initialize_svr4_solib () { - solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init); - svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses; svr4_so_ops.free_so = svr4_free_so; svr4_so_ops.clear_so = svr4_clear_so;