34#define GOT_MODULE_OFFSET 4
199 for (i = 0; i < map->
nsegs; i++)
238 sizeof ext_ldmbuf->
nsegs,
253 for (seg = 0; seg <
nsegs; seg++)
257 sizeof (ext_ldmbuf->
segs[seg].
addr),
283 gdb::optional<gdb::byte_vector> buf
287 if (!buf || buf->empty ())
289 info->exec_loadmap = NULL;
290 error (_(
"Error reading DSBT exec loadmap"));
298 if (!buf || buf->empty ())
300 info->interp_loadmap = NULL;
301 error (_(
"Error reading DSBT interp loadmap"));
321 int ext_ldmbuf_size, int_ldmbuf_size;
326 sizeof ext_ldmbuf_partial))
334 sizeof ext_ldmbuf_partial.
version,
344 sizeof ext_ldmbuf_partial.
nsegs,
356 memcpy (ext_ldmbuf, &ext_ldmbuf_partial,
sizeof ext_ldmbuf_partial);
360 (gdb_byte *) ext_ldmbuf +
sizeof ext_ldmbuf_partial,
361 ext_ldmbuf_size -
sizeof ext_ldmbuf_partial))
377 for (seg = 0; seg <
nsegs; seg++)
381 sizeof (ext_ldmbuf->
segs[seg].
addr),
418 for (seg = 0; seg < map->
nsegs; seg++)
451 if (info->main_executable_lm_info == 0)
455 if (info->lm_base_cache)
456 return info->lm_base_cache;
466 "lm_base: get addr %x by _GLOBAL_OFFSET_TABLE_.\n",
467 (
unsigned int) addr);
476 ldm = info->exec_loadmap;
480 "lm_base: get addr %x by DT_PLTGOT.\n",
481 (
unsigned int) addr);
487 "lm_base: _GLOBAL_OFFSET_TABLE_ not found.\n");
494 "lm_base: _GLOBAL_OFFSET_TABLE_ + %d = %s\n",
503 "lm_base: lm_base_cache = %s\n",
504 hex_string_custom (info->lm_base_cache, 8));
506 return info->lm_base_cache;
524 struct so_list *sos_head = NULL;
525 struct so_list **sos_next_ptr = &sos_head;
540 if (info->main_executable_lm_info == 0 &&
core_bfd != NULL)
558 "current_sos: reading link_map entry at %s\n",
559 hex_string_custom (
lm_addr, 8));
564 warning (_(
"dsbt_current_sos: Unable to read link map entry."
565 " Shared object chain may be incomplete."));
578 warning (_(
"dsbt_current_sos: Unable to read dsbt index."
579 " Shared object chain may be incomplete."));
597 warning (_(
"dsbt_current_sos: Unable to fetch load map."
598 " Shared object chain may be incomplete."));
610 gdb::unique_xmalloc_ptr<char> name_buf
613 if (name_buf ==
nullptr)
614 warning (_(
"Can't read pathname for link map entry."));
627 sos_next_ptr = &sop->
next;
635 sizeof (lm_buf.
l_next), byte_order);
660 warning (_(
"Unable to find dynamic linker breakpoint function.\n"
661 "GDB will be unable to debug shared library initializers\n"
662 "and track explicitly loaded dynamic code."));
670 return (strcmp (sym->name, (
const char *) data) == 0);
684 asection *interp_sect;
695 info->interp_text_sect_low = 0;
696 info->interp_text_sect_high = 0;
697 info->interp_plt_sect_low = 0;
698 info->interp_plt_sect_high = 0;
706 unsigned int interp_sect_size;
714 interp_sect_size = bfd_section_size (interp_sect);
715 buf = (
char *) alloca (interp_sect_size);
717 interp_sect, buf, 0, interp_sect_size);
728 catch (
const gdb_exception &ex)
739 ldm = info->interp_loadmap;
743 interp_sect = bfd_get_section_by_name (tmp_bfd.get (),
".text");
746 info->interp_text_sect_low = bfd_section_vma (interp_sect);
747 info->interp_text_sect_low
749 info->interp_text_sect_high
750 = info->interp_text_sect_low + bfd_section_size (interp_sect);
752 interp_sect = bfd_get_section_by_name (tmp_bfd.get (),
".plt");
755 info->interp_plt_sect_low = bfd_section_vma (interp_sect);
756 info->interp_plt_sect_low
758 info->interp_plt_sect_high
759 = info->interp_plt_sect_low + bfd_section_size (interp_sect);
768 "enable_break: _dl_debug_state (prior to relocation) = %s\n",
769 hex_string_custom (addr, 8));
774 "enable_break: _dl_debug_state (after relocation) = %s\n",
775 hex_string_custom (addr, 8));
786 "enable_break: _dl_debug_state is not found\n");
812 ldm = info->exec_loadmap;
814 delete info->main_executable_lm_info;
816 info->main_executable_lm_info->map = ldm;
824 CORE_ADDR orig_addr, addr, offset;
831 addr = osect->
addr ();
835 orig_addr = addr - offset;
837 for (seg = 0; seg < ldm->
nsegs; seg++)
840 && orig_addr < ldm->segs[seg].p_vaddr + ldm->
segs[seg].
p_memsz)
842 new_offsets[osect_idx]
845 if (new_offsets[osect_idx] != offset)
875 warning (_(
"shared library handler failed to enable breakpoint"));
885 info->lm_base_cache = 0;
886 info->main_lm_addr = 0;
888 delete info->main_executable_lm_info;
889 info->main_executable_lm_info = NULL;
908 for (seg = 0; seg < map->nsegs; seg++)
910 if (map->segs[seg].p_vaddr <= sec->
addr
911 && sec->
addr < map->segs[seg].p_vaddr + map->segs[seg].p_memsz)
913 CORE_ADDR displ = map->
segs[seg].
addr - map->segs[seg].p_vaddr;
948Set internal debugging of shared library code for DSBT ELF."), _(
"\
949Show internal debugging of shared library code for DSBT ELF."), _(
"\
950When 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)
#define ALL_OBJFILE_OSECTIONS(objfile, osect)
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 int cmp_name(const asymbol *sym, const void *data)
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
CORE_ADDR gdb_bfd_lookup_symbol(bfd *abfd, int(*match_sym)(const asymbol *, const void *), const void *data)
gdb_bfd_ref_ptr solib_bfd_open(const char *pathname)
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
::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,...)