Add multi-target tests
[deliverable/binutils-gdb.git] / sim / rx / load.c
index 4b723744abdb33e5f85e582eeeb0037ae39048a3..fcf3bf385443e2040c272ca9e8b225f6994cd36d 100644 (file)
@@ -1,6 +1,6 @@
 /* load.c --- loading object files into the RX simulator.
 
-Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright (C) 2005-2020 Free Software Foundation, Inc.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
@@ -19,17 +19,44 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "bfd.h"
-#include "libbfd.h"
 #include "cpu.h"
 #include "mem.h"
+#include "load.h"
 #include "elf/internal.h"
 #include "elf/common.h"
 
+/* Helper function for invoking a GDB-specified printf.  */
+static void
+xprintf (host_callback *callback, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+
+  (*callback->vprintf_filtered) (callback, fmt, ap);
+
+  va_end (ap);
+}
+
+/* Given a file offset, look up the section name.  */
+static const char *
+find_section_name_by_offset (bfd *abfd, file_ptr filepos)
+{
+  asection *s;
+
+  for (s = abfd->sections; s; s = s->next)
+    if (s->filepos == filepos)
+      return bfd_section_name (s);
+
+  return "(unknown)";
+}
+
 /* A note about endianness and swapping...
 
    The RX chip is CISC-like in that the opcodes are variable length
@@ -55,7 +82,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    encoded in little-endian format.  */
 
 void
-rx_load (bfd *prog)
+rx_load (bfd *prog, host_callback *callback)
 {
   unsigned long highest_addr_loaded = 0;
   Elf_Internal_Phdr * phdrs;
@@ -104,6 +131,11 @@ rx_load (bfd *prog)
       if (verbose > 1)
        fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n",
                 (int) base, (int) p->p_vaddr, (int) size);
+      if (callback)
+       xprintf (callback,
+                "Loading section %s, size %#lx lma %08lx vma %08lx\n",
+                find_section_name_by_offset (prog, p->p_offset),
+                size, base, p->p_vaddr);
 
       buf = malloc (size);
       if (buf == NULL)
@@ -113,12 +145,12 @@ rx_load (bfd *prog)
        }
       
       offset = p->p_offset;
-      if (prog->iovec->bseek (prog, offset, SEEK_SET) != 0)
+      if (bfd_seek (prog, offset, SEEK_SET) != 0)
        {
          fprintf (stderr, "Failed to seek to offset %lx\n", (long) offset);
          continue;
        }
-      if (prog->iovec->bread (prog, buf, size) != size)
+      if (bfd_bread (buf, size, prog) != size)
        {
          fprintf (stderr, "Failed to read %lx bytes\n", size);
          continue;
@@ -141,6 +173,8 @@ rx_load (bfd *prog)
       heaptop = heapbottom = 0;
     }
 
+  reset_decoder ();
+
   if (verbose > 1)
     fprintf (stderr, "[start pc=%08x %s]\n",
             (unsigned int) regs.r_pc,
This page took 0.026191 seconds and 4 git commands to generate.