30#include "elf/common.h"
33#define GOT_MODULE_OFFSET 4
198 for (i = 0; i < map->
nsegs; i++)
237 sizeof ext_ldmbuf->
nsegs,
252 for (seg = 0; seg <
nsegs; seg++)
256 sizeof (ext_ldmbuf->
segs[seg].
addr),
282 gdb::optional<gdb::byte_vector> buf
286 if (!buf || buf->empty ())
288 info->exec_loadmap = NULL;
289 error (_(
"Error reading DSBT exec loadmap"));
297 if (!buf || buf->empty ())
299 info->interp_loadmap = NULL;
300 error (_(
"Error reading DSBT interp loadmap"));
320 int ext_ldmbuf_size, int_ldmbuf_size;
325 sizeof ext_ldmbuf_partial))
333 sizeof ext_ldmbuf_partial.
version,
343 sizeof ext_ldmbuf_partial.
nsegs,
355 memcpy (ext_ldmbuf, &ext_ldmbuf_partial,
sizeof ext_ldmbuf_partial);
359 (gdb_byte *) ext_ldmbuf +
sizeof ext_ldmbuf_partial,
360 ext_ldmbuf_size -
sizeof ext_ldmbuf_partial))
376 for (seg = 0; seg <
nsegs; seg++)
380 sizeof (ext_ldmbuf->
segs[seg].
addr),
417 for (seg = 0; seg < map->
nsegs; seg++)
450 if (info->main_executable_lm_info == 0)
454 if (info->lm_base_cache)
455 return info->lm_base_cache;
465 "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n",
466 (
unsigned int) addr);
475 ldm = info->exec_loadmap;
479 "lm_base: get addr %x by DT_PLTGOT.\n",
480 (
unsigned int) addr);
486 "lm_base: _GLOBAL_OFFSET_TABLE_ not found.\n");
493 "lm_base: _GLOBAL_OFFSET_TABLE_ + %d = %s\n",
502 "lm_base: lm_base_cache = %s\n",
503 hex_string_custom (info->lm_base_cache, 8));
505 return info->lm_base_cache;
523 struct so_list *sos_head = NULL;
524 struct so_list **sos_next_ptr = &sos_head;
539 if (info->main_executable_lm_info == 0 &&
core_bfd != NULL)
557 "current_sos: reading link_map entry at %s\n",
558 hex_string_custom (
lm_addr, 8));
563 warning (_(
"dsbt_current_sos: Unable to read link map entry."
564 " Shared object chain may be incomplete."));
577 warning (_(
"dsbt_current_sos: Unable to read dsbt index."
578 " Shared object chain may be incomplete."));
596 warning (_(
"dsbt_current_sos: Unable to fetch load map."
597 " Shared object chain may be incomplete."));
609 gdb::unique_xmalloc_ptr<char> name_buf
612 if (name_buf ==
nullptr)
613 warning (_(
"Can't read pathname for link map entry."));
626 sos_next_ptr = &sop->
next;
634 sizeof (lm_buf.
l_next), byte_order);
659 warning (_(
"Unable to find dynamic linker breakpoint function.\n"
660 "GDB will be unable to debug shared library initializers\n"
661 "and track explicitly loaded dynamic code."));
675 asection *interp_sect;
686 info->interp_text_sect_low = 0;
687 info->interp_text_sect_high = 0;
688 info->interp_plt_sect_low = 0;
689 info->interp_plt_sect_high = 0;
697 unsigned int interp_sect_size;
705 interp_sect_size = bfd_section_size (interp_sect);
706 buf = (
char *) alloca (interp_sect_size);
708 interp_sect, buf, 0, interp_sect_size);
719 catch (
const gdb_exception &ex)
730 ldm = info->interp_loadmap;
734 interp_sect = bfd_get_section_by_name (tmp_bfd.get (),
".text");
737 info->interp_text_sect_low = bfd_section_vma (interp_sect);
738 info->interp_text_sect_low
740 info->interp_text_sect_high
741 = info->interp_text_sect_low + bfd_section_size (interp_sect);
743 interp_sect = bfd_get_section_by_name (tmp_bfd.get (),
".plt");
746 info->interp_plt_sect_low = bfd_section_vma (interp_sect);
747 info->interp_plt_sect_low
749 info->interp_plt_sect_high
750 = info->interp_plt_sect_low + bfd_section_size (interp_sect);
755 [] (
const asymbol *sym)
757 return strcmp (sym->name,
"_dl_debug_state") == 0;
764 "enable_break: _dl_debug_state (prior to relocation) = %s\n",
765 hex_string_custom (addr, 8));
770 "enable_break: _dl_debug_state (after relocation) = %s\n",
771 hex_string_custom (addr, 8));
782 "enable_break: _dl_debug_state is not found\n");
807 ldm = info->exec_loadmap;
809 delete info->main_executable_lm_info;
811 info->main_executable_lm_info->map = ldm;
819 CORE_ADDR orig_addr, addr, offset;
826 addr = osect->
addr ();
830 orig_addr = addr - offset;
832 for (seg = 0; seg < ldm->
nsegs; seg++)
835 && orig_addr < ldm->segs[seg].p_vaddr + ldm->
segs[seg].
p_memsz)
837 new_offsets[osect_idx]
840 if (new_offsets[osect_idx] != offset)
870 warning (_(
"shared library handler failed to enable breakpoint"));
880 info->lm_base_cache = 0;
881 info->main_lm_addr = 0;
883 delete info->main_executable_lm_info;
884 info->main_executable_lm_info = NULL;
903 for (seg = 0; seg < map->
nsegs; seg++)
943Set internal debugging of shared library code for DSBT ELF."), _(
"\
944Show internal debugging of shared library code for DSBT ELF."), _(
"\
945When non-zero, DSBT solib specific internal debugging is enabled."),
struct gdbarch * target_gdbarch(void)
struct breakpoint * create_solib_event_breakpoint(struct gdbarch *gdbarch, CORE_ADDR address)
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct inferior * current_inferior(void)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
static CORE_ADDR lm_addr(struct so_list *so)
void objfile_relocate(struct objfile *objfile, const section_offsets &new_offsets)
static int in_plt_section(CORE_ADDR pc)
struct program_space * current_program_space
static unsigned int solib_dsbt_debug
static void dsbt_print_loadmap(struct int_elf32_dsbt_loadmap *map)
static CORE_ADDR lm_base(void)
static void show_dsbt_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void dsbt_relocate_section_addresses(struct so_list *so, struct target_section *sec)
static void enable_break_failure_warning(void)
static void dsbt_clear_solib(void)
static int enable_break(void)
gdb_byte ext_Elf32_Addr[4]
static void dsbt_get_initial_loadmaps(void)
static struct dsbt_info * get_dsbt_info(void)
static const registry< program_space >::key< dsbt_info > solib_dsbt_pspace_data
static struct int_elf32_dsbt_loadmap * fetch_loadmap(CORE_ADDR ldmaddr)
static int dsbt_in_dynsym_resolve_code(CORE_ADDR pc)
static int open_symbol_file_object(int from_tty)
const struct target_so_ops dsbt_so_ops
#define GOT_MODULE_OFFSET
static void dsbt_relocate_main_executable(void)
gdb_byte ext_Elf32_Half[2]
gdb_byte ext_Elf32_Word[4]
static void dsbt_solib_create_inferior_hook(int from_tty)
void _initialize_dsbt_solib()
static CORE_ADDR displacement_from_map(struct int_elf32_dsbt_loadmap *map, CORE_ADDR addr)
static struct int_elf32_dsbt_loadmap * decode_loadmap(const gdb_byte *buf)
static void dsbt_free_so(struct so_list *so)
static struct so_list * dsbt_current_sos(void)
static CORE_ADDR interp_text_sect_high
static CORE_ADDR interp_plt_sect_high
gdb_bfd_ref_ptr solib_bfd_open(const char *pathname)
CORE_ADDR gdb_bfd_lookup_symbol(bfd *abfd, gdb::function_view< bool(const asymbol *)> match_sym)
int gdb_bfd_scan_elf_dyntag(const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr, CORE_ADDR *ptr_addr)
#define SO_NAME_MAX_PATH_SIZE
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct ext_elf32_dsbt_loadaddr l_addr
CORE_ADDR interp_text_sect_low
CORE_ADDR interp_plt_sect_low
struct lm_info_dsbt * main_executable_lm_info
struct int_elf32_dsbt_loadmap * interp_loadmap
struct int_elf32_dsbt_loadmap * exec_loadmap
CORE_ADDR interp_text_sect_high
CORE_ADDR interp_plt_sect_high
ext_Elf32_Word dsbt_index
struct ext_elf32_dsbt_loadseg segs[1]
ext_Elf32_Word dsbt_table_ptr
struct int_elf32_dsbt_loadseg segs[1]
int_elf32_dsbt_loadmap * map
struct obj_section * sections_start
iterator_range< section_iterator > sections()
::section_offsets section_offsets
struct objfile * symfile_object_file
char so_name[SO_NAME_MAX_PATH_SIZE]
char so_original_name[SO_NAME_MAX_PATH_SIZE]
std::vector< CORE_ADDR > section_offsets
int target_read_string(CORE_ADDR addr, int len, int width, unsigned int fetchlimit, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *bytes_read)
bool target_has_execution(inferior *inf)
gdb::optional< gdb::byte_vector > target_read_alloc(struct target_ops *ops, enum target_object object, const char *annex)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * print_core_address(struct gdbarch *gdbarch, CORE_ADDR address)
void gdb_printf(struct ui_file *stream, const char *format,...)