gdb/features: remove rx.xml from XMLTOC list
[deliverable/binutils-gdb.git] / sim / rl78 / load.c
index f2a7d5d712fca4f628cec57c4bea954f1a55a912..1776f488d5a6a1ab7332639581406c267513fa76 100644 (file)
@@ -1,6 +1,6 @@
 /* load.c --- loading object files into the RL78 simulator.
 
 /* load.c --- loading object files into the RL78 simulator.
 
-   Copyright (C) 2005, 2007-2012 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.
    Contributed by Red Hat, Inc.
 
    This file is part of the GNU simulators.
@@ -27,7 +27,8 @@
 
 #include "libiberty.h"
 #include "bfd.h"
 
 #include "libiberty.h"
 #include "bfd.h"
-#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/rl78.h"
 #include "cpu.h"
 #include "mem.h"
 #include "load.h"
 #include "cpu.h"
 #include "mem.h"
 #include "load.h"
@@ -55,7 +56,7 @@ find_section_name_by_offset (bfd *abfd, file_ptr filepos)
 
   for (s = abfd->sections; s; s = s->next)
     if (s->filepos == filepos)
 
   for (s = abfd->sections; s; s = s->next)
     if (s->filepos == filepos)
-      return bfd_get_section_name (abfd, s);
+      return bfd_section_name (s);
 
   return "(unknown)";
 }
 
   return "(unknown)";
 }
@@ -89,7 +90,30 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
       fprintf (stderr, "%s: Failed to read program headers\n", simname);
       return;
     }
       fprintf (stderr, "%s: Failed to read program headers\n", simname);
       return;
     }
-  
+
+  switch (elf_elfheader (prog)->e_flags & E_FLAG_RL78_CPU_MASK)
+    {
+    case E_FLAG_RL78_G10:
+      rl78_g10_mode = 1;
+      g13_multiply = 0;
+      g14_multiply = 0;
+      mem_set_mirror (0, 0xf8000, 4096);
+      break;
+    case E_FLAG_RL78_G13:
+      rl78_g10_mode = 0;
+      g13_multiply = 1;
+      g14_multiply = 0;
+      break;
+    case E_FLAG_RL78_G14:
+      rl78_g10_mode = 0;
+      g13_multiply = 0;
+      g14_multiply = 1;
+      break;
+    default:
+      /* Keep whatever was manually specified.  */
+      break;
+    }
+
   for (i = 0; i < num_headers; i++)
     {
       Elf_Internal_Phdr * p = phdrs + i;
   for (i = 0; i < num_headers; i++)
     {
       Elf_Internal_Phdr * p = phdrs + i;
@@ -115,13 +139,13 @@ rl78_load (bfd *prog, host_callback *callbacks, const char * const simname)
       buf = xmalloc (size);
 
       offset = p->p_offset;
       buf = xmalloc (size);
 
       offset = p->p_offset;
-      if (prog->iovec->bseek (prog, offset, SEEK_SET) != 0)
+      if (bfd_seek (prog, offset, SEEK_SET) != 0)
        {
          fprintf (stderr, "%s, Failed to seek to offset %lx\n", simname, (long) offset);
          continue;
        }
 
        {
          fprintf (stderr, "%s, Failed to seek to offset %lx\n", simname, (long) offset);
          continue;
        }
 
-      if (prog->iovec->bread (prog, buf, size) != size)
+      if (bfd_bread (buf, size, prog) != size)
        {
          fprintf (stderr, "%s: Failed to read %lx bytes\n", simname, size);
          continue;
        {
          fprintf (stderr, "%s: Failed to read %lx bytes\n", simname, size);
          continue;
This page took 0.023598 seconds and 4 git commands to generate.