Automatic date update in version.in
[deliverable/binutils-gdb.git] / sim / common / sim-load.c
index 7e29f6c306e51173ba3a5bcbfd3dc90fd5d39d5e..3ea50e7fbcdecdb512198803ed102c97d100f3a0 100644 (file)
@@ -1,5 +1,5 @@
 /* Utility to load a file into the simulator.
-   Copyright (C) 1997-2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -18,29 +18,26 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    as it is used by simulators that don't use it [though that doesn't mean
    to suggest that they shouldn't :-)].  */
 
-#ifdef HAVE_CONFIG_H
-#include "cconfig.h"
-#endif
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include "ansidecl.h"
 #include <stdio.h> /* for NULL */
 #include <stdarg.h>
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
 #include <time.h>
 
 #include "sim-basics.h"
 #include "bfd.h"
 #include "sim-utils.h"
 
-#include "gdb/callback.h"
-#include "gdb/remote-sim.h"
+#include "sim/callback.h"
+#include "sim/sim.h"
 
 static void eprintf (host_callback *, const char *, ...);
 static void xprintf (host_callback *, const char *, ...);
 static void report_transfer_performance
   (host_callback *, unsigned long, time_t, time_t);
-static void xprintf_bfd_vma (host_callback *, bfd_vma);
 
 /* Load program PROG into the simulator using the function DO_LOAD.
    If PROG_BFD is non-NULL, the file has already been opened.
@@ -101,7 +98,7 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
        {
          bfd_size_type size;
 
-         size = bfd_get_section_size (s);
+         size = bfd_section_size (s);
          if (size > 0)
            {
              unsigned char *buffer;
@@ -119,17 +116,17 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
                  return NULL;
                }
              if (lma_p)
-               lma = bfd_section_lma (result_bfd, s);
+               lma = bfd_section_lma (s);
              else
-               lma = bfd_section_vma (result_bfd, s);
+               lma = bfd_section_vma (s);
              if (verbose_p)
                {
-                 xprintf (callback, "Loading section %s, size 0x%lx %s ",
-                          bfd_get_section_name (result_bfd, s),
+                 xprintf (callback,
+                          "Loading section %s, size 0x%lx %s "
+                          "%" BFD_VMA_FMT "x\n",
+                          bfd_section_name (s),
                           (unsigned long) size,
-                          (lma_p ? "lma" : "vma"));
-                 xprintf_bfd_vma (callback, lma);
-                 xprintf (callback, "\n");
+                          (lma_p ? "lma" : "vma"), lma);
                }
              data_count += size;
              bfd_get_section_contents (result_bfd, s, buffer, 0, size);
@@ -151,9 +148,8 @@ sim_load_file (SIM_DESC sd, const char *myname, host_callback *callback,
   if (verbose_p)
     {
       end_time = time (NULL);
-      xprintf (callback, "Start address ");
-      xprintf_bfd_vma (callback, bfd_get_start_address (result_bfd));
-      xprintf (callback, "\n");
+      xprintf (callback, "Start address %" BFD_VMA_FMT "x\n",
+              bfd_get_start_address (result_bfd));
       report_transfer_performance (callback, data_count, start_time, end_time);
     }
 
@@ -200,13 +196,3 @@ report_transfer_performance (host_callback *callback, unsigned long data_count,
     xprintf (callback, "%ld bits in <1 sec", (data_count * 8));
   xprintf (callback, ".\n");
 }
-
-/* Print a bfd_vma.
-   This is intended to handle the vagaries of 32 vs 64 bits, etc.  */
-
-static void
-xprintf_bfd_vma (host_callback *callback, bfd_vma vma)
-{
-  /* FIXME: for now */
-  xprintf (callback, "0x%lx", (unsigned long) vma);
-}
This page took 0.025086 seconds and 4 git commands to generate.