- Elf32_Obj_Info list_32;
-
- read_memory (lladdr, (char *) &list_32, sizeof (Elf32_Obj_Info));
- if (list_32.oi_size != sizeof (Elf32_Obj_Info))
- return;
- new_lm -> l_variant = OBJ_LIST_32;
- new_lm -> l_next = (CORE_ADDR) list_32.oi_next;
-
- target_read_string ((CORE_ADDR) list_32.oi_pathname,
- &so_list_ptr -> so_name,
- list_32.oi_pathname_len + 1, &errcode);
- if (errcode != 0)
- memory_error (errcode, (CORE_ADDR) list_32.oi_pathname);
-
- LM_ADDR (so_list_ptr) = (CORE_ADDR) list_32.oi_ehdr;
- LM_OFFSET (so_list_ptr) =
- (CORE_ADDR) list_32.oi_ehdr - (CORE_ADDR) list_32.oi_orig_ehdr;
- }
- else
-#endif
- {
-#if defined (_MIPS_SIM_NABI32) && _MIPS_SIM == _MIPS_SIM_NABI32
- /* If we are compiling GDB under N32 ABI, the alignments in
- the obj struct are different from the O32 ABI and we will get
- wrong values when accessing the struct.
- As a workaround we use fixed values which are good for
- Irix 6.2. */
- char buf[432];
-
- read_memory ((CORE_ADDR) list_old.data, buf, sizeof (buf));
-
- target_read_string (extract_address (&buf[236], 4),
- &so_list_ptr -> so_name,
- INT_MAX, &errcode);
- if (errcode != 0)
- memory_error (errcode, extract_address (&buf[236], 4));
-
- LM_ADDR (so_list_ptr) = extract_address (&buf[196], 4);
- LM_OFFSET (so_list_ptr) =
- extract_address (&buf[196], 4) - extract_address (&buf[248], 4);
-#else
- struct obj obj_old;
-
- read_memory ((CORE_ADDR) list_old.data, (char *) &obj_old,
- sizeof (struct obj));
-
- target_read_string ((CORE_ADDR) obj_old.o_path,
- &so_list_ptr -> so_name,
- INT_MAX, &errcode);
- if (errcode != 0)
- memory_error (errcode, (CORE_ADDR) obj_old.o_path);
-
- LM_ADDR (so_list_ptr) = (CORE_ADDR) obj_old.o_praw;
- LM_OFFSET (so_list_ptr) =
- (CORE_ADDR) obj_old.o_praw - obj_old.o_base_address;
-#endif
- }
-
- solib_map_sections (so_list_ptr);
-}
-
-
-/*
-
-LOCAL FUNCTION
-
- find_solib -- step through list of shared objects
-
-SYNOPSIS
-
- struct so_list *find_solib (struct so_list *so_list_ptr)
-
-DESCRIPTION
-
- This module contains the routine which finds the names of any
- loaded "images" in the current process. The argument in must be
- NULL on the first call, and then the returned value must be passed
- in on subsequent calls. This provides the capability to "step" down
- the list of loaded objects. On the last object, a NULL value is
- returned.
- */
-
-static struct so_list *
-find_solib (so_list_ptr)
- struct so_list *so_list_ptr; /* Last lm or NULL for first one */
-{
- struct so_list *so_list_next = NULL;
- struct link_map *lm = NULL;
- struct so_list *new;
-
- if (so_list_ptr == NULL)
- {
- /* We are setting up for a new scan through the loaded images. */
- if ((so_list_next = so_list_head) == NULL)
- {
- /* Find the first link map list member. */
- lm = first_link_map_member ();
- }
- }
- else
- {
- /* We have been called before, and are in the process of walking
- the shared library list. Advance to the next shared object. */
- lm = next_link_map_member (so_list_ptr);
- so_list_next = so_list_ptr -> next;
- }
- if ((so_list_next == NULL) && (lm != NULL))
- {
- new = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset ((char *) new, 0, sizeof (struct so_list));
- /* Add the new node as the next node in the list, or as the root
- node if this is the first one. */
- if (so_list_ptr != NULL)
- {
- so_list_ptr -> next = new;
- }
- else
- {
- so_list_head = new;
- }
- so_list_next = new;
- xfer_link_map_member (new, lm);
- }
- return (so_list_next);
-}
-
-/* A small stub to get us past the arg-passing pinhole of catch_errors. */
-
-static int
-symbol_add_stub (arg)
- char *arg;
-{
- register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
- CORE_ADDR text_addr = 0;
-
- if (so -> textsection)
- text_addr = so -> textsection -> addr;
- else
- {
- asection *lowest_sect;
-
- /* If we didn't find a mapped non zero sized .text section, set up
- text_addr so that the relocation in symbol_file_add does no harm. */
-
- lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
- if (lowest_sect == NULL)
- bfd_map_over_sections (so -> abfd, find_lowest_section,
- (PTR) &lowest_sect);
- if (lowest_sect)
- text_addr = bfd_section_vma (so -> abfd, lowest_sect) + LM_OFFSET (so);
- }
-
- so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- text_addr,
- 0, 0, 0);
- return (1);
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_add -- add a shared library file to the symtab and section list
-
-SYNOPSIS
-
- void solib_add (char *arg_string, int from_tty,
- struct target_ops *target)
-
-DESCRIPTION
-
-*/
-
-void
-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- register struct so_list *so = NULL; /* link map state variable */
-
- /* Last shared library that we read. */
- struct so_list *so_last = NULL;
-
- char *re_err;
- int count;
- int old;
-
- if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
- {
- error ("Invalid regexp: %s", re_err);
- }
-
- /* Add the shared library sections to the section table of the
- specified target, if any. */
- if (target)
- {
- /* Count how many new section_table entries there are. */
- so = NULL;
- count = 0;
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count += so -> sections_end - so -> sections;
- }
- }
-
- if (count)
- {
- int update_coreops;
-
- /* We must update the to_sections field in the core_ops structure
- here, otherwise we dereference a potential dangling pointer
- for each call to target_read/write_memory within this routine. */
- update_coreops = core_ops.to_sections == target->to_sections;
-
- /* Reallocate the target's section table including the new size. */
- if (target -> to_sections)
- {
- old = target -> to_sections_end - target -> to_sections;
- target -> to_sections = (struct section_table *)
- xrealloc ((char *)target -> to_sections,
- (sizeof (struct section_table)) * (count + old));
- }
- else
- {
- old = 0;
- target -> to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * count);
- }
- target -> to_sections_end = target -> to_sections + (count + old);
-
- /* Update the to_sections field in the core_ops structure
- if needed. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
-
- /* Add these section table entries to the target's table. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count = so -> sections_end - so -> sections;
- memcpy ((char *) (target -> to_sections + old),
- so -> sections,
- (sizeof (struct section_table)) * count);
- old += count;
- }
- }
- }
- }
-
- /* Now add the symbol files. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0] && re_exec (so -> so_name))
- {
- so -> from_tty = from_tty;
- if (so -> symbols_loaded)
- {
- if (from_tty)
- {
- printf_unfiltered ("Symbols already loaded for %s\n", so -> so_name);
- }
- }
- else if (catch_errors
- (symbol_add_stub, (char *) so,
- "Error while reading shared library symbols:\n",
- RETURN_MASK_ALL))
- {
- so_last = so;
- so -> symbols_loaded = 1;
- }
- }
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- if (so_last)
- reinit_frame_cache ();
-}
-
-/*
-
-LOCAL FUNCTION
-
- info_sharedlibrary_command -- code for "info sharedlibrary"
-
-SYNOPSIS
-
- static void info_sharedlibrary_command ()
-
-DESCRIPTION
-
- Walk through the shared library list and print information
- about each attached library.
-*/
-
-static void
-info_sharedlibrary_command (ignore, from_tty)
- char *ignore;
- int from_tty;
-{
- register struct so_list *so = NULL; /* link map state variable */
- int header_done = 0;
-
- if (exec_bfd == NULL)
- {
- printf_unfiltered ("No exec file.\n");