/* 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
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.
{
bfd_size_type size;
- size = bfd_get_section_size (s);
+ size = bfd_section_size (s);
if (size > 0)
{
unsigned char *buffer;
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);
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);
}
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);
-}