90#if !defined(HAVE_LIBEXPAT)
94static gdb::optional<std::vector<lm_info_aix>>
97 static int have_warned;
102 warning (_(
"Can not parse XML library list; XML support was disabled "
116library_list_start_library (
struct gdb_xml_parser *parser,
121 std::vector<lm_info_aix> *list = (std::vector<lm_info_aix> *) user_data;
144 list->push_back (std::move (item));
150library_list_start_list (
struct gdb_xml_parser *parser,
158 if (strcmp (
version,
"1.0") != 0)
160 _(
"Library list has unsupported version \"%s\""),
180 {
"library", library_attributes, NULL,
182 library_list_start_library, NULL},
194 {
"library-list-aix", library_list_attributes, library_list_children,
204static gdb::optional<std::vector<lm_info_aix>>
207 std::vector<lm_info_aix> result;
210 library_list_elements, library, &result) == 0)
228static gdb::optional<std::vector<lm_info_aix>> &
235 if (data->library_list.has_value ())
236 return data->library_list;
238 gdb::optional<gdb::char_vector> library_document
242 if (!library_document && warning_msg != NULL)
244 warning (_(
"%s (failed to read TARGET_OBJECT_LIBRARIES_AIX)"),
246 return data->library_list;
250 library_document->data ());
253 if (!data->library_list.has_value () && warning_msg != NULL)
254 warning (_(
"%s (missing XML support?)"), warning_msg);
256 return data->library_list;
286 struct bfd_section *data_sect, *bss_sect;
288 data_sect = bfd_get_section_by_name (abfd,
".data");
289 if (data_sect == NULL)
292 bss_sect = bfd_get_section_by_name (abfd,
".bss");
293 if (bss_sect == NULL)
300 if (bfd_section_vma (bss_sect) < bfd_section_vma (data_sect))
303 if (bfd_section_vma (bss_sect)
304 < bfd_section_vma (data_sect) + bfd_section_size (data_sect))
305 return (bfd_section_vma (data_sect) + bfd_section_size (data_sect)
306 - bfd_section_vma (bss_sect));
318 bfd *abfd = bfd_sect->owner;
319 const char *section_name = bfd_section_name (bfd_sect);
322 if (strcmp (section_name,
".text") == 0)
324 sec->
addr = info->text_addr;
329 sec->
addr += bfd_sect->filepos;
331 else if (strcmp (section_name,
".data") == 0)
333 sec->
addr = info->data_addr;
336 else if (strcmp (section_name,
".bss") == 0)
345 struct bfd_section *data_sect
346 = bfd_get_section_by_name (abfd,
".data");
347 CORE_ADDR data_offset = 0;
349 if (data_sect != NULL)
350 data_offset = info->data_addr - bfd_section_vma (data_sect);
352 sec->
addr = bfd_section_vma (bfd_sect) + data_offset;
354 sec->
endaddr = sec->
addr + bfd_section_size (bfd_sect);
359 sec->
addr = bfd_section_vma (bfd_sect);
360 sec->
endaddr = sec->
addr + bfd_section_size (bfd_sect);
399 struct bfd_section *sect
403 = info->text_addr + sect->filepos - bfd_section_vma (sect);
410 struct bfd_section *sect
414 = info->data_addr - bfd_section_vma (sect);
441 const char *warning_msg =
"unable to relocate main executable";
445 gdb::optional<std::vector<lm_info_aix>> &library_list
447 if (!library_list.has_value ())
450 if (library_list->empty ())
452 warning (_(
"unable to relocate main executable (no info from loader)"));
472 struct so_list *start = NULL, *last = NULL;
475 gdb::optional<std::vector<lm_info_aix>> &library_list
477 if (!library_list.has_value ())
483 for (ix = 1; ix < library_list->size (); ix++)
489 if (info.member_name.empty ())
503 so_name = string_printf (
"%s(%s)", info.filename.c_str (),
504 info.member_name.c_str ());
515 last = start = new_solib;
518 last->
next = new_solib;
553 const int path_len = strlen (pathname);
558 if (pathname[path_len - 1] !=
')')
562 sep = strrchr (pathname,
'(');
568 warning (_(
"missing '(' in shared object pathname: %s"), pathname);
571 filename_len = sep - pathname;
573 std::string filename (string_printf (
"%.*s", filename_len, pathname));
574 std::string member_name (string_printf (
"%.*s", path_len - filename_len - 2,
580 gdb::unique_xmalloc_ptr<char> found_pathname
581 =
solib_find (filename.c_str (), &found_file);
582 if (found_pathname == NULL)
583 perror_with_name (pathname);
586 if (archive_bfd == NULL)
588 warning (_(
"Could not open `%s' as an executable file: %s"),
589 filename.c_str (), bfd_errmsg (bfd_get_error ()));
593 if (bfd_check_format (archive_bfd.get (), bfd_object))
596 if (! bfd_check_format (archive_bfd.get (), bfd_archive))
598 warning (_(
"\"%s\": not in executable format: %s."),
599 filename.c_str (), bfd_errmsg (bfd_get_error ()));
605 while (object_bfd != NULL)
607 if (member_name == bfd_get_filename (object_bfd.get ()))
610 std::string s = bfd_get_filename (object_bfd.get ());
616 if (s.find (
'(') != std::string::npos)
618 int pos = s.find (
'(');
619 int len = s.find (
')') - s.find (
'(');
620 if (s.substr (pos+1, len-1) == member_name)
628 if (object_bfd == NULL)
630 warning (_(
"\"%s\": member \"%s\" missing."), filename.c_str (),
631 member_name.c_str ());
635 if (! bfd_check_format (object_bfd.get (), bfd_object))
637 warning (_(
"%s(%s): not in object format: %s."),
638 filename.c_str (), member_name.c_str (),
639 bfd_errmsg (bfd_get_error ()));
647 std::string fname = string_printf (
"%s%s",
648 bfd_get_filename (archive_bfd.get ()),
650 bfd_set_filename (object_bfd.get (), fname.c_str ());
663 if (strcmp (bfd_section_name (osect->the_bfd_section),
".data") == 0)
679 if (pc_osect == NULL)
680 error (_(
"unable to find TOC entry for pc %s "
681 "(no section contains this PC)"),
682 core_addr_to_string (pc));
685 if (data_osect == NULL)
686 error (_(
"unable to find TOC entry for pc %s "
687 "(%s has no data section)"),
693 core_addr_to_string (result));
709 data->library_list.reset ();
static struct @5 attributes[]
gdb_bfd_ref_ptr gdb_bfd_openr_next_archived_file(bfd *archive, bfd *previous)
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
struct inferior * current_inferior(void)
observable< struct bpstat *, int > normal_stop
void objfile_relocate(struct objfile *objfile, const section_offsets &new_offsets)
struct obj_section * find_pc_section(CORE_ADDR pc)
const char * objfile_name(const struct objfile *objfile)
struct program_space * current_program_space
static struct solib_aix_inferior_data * get_solib_aix_inferior_data(struct inferior *inf)
static CORE_ADDR solib_aix_bss_data_overlap(bfd *abfd)
static void solib_aix_normal_stop_observer(struct bpstat *unused_1, int unused_2)
static struct so_list * solib_aix_current_sos(void)
static void solib_aix_solib_create_inferior_hook(int from_tty)
static const registry< inferior >::key< solib_aix_inferior_data > solib_aix_inferior_data_handle
static void solib_aix_clear_solib(void)
void _initialize_solib_aix()
static struct obj_section * data_obj_section_from_objfile(struct objfile *objfile)
static void solib_aix_free_so(struct so_list *so)
static section_offsets solib_aix_get_section_offsets(struct objfile *objfile, lm_info_aix *info)
static gdb_bfd_ref_ptr solib_aix_bfd_open(const char *pathname)
static gdb::optional< std::vector< lm_info_aix > > solib_aix_parse_libraries(const char *library)
const struct target_so_ops solib_aix_so_ops
static void solib_aix_relocate_section_addresses(struct so_list *so, struct target_section *sec)
static int solib_aix_open_symbol_file_object(int from_tty)
static gdb::optional< std::vector< lm_info_aix > > & solib_aix_get_library_list(struct inferior *inf, const char *warning_msg)
CORE_ADDR solib_aix_get_toc_value(CORE_ADDR pc)
static int solib_aix_in_dynsym_resolve_code(CORE_ADDR pc)
gdb_bfd_ref_ptr solib_bfd_fopen(const char *pathname, int fd)
gdb_bfd_ref_ptr solib_bfd_open(const char *pathname)
gdb::unique_xmalloc_ptr< char > solib_find(const char *in_pathname, int *fd)
#define solib_debug_printf(fmt,...)
#define SO_NAME_MAX_PATH_SIZE
gdb::unique_xmalloc_ptr< void > value
struct bfd_section * the_bfd_section
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]
gdb::optional< std::vector< lm_info_aix > > library_list
struct bfd_section * the_bfd_section
std::vector< CORE_ADDR > section_offsets
gdb::optional< gdb::char_vector > target_read_stralloc(struct target_ops *ops, enum target_object object, const char *annex)
@ TARGET_OBJECT_LIBRARIES_AIX
CORE_ADDR xcoff_get_toc_offset(struct objfile *objfile)
void void gdb_xml_error(struct gdb_xml_parser *parser, const char *format,...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF(2
void void struct gdb_xml_value * xml_find_attribute(std::vector< gdb_xml_value > &attributes, const char *name)
int gdb_xml_parse_quick(const char *name, const char *dtd_name, const struct gdb_xml_element *elements, const char *document, void *user_data)
gdb_xml_attribute_handler gdb_xml_parse_attr_ulongest