30#include "gdbsupport/scope-exit.h"
93#if !defined(HAVE_LIBEXPAT)
97static gdb::optional<std::vector<lm_info_aix>>
100 static int have_warned;
105 warning (_(
"Can not parse XML library list; XML support was disabled "
124 std::vector<lm_info_aix> *list = (std::vector<lm_info_aix> *)
user_data;
147 list->push_back (std::move (item));
161 if (strcmp (
version,
"1.0") != 0)
163 _(
"Library list has unsupported version \"%s\""),
207static gdb::optional<std::vector<lm_info_aix>>
210 std::vector<lm_info_aix> result;
231static gdb::optional<std::vector<lm_info_aix>> &
238 if (data->library_list.has_value ())
239 return data->library_list;
241 gdb::optional<gdb::char_vector> library_document
245 if (!library_document && warning_msg != NULL)
247 warning (_(
"%s (failed to read TARGET_OBJECT_LIBRARIES_AIX)"),
249 return data->library_list;
253 library_document->data ());
256 if (!data->library_list.has_value () && warning_msg != NULL)
257 warning (_(
"%s (missing XML support?)"), warning_msg);
259 return data->library_list;
289 struct bfd_section *data_sect, *bss_sect;
291 data_sect = bfd_get_section_by_name (abfd,
".data");
292 if (data_sect == NULL)
295 bss_sect = bfd_get_section_by_name (abfd,
".bss");
296 if (bss_sect == NULL)
303 if (bfd_section_vma (bss_sect) < bfd_section_vma (data_sect))
306 if (bfd_section_vma (bss_sect)
307 < bfd_section_vma (data_sect) + bfd_section_size (data_sect))
308 return (bfd_section_vma (data_sect) + bfd_section_size (data_sect)
309 - bfd_section_vma (bss_sect));
321 bfd *abfd = bfd_sect->owner;
322 const char *section_name = bfd_section_name (bfd_sect);
325 if (strcmp (section_name,
".text") == 0)
327 sec->
addr = info->text_addr;
332 sec->
addr += bfd_sect->filepos;
334 else if (strcmp (section_name,
".data") == 0)
336 sec->
addr = info->data_addr;
339 else if (strcmp (section_name,
".bss") == 0)
348 struct bfd_section *data_sect
349 = bfd_get_section_by_name (abfd,
".data");
350 CORE_ADDR data_offset = 0;
352 if (data_sect != NULL)
353 data_offset = info->data_addr - bfd_section_vma (data_sect);
355 sec->
addr = bfd_section_vma (bfd_sect) + data_offset;
357 sec->
endaddr = sec->
addr + bfd_section_size (bfd_sect);
362 sec->
addr = bfd_section_vma (bfd_sect);
363 sec->
endaddr = sec->
addr + bfd_section_size (bfd_sect);
402 struct bfd_section *sect
406 = info->text_addr + sect->filepos - bfd_section_vma (sect);
413 struct bfd_section *sect
417 = info->data_addr - bfd_section_vma (sect);
444 const char *warning_msg =
"unable to relocate main executable";
448 gdb::optional<std::vector<lm_info_aix>> &library_list
450 if (!library_list.has_value ())
453 if (library_list->empty ())
455 warning (_(
"unable to relocate main executable (no info from loader)"));
475 struct so_list *start = NULL, *last = NULL;
478 gdb::optional<std::vector<lm_info_aix>> &library_list
480 if (!library_list.has_value ())
486 for (ix = 1; ix < library_list->size (); ix++)
492 if (info.member_name.empty ())
506 so_name = string_printf (
"%s(%s)", info.filename.c_str (),
507 info.member_name.c_str ());
518 last = start = new_solib;
521 last->
next = new_solib;
556 const int path_len = strlen (pathname);
561 if (pathname[path_len - 1] !=
')')
565 sep = strrchr (pathname,
'(');
571 warning (_(
"missing '(' in shared object pathname: %s"), pathname);
574 filename_len = sep - pathname;
576 std::string filename (string_printf (
"%.*s", filename_len, pathname));
577 std::string member_name (string_printf (
"%.*s", path_len - filename_len - 2,
583 gdb::unique_xmalloc_ptr<char> found_pathname
584 =
solib_find (filename.c_str (), &found_file);
585 if (found_pathname == NULL)
589 if (archive_bfd == NULL)
591 warning (_(
"Could not open `%s' as an executable file: %s"),
592 filename.c_str (), bfd_errmsg (bfd_get_error ()));
596 if (bfd_check_format (archive_bfd.get (), bfd_object))
599 if (! bfd_check_format (archive_bfd.get (), bfd_archive))
601 warning (_(
"\"%s\": not in executable format: %s."),
602 filename.c_str (), bfd_errmsg (bfd_get_error ()));
608 while (object_bfd != NULL)
610 if (member_name == bfd_get_filename (object_bfd.get ()))
617 if (object_bfd == NULL)
619 warning (_(
"\"%s\": member \"%s\" missing."), filename.c_str (),
620 member_name.c_str ());
624 if (! bfd_check_format (object_bfd.get (), bfd_object))
626 warning (_(
"%s(%s): not in object format: %s."),
627 filename.c_str (), member_name.c_str (),
628 bfd_errmsg (bfd_get_error ()));
636 std::string fname = string_printf (
"%s%s",
637 bfd_get_filename (archive_bfd.get ()),
639 bfd_set_filename (object_bfd.get (), fname.c_str ());
670 if (pc_osect == NULL)
671 error (_(
"unable to find TOC entry for pc %s "
672 "(no section contains this PC)"),
673 core_addr_to_string (pc));
676 if (data_osect == NULL)
677 error (_(
"unable to find TOC entry for pc %s "
678 "(%s has no data section)"),
684 core_addr_to_string (result));
700 data->library_list.reset ();
static struct @4 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)
#define ALL_OBJFILE_OSECTIONS(objfile, osect)
struct program_space * current_program_space
static void library_list_start_library(struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, std::vector< gdb_xml_value > &attributes)
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 struct gdb_xml_attribute library_attributes[]
static void library_list_start_list(struct gdb_xml_parser *parser, const struct gdb_xml_element *element, void *user_data, std::vector< gdb_xml_value > &attributes)
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 const struct gdb_xml_attribute library_list_attributes[]
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)
static const struct gdb_xml_element library_list_elements[]
static const struct gdb_xml_element library_list_children[]
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
::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
void perror_with_name(const char *string)
CORE_ADDR xcoff_get_toc_offset(struct objfile *objfile)
void gdb_xml_error(struct gdb_xml_parser *parser, const char *format,...)
int gdb_xml_parse_quick(const char *name, const char *dtd_name, const struct gdb_xml_element *elements, const char *document, void *user_data)
struct gdb_xml_value * xml_find_attribute(std::vector< gdb_xml_value > &attributes, const char *name)
gdb_xml_attribute_handler gdb_xml_parse_attr_ulongest