From ba9666525f68ab75a7176bd02b7e8d0dc8c644b7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 27 Jun 2021 01:26:30 -0400 Subject: [PATCH] sim: model: constify sim_machs storage The array of pointers is never modified, so mark it const so it ends up in the read-only data section. --- sim/bfin/ChangeLog | 4 ++++ sim/bfin/machs.c | 2 +- sim/bpf/ChangeLog | 4 ++++ sim/bpf/arch.c | 2 +- sim/common/ChangeLog | 9 +++++++++ sim/common/sim-model.c | 10 +++++----- sim/common/sim-model.h | 2 +- sim/cris/ChangeLog | 4 ++++ sim/cris/arch.c | 2 +- sim/frv/ChangeLog | 4 ++++ sim/frv/arch.c | 2 +- sim/iq2000/ChangeLog | 4 ++++ sim/iq2000/arch.c | 2 +- sim/lm32/ChangeLog | 4 ++++ sim/lm32/arch.c | 2 +- sim/m32r/ChangeLog | 4 ++++ sim/m32r/arch.c | 2 +- sim/or1k/ChangeLog | 4 ++++ sim/or1k/arch.c | 2 +- sim/riscv/ChangeLog | 4 ++++ sim/riscv/machs.c | 2 +- 21 files changed, 60 insertions(+), 15 deletions(-) diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index d84d44f8e81..a26a35a136c 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * machs.c (sim_machs): Mark const. + 2021-06-27 Mike Frysinger * Makefile.in: Change to $(SDL_CFLAGS) & $(SDL_LIBS). diff --git a/sim/bfin/machs.c b/sim/bfin/machs.c index e94af5d0f5b..ff49bb7c3bb 100644 --- a/sim/bfin/machs.c +++ b/sim/bfin/machs.c @@ -1962,7 +1962,7 @@ static const SIM_MACH bfin_mach = bfin_prepare_run }; -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { & bfin_mach, NULL diff --git a/sim/bpf/ChangeLog b/sim/bpf/ChangeLog index 046c450198d..2d847bb0278 100644 --- a/sim/bpf/ChangeLog +++ b/sim/bpf/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * Makefile.in (SIM_WERROR_CFLAGS): Delete. diff --git a/sim/bpf/arch.c b/sim/bpf/arch.c index cb3a206f1e8..8ceaa34cef8 100644 --- a/sim/bpf/arch.c +++ b/sim/bpf/arch.c @@ -25,7 +25,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_BPFBF & bpf_mach, diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 6926fd3438b..7b21b00c880 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,12 @@ +2021-06-29 Mike Frysinger + + * sim-model.c (model_option_handler): Make machp const. + (sim_model_lookup): Likewise. + (sim_mach_lookup): Likewise. + (sim_mach_lookup_bfd_name): Likewise. + (sim_machs): Add const. + * sim-model.h (sim_machs): Likewise. + 2021-06-29 Mike Frysinger * sim-io.h (sim_io_vprintf): Add ATTRIBUTE_PRINTF. diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c index e1af9d4b1e4..bfdb3c24bc8 100644 --- a/sim/common/sim-model.c +++ b/sim/common/sim-model.c @@ -74,7 +74,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, case OPTION_MODEL_INFO : { - const SIM_MACH **machp; + const SIM_MACH * const *machp; const SIM_MODEL *model; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -140,7 +140,7 @@ sim_model_set (SIM_DESC sd, sim_cpu *cpu, const SIM_MODEL *model) const SIM_MODEL * sim_model_lookup (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; const SIM_MODEL *model; for (machp = & sim_machs[0]; *machp != NULL; ++machp) @@ -160,7 +160,7 @@ sim_model_lookup (const char *name) const SIM_MACH * sim_mach_lookup (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -176,7 +176,7 @@ sim_mach_lookup (const char *name) const SIM_MACH * sim_mach_lookup_bfd_name (const char *name) { - const SIM_MACH **machp; + const SIM_MACH * const *machp; for (machp = & sim_machs[0]; *machp != NULL; ++machp) { @@ -251,7 +251,7 @@ sim_model_init (SIM_DESC sd) #if !WITH_MODEL_P /* Set up basic model support. This is a stub for ports that do not define models. See sim-model.h for more details. */ -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { NULL }; diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h index 3a028d5f32f..d6edf649d6e 100644 --- a/sim/common/sim-model.h +++ b/sim/common/sim-model.h @@ -140,7 +140,7 @@ typedef struct model { /* ??? In a simulator of multiple architectures, will need multiple copies of this. Have an `archs' array that contains a pointer to the machs array for each (which in turn has a pointer to the models array for each). */ -extern const SIM_MACH *sim_machs[]; +extern const SIM_MACH * const sim_machs[]; /* Model module handlers. */ extern MODULE_INSTALL_FN sim_model_install; diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index f369739af8b..8c36ffeae32 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpuv10.c (crisv10f_record_trace_results): Delete function. diff --git a/sim/cris/arch.c b/sim/cris/arch.c index 1395cc7472d..1635ef6a955 100644 --- a/sim/cris/arch.c +++ b/sim/cris/arch.c @@ -24,7 +24,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_CRISV10F & crisv10_mach, diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog index 36ea3ef6b54..78208fbf154 100644 --- a/sim/frv/ChangeLog +++ b/sim/frv/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpu.c (frvbf_record_trace_results): Delete function. diff --git a/sim/frv/arch.c b/sim/frv/arch.c index 80b620fae60..f58ed116816 100644 --- a/sim/frv/arch.c +++ b/sim/frv/arch.c @@ -24,7 +24,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_FRVBF & frv_mach, diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog index a8cea4d6995..cc5d594e0a9 100644 --- a/sim/iq2000/ChangeLog +++ b/sim/iq2000/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpu.c (iq2000bf_record_trace_results): Delete function. diff --git a/sim/iq2000/arch.c b/sim/iq2000/arch.c index 30ce2f5ca6c..22dc565b1bc 100644 --- a/sim/iq2000/arch.c +++ b/sim/iq2000/arch.c @@ -24,7 +24,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_IQ2000BF & iq2000_mach, diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index bc3c5fe8221..689eb6461af 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpu.c (lm32bf_record_trace_results): Delete function. diff --git a/sim/lm32/arch.c b/sim/lm32/arch.c index e8a826adc70..72fe4b43b87 100644 --- a/sim/lm32/arch.c +++ b/sim/lm32/arch.c @@ -24,7 +24,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_LM32BF & lm32_mach, diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog index 00b0a7a8c11..d8171c600ae 100644 --- a/sim/m32r/ChangeLog +++ b/sim/m32r/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpu.c (m32rbf_record_trace_results): Delete function. diff --git a/sim/m32r/arch.c b/sim/m32r/arch.c index eb4bc06baef..4b789759eb6 100644 --- a/sim/m32r/arch.c +++ b/sim/m32r/arch.c @@ -24,7 +24,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_M32RBF & m32r_mach, diff --git a/sim/or1k/ChangeLog b/sim/or1k/ChangeLog index eb14a13adc6..89a89aca725 100644 --- a/sim/or1k/ChangeLog +++ b/sim/or1k/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * arch.c (sim_machs): Mark const. + 2021-06-28 Mike Frysinger * cpu.c (or1k32bf_record_trace_results): Delete function. diff --git a/sim/or1k/arch.c b/sim/or1k/arch.c index 97a7a3806a6..ef3c403c943 100644 --- a/sim/or1k/arch.c +++ b/sim/or1k/arch.c @@ -25,7 +25,7 @@ This file is part of the GNU simulators. #include "sim-main.h" #include "bfd.h" -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #ifdef HAVE_CPU_OR1K32BF & or32_mach, diff --git a/sim/riscv/ChangeLog b/sim/riscv/ChangeLog index bcb630ae34c..69c0808ce32 100644 --- a/sim/riscv/ChangeLog +++ b/sim/riscv/ChangeLog @@ -1,3 +1,7 @@ +2021-06-29 Mike Frysinger + + * machs.c (sim_machs): Mark const. + 2021-06-22 Mike Frysinger * configure: Regenerate. diff --git a/sim/riscv/machs.c b/sim/riscv/machs.c index 9ff23033678..eb75a1dd200 100644 --- a/sim/riscv/machs.c +++ b/sim/riscv/machs.c @@ -111,7 +111,7 @@ static const SIM_MACH rv128i_mach = #endif /* Order matters here. */ -const SIM_MACH *sim_machs[] = +const SIM_MACH * const sim_machs[] = { #if WITH_TARGET_WORD_BITSIZE >= 128 &rv128i_mach, -- 2.30.2