gdb/compile/compile-object-load.c - gdb

Global variables defined

Data types defined

Functions defined

Source code

  1. /* Load module for 'compile' command.

  2.    Copyright (C) 2014-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "compile-object-load.h"
  16. #include "compile-internal.h"
  17. #include "command.h"
  18. #include "objfiles.h"
  19. #include "gdbcore.h"
  20. #include "readline/tilde.h"
  21. #include "bfdlink.h"
  22. #include "gdbcmd.h"
  23. #include "regcache.h"
  24. #include "inferior.h"
  25. #include "compile.h"
  26. #include "arch-utils.h"

  27. /* Helper data for setup_sections.  */

  28. struct setup_sections_data
  29. {
  30.   /* Size of all recent sections with matching LAST_PROT.  */
  31.   CORE_ADDR last_size;

  32.   /* First section matching LAST_PROT.  */
  33.   asection *last_section_first;

  34.   /* Memory protection like the prot parameter of gdbarch_infcall_mmap. */
  35.   unsigned last_prot;

  36.   /* Maximum of alignments of all sections matching LAST_PROT.
  37.      This value is always at least 1.  This value is always a power of 2.  */
  38.   CORE_ADDR last_max_alignment;
  39. };

  40. /* Place all ABFD sections next to each other obeying all constraints.  */

  41. static void
  42. setup_sections (bfd *abfd, asection *sect, void *data_voidp)
  43. {
  44.   struct setup_sections_data *data = data_voidp;
  45.   CORE_ADDR alignment;
  46.   unsigned prot;

  47.   if (sect != NULL)
  48.     {
  49.       /* It is required by later bfd_get_relocated_section_contents.  */
  50.       if (sect->output_section == NULL)
  51.         sect->output_section = sect;

  52.       if ((bfd_get_section_flags (abfd, sect) & SEC_ALLOC) == 0)
  53.         return;

  54.       // Make the memory always readable.
  55.       prot = GDB_MMAP_PROT_READ;
  56.       if ((bfd_get_section_flags (abfd, sect) & SEC_READONLY) == 0)
  57.         prot |= GDB_MMAP_PROT_WRITE;
  58.       if ((bfd_get_section_flags (abfd, sect) & SEC_CODE) != 0)
  59.         prot |= GDB_MMAP_PROT_EXEC;

  60.       if (compile_debug)
  61.         fprintf_unfiltered (gdb_stdout,
  62.                             "module \"%s\" section \"%s\" size %s prot %u\n",
  63.                             bfd_get_filename (abfd),
  64.                             bfd_get_section_name (abfd, sect),
  65.                             paddress (target_gdbarch (),
  66.                                       bfd_get_section_size (sect)),
  67.                             prot);
  68.     }
  69.   else
  70.     prot = -1;

  71.   if (sect == NULL
  72.       || (data->last_prot != prot && bfd_get_section_size (sect) != 0))
  73.     {
  74.       CORE_ADDR addr;
  75.       asection *sect_iter;

  76.       if (data->last_size != 0)
  77.         {
  78.           addr = gdbarch_infcall_mmap (target_gdbarch (), data->last_size,
  79.                                        data->last_prot);
  80.           if (compile_debug)
  81.             fprintf_unfiltered (gdb_stdout,
  82.                                 "allocated %s bytes at %s prot %u\n",
  83.                                 paddress (target_gdbarch (), data->last_size),
  84.                                 paddress (target_gdbarch (), addr),
  85.                                 data->last_prot);
  86.         }
  87.       else
  88.         addr = 0;

  89.       if ((addr & (data->last_max_alignment - 1)) != 0)
  90.         error (_("Inferior compiled module address %s "
  91.                  "is not aligned to BFD required %s."),
  92.                paddress (target_gdbarch (), addr),
  93.                paddress (target_gdbarch (), data->last_max_alignment));

  94.       for (sect_iter = data->last_section_first; sect_iter != sect;
  95.            sect_iter = sect_iter->next)
  96.         if ((bfd_get_section_flags (abfd, sect_iter) & SEC_ALLOC) != 0)
  97.           bfd_set_section_vma (abfd, sect_iter,
  98.                                addr + bfd_get_section_vma (abfd, sect_iter));

  99.       data->last_size = 0;
  100.       data->last_section_first = sect;
  101.       data->last_prot = prot;
  102.       data->last_max_alignment = 1;
  103.     }

  104.   if (sect == NULL)
  105.     return;

  106.   alignment = ((CORE_ADDR) 1) << bfd_get_section_alignment (abfd, sect);
  107.   data->last_max_alignment = max (data->last_max_alignment, alignment);

  108.   data->last_size = (data->last_size + alignment - 1) & -alignment;

  109.   bfd_set_section_vma (abfd, sect, data->last_size);

  110.   data->last_size += bfd_get_section_size (sect);
  111.   data->last_size = (data->last_size + alignment - 1) & -alignment;
  112. }

  113. /* Helper for link_callbacks callbacks vector.  */

  114. static bfd_boolean
  115. link_callbacks_multiple_definition (struct bfd_link_info *link_info,
  116.                                     struct bfd_link_hash_entry *h, bfd *nbfd,
  117.                                     asection *nsec, bfd_vma nval)
  118. {
  119.   bfd *abfd = link_info->input_bfds;

  120.   if (link_info->allow_multiple_definition)
  121.     return TRUE;
  122.   warning (_("Compiled module \"%s\": multiple symbol definitions: %s"),
  123.            bfd_get_filename (abfd), h->root.string);
  124.   return FALSE;
  125. }

  126. /* Helper for link_callbacks callbacks vector.  */

  127. static bfd_boolean
  128. link_callbacks_warning (struct bfd_link_info *link_info, const char *xwarning,
  129.                         const char *symbol, bfd *abfd, asection *section,
  130.                         bfd_vma address)
  131. {
  132.   warning (_("Compiled module \"%s\" section \"%s\": warning: %s"),
  133.            bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
  134.            xwarning);
  135.   /* Maybe permit running as a module?  */
  136.   return FALSE;
  137. }

  138. /* Helper for link_callbacks callbacks vector.  */

  139. static bfd_boolean
  140. link_callbacks_undefined_symbol (struct bfd_link_info *link_info,
  141.                                  const char *name, bfd *abfd, asection *section,
  142.                                  bfd_vma address, bfd_boolean is_fatal)
  143. {
  144.   warning (_("Cannot resolve relocation to \"%s\" "
  145.              "from compiled module \"%s\" section \"%s\"."),
  146.            name, bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
  147.   return FALSE;
  148. }

  149. /* Helper for link_callbacks callbacks vector.  */

  150. static bfd_boolean
  151. link_callbacks_reloc_overflow (struct bfd_link_info *link_info,
  152.                                struct bfd_link_hash_entry *entry,
  153.                                const char *name, const char *reloc_name,
  154.                                bfd_vma addend, bfd *abfd, asection *section,
  155.                                bfd_vma address)
  156. {
  157.   /* TRUE is required for intra-module relocations.  */
  158.   return TRUE;
  159. }

  160. /* Helper for link_callbacks callbacks vector.  */

  161. static bfd_boolean
  162. link_callbacks_reloc_dangerous (struct bfd_link_info *link_info,
  163.                                 const char *message, bfd *abfd,
  164.                                 asection *section, bfd_vma address)
  165. {
  166.   warning (_("Compiled module \"%s\" section \"%s\": dangerous "
  167.              "relocation: %s\n"),
  168.            bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
  169.            message);
  170.   return FALSE;
  171. }

  172. /* Helper for link_callbacks callbacks vector.  */

  173. static bfd_boolean
  174. link_callbacks_unattached_reloc (struct bfd_link_info *link_info,
  175.                                  const char *name, bfd *abfd, asection *section,
  176.                                  bfd_vma address)
  177. {
  178.   warning (_("Compiled module \"%s\" section \"%s\": unattached "
  179.              "relocation: %s\n"),
  180.            bfd_get_filename (abfd), bfd_get_section_name (abfd, section),
  181.            name);
  182.   return FALSE;
  183. }

  184. /* Helper for link_callbacks callbacks vector.  */

  185. static void
  186. link_callbacks_einfo (const char *fmt, ...)
  187. {
  188.   struct cleanup *cleanups;
  189.   va_list ap;
  190.   char *str;

  191.   va_start (ap, fmt);
  192.   str = xstrvprintf (fmt, ap);
  193.   va_end (ap);
  194.   cleanups = make_cleanup (xfree, str);

  195.   warning (_("Compile module: warning: %s"), str);

  196.   do_cleanups (cleanups);
  197. }

  198. /* Helper for bfd_get_relocated_section_contents.
  199.    Only these symbols are set by bfd_simple_get_relocated_section_contents
  200.    but bfd/ seems to use even the NULL ones without checking them first.  */

  201. static const struct bfd_link_callbacks link_callbacks =
  202. {
  203.   NULL, /* add_archive_element */
  204.   link_callbacks_multiple_definition, /* multiple_definition */
  205.   NULL, /* multiple_common */
  206.   NULL, /* add_to_set */
  207.   NULL, /* constructor */
  208.   link_callbacks_warning, /* warning */
  209.   link_callbacks_undefined_symbol, /* undefined_symbol */
  210.   link_callbacks_reloc_overflow, /* reloc_overflow */
  211.   link_callbacks_reloc_dangerous, /* reloc_dangerous */
  212.   link_callbacks_unattached_reloc, /* unattached_reloc */
  213.   NULL, /* notice */
  214.   link_callbacks_einfo, /* einfo */
  215.   NULL, /* info */
  216.   NULL, /* minfo */
  217.   NULL, /* override_segment_assignment */
  218. };

  219. struct link_hash_table_cleanup_data
  220. {
  221.   bfd *abfd;
  222.   bfd *link_next;
  223. };

  224. /* Cleanup callback for struct bfd_link_info.  */

  225. static void
  226. link_hash_table_free (void *d)
  227. {
  228.   struct link_hash_table_cleanup_data *data = d;

  229.   if (data->abfd->is_linker_output)
  230.     (*data->abfd->link.hash->hash_table_free) (data->abfd);
  231.   data->abfd->link.next = data->link_next;
  232. }

  233. /* Relocate and store into inferior memory each section SECT of ABFD.  */

  234. static void
  235. copy_sections (bfd *abfd, asection *sect, void *data)
  236. {
  237.   asymbol **symbol_table = data;
  238.   bfd_byte *sect_data, *sect_data_got;
  239.   struct cleanup *cleanups;
  240.   struct bfd_link_info link_info;
  241.   struct bfd_link_order link_order;
  242.   CORE_ADDR inferior_addr;
  243.   struct link_hash_table_cleanup_data cleanup_data;

  244.   if ((bfd_get_section_flags (abfd, sect) & (SEC_ALLOC | SEC_LOAD))
  245.       != (SEC_ALLOC | SEC_LOAD))
  246.     return;

  247.   if (bfd_get_section_size (sect) == 0)
  248.     return;

  249.   /* Mostly a copy of bfd_simple_get_relocated_section_contents which GDB
  250.      cannot use as it does not report relocations to undefined symbols.  */
  251.   memset (&link_info, 0, sizeof (link_info));
  252.   link_info.output_bfd = abfd;
  253.   link_info.input_bfds = abfd;
  254.   link_info.input_bfds_tail = &abfd->link.next;

  255.   cleanup_data.abfd = abfd;
  256.   cleanup_data.link_next = abfd->link.next;

  257.   abfd->link.next = NULL;
  258.   link_info.hash = bfd_link_hash_table_create (abfd);

  259.   cleanups = make_cleanup (link_hash_table_free, &cleanup_data);
  260.   link_info.callbacks = &link_callbacks;

  261.   memset (&link_order, 0, sizeof (link_order));
  262.   link_order.next = NULL;
  263.   link_order.type = bfd_indirect_link_order;
  264.   link_order.offset = 0;
  265.   link_order.size = bfd_get_section_size (sect);
  266.   link_order.u.indirect.section = sect;

  267.   sect_data = xmalloc (bfd_get_section_size (sect));
  268.   make_cleanup (xfree, sect_data);

  269.   sect_data_got = bfd_get_relocated_section_contents (abfd, &link_info,
  270.                                                       &link_order, sect_data,
  271.                                                       FALSE, symbol_table);

  272.   if (sect_data_got == NULL)
  273.     error (_("Cannot map compiled module \"%s\" section \"%s\": %s"),
  274.            bfd_get_filename (abfd), bfd_get_section_name (abfd, sect),
  275.            bfd_errmsg (bfd_get_error ()));
  276.   gdb_assert (sect_data_got == sect_data);

  277.   inferior_addr = bfd_get_section_vma (abfd, sect);
  278.   if (0 != target_write_memory (inferior_addr, sect_data,
  279.                                 bfd_get_section_size (sect)))
  280.     error (_("Cannot write compiled module \"%s\" section \"%s\" "
  281.              "to inferior memory range %s-%s."),
  282.            bfd_get_filename (abfd), bfd_get_section_name (abfd, sect),
  283.            paddress (target_gdbarch (), inferior_addr),
  284.            paddress (target_gdbarch (),
  285.                      inferior_addr + bfd_get_section_size (sect)));

  286.   do_cleanups (cleanups);
  287. }

  288. /* Fetch the type of first parameter of GCC_FE_WRAPPER_FUNCTION.
  289.    Return NULL if GCC_FE_WRAPPER_FUNCTION has no parameters.
  290.    Throw an error otherwise.  */

  291. static struct type *
  292. get_regs_type (struct objfile *objfile)
  293. {
  294.   struct symbol *func_sym;
  295.   struct type *func_type, *regsp_type, *regs_type;

  296.   func_sym = lookup_global_symbol_from_objfile (objfile,
  297.                                                 GCC_FE_WRAPPER_FUNCTION,
  298.                                                 VAR_DOMAIN);
  299.   if (func_sym == NULL)
  300.     error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
  301.            GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));

  302.   func_type = SYMBOL_TYPE (func_sym);
  303.   if (TYPE_CODE (func_type) != TYPE_CODE_FUNC)
  304.     error (_("Invalid type code %d of function \"%s\" in compiled "
  305.              "module \"%s\"."),
  306.            TYPE_CODE (func_type), GCC_FE_WRAPPER_FUNCTION,
  307.            objfile_name (objfile));

  308.   /* No register parameter present.  */
  309.   if (TYPE_NFIELDS (func_type) == 0)
  310.     return NULL;

  311.   if (TYPE_NFIELDS (func_type) != 1)
  312.     error (_("Invalid %d parameters of function \"%s\" in compiled "
  313.              "module \"%s\"."),
  314.            TYPE_NFIELDS (func_type), GCC_FE_WRAPPER_FUNCTION,
  315.            objfile_name (objfile));

  316.   regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0));
  317.   if (TYPE_CODE (regsp_type) != TYPE_CODE_PTR)
  318.     error (_("Invalid type code %d of first parameter of function \"%s\" "
  319.              "in compiled module \"%s\"."),
  320.            TYPE_CODE (regsp_type), GCC_FE_WRAPPER_FUNCTION,
  321.            objfile_name (objfile));

  322.   regs_type = check_typedef (TYPE_TARGET_TYPE (regsp_type));
  323.   if (TYPE_CODE (regs_type) != TYPE_CODE_STRUCT)
  324.     error (_("Invalid type code %d of dereferenced first parameter "
  325.              "of function \"%s\" in compiled module \"%s\"."),
  326.            TYPE_CODE (regs_type), GCC_FE_WRAPPER_FUNCTION,
  327.            objfile_name (objfile));

  328.   return regs_type;
  329. }

  330. /* Store all inferior registers required by REGS_TYPE to inferior memory
  331.    starting at inferior address REGS_BASE.  */

  332. static void
  333. store_regs (struct type *regs_type, CORE_ADDR regs_base)
  334. {
  335.   struct gdbarch *gdbarch = target_gdbarch ();
  336.   struct regcache *regcache = get_thread_regcache (inferior_ptid);
  337.   int fieldno;

  338.   for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++)
  339.     {
  340.       const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno);
  341.       ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
  342.       ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
  343.       ULONGEST reg_offset;
  344.       struct type *reg_type = check_typedef (TYPE_FIELD_TYPE (regs_type,
  345.                                                               fieldno));
  346.       ULONGEST reg_size = TYPE_LENGTH (reg_type);
  347.       int regnum;
  348.       struct value *regval;
  349.       CORE_ADDR inferior_addr;

  350.       if (strcmp (reg_name, COMPILE_I_SIMPLE_REGISTER_DUMMY) == 0)
  351.         continue;

  352.       if ((reg_bitpos % 8) != 0 || reg_bitsize != 0)
  353.         error (_("Invalid register \"%s\" position %s bits or size %s bits"),
  354.                reg_name, pulongest (reg_bitpos), pulongest (reg_bitsize));
  355.       reg_offset = reg_bitpos / 8;

  356.       if (TYPE_CODE (reg_type) != TYPE_CODE_INT
  357.           && TYPE_CODE (reg_type) != TYPE_CODE_PTR)
  358.         error (_("Invalid register \"%s\" type code %d"), reg_name,
  359.                TYPE_CODE (reg_type));

  360.       regnum = compile_register_name_demangle (gdbarch, reg_name);

  361.       regval = value_from_register (reg_type, regnum, get_current_frame ());
  362.       if (value_optimized_out (regval))
  363.         error (_("Register \"%s\" is optimized out."), reg_name);
  364.       if (!value_entirely_available (regval))
  365.         error (_("Register \"%s\" is not available."), reg_name);

  366.       inferior_addr = regs_base + reg_offset;
  367.       if (0 != target_write_memory (inferior_addr, value_contents (regval),
  368.                                     reg_size))
  369.         error (_("Cannot write register \"%s\" to inferior memory at %s."),
  370.                reg_name, paddress (gdbarch, inferior_addr));
  371.     }
  372. }

  373. /* Load OBJECT_FILE into inferior memory.  Throw an error otherwise.
  374.    Caller must fully dispose the return value by calling compile_object_run.
  375.    SOURCE_FILE's copy is stored into the returned object.
  376.    Caller should free both OBJECT_FILE and SOURCE_FILE immediatelly after this
  377.    function returns.  */

  378. struct compile_module *
  379. compile_object_load (const char *object_file, const char *source_file)
  380. {
  381.   struct cleanup *cleanups, *cleanups_free_objfile;
  382.   bfd *abfd;
  383.   struct setup_sections_data setup_sections_data;
  384.   CORE_ADDR addr, func_addr, regs_addr;
  385.   struct bound_minimal_symbol bmsym;
  386.   long storage_needed;
  387.   asymbol **symbol_table, **symp;
  388.   long number_of_symbols, missing_symbols;
  389.   struct type *dptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
  390.   unsigned dptr_type_len = TYPE_LENGTH (dptr_type);
  391.   struct compile_module *retval;
  392.   struct type *regs_type;
  393.   char *filename, **matching;
  394.   struct objfile *objfile;

  395.   filename = tilde_expand (object_file);
  396.   cleanups = make_cleanup (xfree, filename);

  397.   abfd = gdb_bfd_open (filename, gnutarget, -1);
  398.   if (abfd == NULL)
  399.     error (_("\"%s\": could not open as compiled module: %s"),
  400.           filename, bfd_errmsg (bfd_get_error ()));
  401.   make_cleanup_bfd_unref (abfd);

  402.   if (!bfd_check_format_matches (abfd, bfd_object, &matching))
  403.     error (_("\"%s\": not in loadable format: %s"),
  404.           filename, gdb_bfd_errmsg (bfd_get_error (), matching));

  405.   if ((bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC)) != 0)
  406.     error (_("\"%s\": not in object format."), filename);

  407.   setup_sections_data.last_size = 0;
  408.   setup_sections_data.last_section_first = abfd->sections;
  409.   setup_sections_data.last_prot = -1;
  410.   setup_sections_data.last_max_alignment = 1;
  411.   bfd_map_over_sections (abfd, setup_sections, &setup_sections_data);
  412.   setup_sections (abfd, NULL, &setup_sections_data);

  413.   storage_needed = bfd_get_symtab_upper_bound (abfd);
  414.   if (storage_needed < 0)
  415.     error (_("Cannot read symbols of compiled module \"%s\": %s"),
  416.           filename, bfd_errmsg (bfd_get_error ()));

  417.   /* SYMFILE_VERBOSE is not passed even if FROM_TTY, user is not interested in
  418.      "Reading symbols from ..." message for automatically generated file.  */
  419.   objfile = symbol_file_add_from_bfd (abfd, filename, 0, NULL, 0, NULL);
  420.   cleanups_free_objfile = make_cleanup_free_objfile (objfile);

  421.   bmsym = lookup_minimal_symbol_text (GCC_FE_WRAPPER_FUNCTION, objfile);
  422.   if (bmsym.minsym == NULL || MSYMBOL_TYPE (bmsym.minsym) == mst_file_text)
  423.     error (_("Could not find symbol \"%s\" of compiled module \"%s\"."),
  424.            GCC_FE_WRAPPER_FUNCTION, filename);
  425.   func_addr = BMSYMBOL_VALUE_ADDRESS (bmsym);

  426.   /* The memory may be later needed
  427.      by bfd_generic_get_relocated_section_contents
  428.      called from default_symfile_relocate.  */
  429.   symbol_table = obstack_alloc (&objfile->objfile_obstack, storage_needed);
  430.   number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
  431.   if (number_of_symbols < 0)
  432.     error (_("Cannot parse symbols of compiled module \"%s\": %s"),
  433.           filename, bfd_errmsg (bfd_get_error ()));

  434.   missing_symbols = 0;
  435.   for (symp = symbol_table; symp < symbol_table + number_of_symbols; symp++)
  436.     {
  437.       asymbol *sym = *symp;

  438.       if (sym->flags != 0)
  439.         continue;
  440.       if (compile_debug)
  441.         fprintf_unfiltered (gdb_stdout,
  442.                             "lookup undefined ELF symbol \"%s\"\n",
  443.                             sym->name);
  444.       sym->flags = BSF_GLOBAL;
  445.       sym->section = bfd_abs_section_ptr;
  446.       if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0)
  447.         {
  448.           sym->value = 0;
  449.           continue;
  450.         }
  451.       bmsym = lookup_minimal_symbol (sym->name, NULL, NULL);
  452.       switch (bmsym.minsym == NULL
  453.               ? mst_unknown : MSYMBOL_TYPE (bmsym.minsym))
  454.         {
  455.         case mst_text:
  456.           sym->value = BMSYMBOL_VALUE_ADDRESS (bmsym);
  457.           break;
  458.         default:
  459.           warning (_("Could not find symbol \"%s\" "
  460.                      "for compiled module \"%s\"."),
  461.                    sym->name, filename);
  462.           missing_symbols++;
  463.         }
  464.     }
  465.   if (missing_symbols)
  466.     error (_("%ld symbols were missing, cannot continue."), missing_symbols);

  467.   bfd_map_over_sections (abfd, copy_sections, symbol_table);

  468.   regs_type = get_regs_type (objfile);
  469.   if (regs_type == NULL)
  470.     regs_addr = 0;
  471.   else
  472.     {
  473.       /* Use read-only non-executable memory protection.  */
  474.       regs_addr = gdbarch_infcall_mmap (target_gdbarch (),
  475.                                         TYPE_LENGTH (regs_type),
  476.                                         GDB_MMAP_PROT_READ);
  477.       gdb_assert (regs_addr != 0);
  478.       store_regs (regs_type, regs_addr);
  479.     }

  480.   discard_cleanups (cleanups_free_objfile);
  481.   do_cleanups (cleanups);

  482.   retval = xmalloc (sizeof (*retval));
  483.   retval->objfile = objfile;
  484.   retval->source_file = xstrdup (source_file);
  485.   retval->func_addr = func_addr;
  486.   retval->regs_addr = regs_addr;
  487.   return retval;
  488. }