sim: namespace sim_machs

We want to do a single build with all arches in one binary which means
we need to namespace sim_machs on a per-arch basis.  Move it from a
global variable to the sim description structure so it can be setup at
runtime.

Changing the SIM_MODEL->num from an enum to an int is unfortunate, but
we specifically don't want to maintain a centralized list anymore, and
this was never used directly in common code, just passed to per-arch
callbacks.
This commit is contained in:
Mike Frysinger
2021-06-28 21:42:56 -04:00
parent f8261de1b2
commit 1c636da093
35 changed files with 167 additions and 46 deletions

View File

@@ -1,3 +1,10 @@
2021-06-30 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Rename to ...
(lm32_sim_machs): ... this.
* sim-if.c (lm32_sim_machs): New decl.
(sim_open): Set STATE_MACH.
2021-06-29 Mike Frysinger <vapier@gentoo.org>
* arch.c (sim_machs): Mark const.

View File

@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
#include "sim-main.h"
#include "bfd.h"
const SIM_MACH * const sim_machs[] =
const SIM_MACH * const lm32_sim_machs[] =
{
#ifdef HAVE_CPU_LM32BF
& lm32_mach,

View File

@@ -80,6 +80,8 @@ find_limit (SIM_DESC sd)
return (addr + 65536) & ~(0xffffUL);
}
extern const SIM_MACH * const lm32_sim_machs[];
/* Create an instance of the simulator. */
SIM_DESC
@@ -92,6 +94,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
unsigned long base, limit;
/* Set default options before parsing user options. */
STATE_MACHS (sd) = lm32_sim_machs;
current_alignment = STRICT_ALIGNMENT;
current_target_byte_order = BFD_ENDIAN_BIG;