From bd38246a45dc199ce32b50878670bbbdf7e27ad5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 17 Dec 2020 08:33:39 +1030 Subject: [PATCH] Constify more arrays bfd/ * coff-z80.c (bfd_howto_type): Make typedef const. * elf32-z80.c (bfd_howto_type): Likewise. * elf32-m32c.c (EncodingTable): Likewise. * elf32-csky.c (csky_arch_for_merge): Likewise. (csky_archs): Use typedef. * elf32-m68hc11.c (m68hc11_direct_relax_table): Make const. (find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit. * elf32-ppc.c (ppc_alt_plt): Make const. * elf32-rl78.c (relax_addr16): Likewise. * targets.c (_bfd_associated_vector): Likewise. (bfd_target_vector, bfd_associated_vector): Likewise. * libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise. * libbfd.h: Regenerate. include/ * opcode/arc-attrs.h (CONFLICT_LIST): Make const. --- bfd/ChangeLog | 16 ++++++++++++++++ bfd/coff-z80.c | 2 +- bfd/elf32-csky.c | 4 ++-- bfd/elf32-m32c.c | 2 +- bfd/elf32-m68hc11.c | 6 +++--- bfd/elf32-ppc.c | 2 +- bfd/elf32-rl78.c | 2 +- bfd/elf32-z80.c | 2 +- bfd/libbfd-in.h | 4 ++-- bfd/libbfd.h | 4 ++-- bfd/targets.c | 6 +++--- include/ChangeLog | 4 ++++ include/opcode/arc-attrs.h | 2 +- 13 files changed, 38 insertions(+), 18 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 40d96a86a7..c49faa318a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +2020-12-18 Alan Modra + + * coff-z80.c (bfd_howto_type): Make typedef const. + * elf32-z80.c (bfd_howto_type): Likewise. + * elf32-m32c.c (EncodingTable): Likewise. + * elf32-csky.c (csky_arch_for_merge): Likewise. + (csky_archs): Use typedef. + * elf32-m68hc11.c (m68hc11_direct_relax_table): Make const. + (find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit. + * elf32-ppc.c (ppc_alt_plt): Make const. + * elf32-rl78.c (relax_addr16): Likewise. + * targets.c (_bfd_associated_vector): Likewise. + (bfd_target_vector, bfd_associated_vector): Likewise. + * libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise. + * libbfd.h: Regenerate. + 2020-12-18 Alan Modra * ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION. diff --git a/bfd/coff-z80.c b/bfd/coff-z80.c index 16f83cfeef..ced9074b6c 100644 --- a/bfd/coff-z80.c +++ b/bfd/coff-z80.c @@ -30,7 +30,7 @@ #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 0 -typedef struct { +typedef const struct { bfd_reloc_code_real_type r_type; reloc_howto_type howto; } bfd_howto_type; diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c index 8d48a03aad..9ad78cfa00 100644 --- a/bfd/elf32-csky.c +++ b/bfd/elf32-csky.c @@ -40,7 +40,7 @@ enum merge_class CSKY_V2 }; -typedef struct csky_arch_for_merge +typedef const struct csky_arch_for_merge { const char *name; const unsigned long arch_eflag; @@ -53,7 +53,7 @@ typedef struct csky_arch_for_merge unsigned int do_warning; } csky_arch_for_merge; -static struct csky_arch_for_merge csky_archs[] = +static csky_arch_for_merge csky_archs[] = { /* 510 and 610 merge to 610 without warning. */ { "ck510", CSKY_ARCH_510, CSKY_V1, 0, 0}, diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index a0452d763b..6de8c4c76d 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -1347,7 +1347,7 @@ static int bytes_to_reloc[] = { /* If the displacement is within the given range and the new encoding differs from the old encoding (the index), then the insn can be relaxed to the new encoding. */ -typedef struct { +typedef const struct { int bytes; unsigned int max_disp; unsigned char new_encoding; diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index 7bbb48962d..7e6680807e 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -505,7 +505,7 @@ m68hc11_elf_bfd_link_hash_table_create (bfd *abfd) /* 68HC11 Linker Relaxation. */ -struct m68hc11_direct_relax +const struct m68hc11_direct_relax { const char *name; unsigned char code; @@ -548,7 +548,7 @@ struct m68hc11_direct_relax { 0, 0, 0 } }; -static struct m68hc11_direct_relax * +static const struct m68hc11_direct_relax * find_relaxable_insn (unsigned char code) { int i; @@ -962,7 +962,7 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec, { unsigned char code; unsigned short offset; - struct m68hc11_direct_relax *rinfo; + const struct m68hc11_direct_relax *rinfo; prev_insn_branch = 0; offset = bfd_get_16 (abfd, contents + irel->r_offset); diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 66265ef600..9d8fa66f90 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1491,7 +1491,7 @@ static const struct bfd_elf_special_section ppc_elf_special_sections[] = }; /* This is what we want for new plt/got. */ -static struct bfd_elf_special_section ppc_alt_plt = +static const struct bfd_elf_special_section ppc_alt_plt = { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC }; static const struct bfd_elf_special_section * diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 3929776287..dc0414e0a0 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -1982,7 +1982,7 @@ rl78_offset_for_reloc (bfd * abfd, } } -struct { +const struct { int prefix; /* or -1 for "no prefix" */ int insn; /* or -1 for "end of list" */ int insn_for_saddr; /* or -1 for "no alternative" */ diff --git a/bfd/elf32-z80.c b/bfd/elf32-z80.c index 89089f5eaa..b27f7afafc 100644 --- a/bfd/elf32-z80.c +++ b/bfd/elf32-z80.c @@ -30,7 +30,7 @@ /* All users of this file have bfd_octets_per_byte (abfd, sec) == 1. */ #define OCTETS_PER_BYTE(ABFD, SEC) 1 -typedef struct { +typedef const struct { bfd_reloc_code_real_type r_type; reloc_howto_type howto; } bfd_howto_type; diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 84dba221e1..f38304ad7d 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -825,11 +825,11 @@ extern FILE *_bfd_real_fopen /* List of supported target vectors, and the default vector (if bfd_default_vector[0] is NULL, there is no default). */ -extern const bfd_target * const *bfd_target_vector ATTRIBUTE_HIDDEN; +extern const bfd_target *const *const bfd_target_vector ATTRIBUTE_HIDDEN; extern const bfd_target *bfd_default_vector[] ATTRIBUTE_HIDDEN; /* List of associated target vectors. */ -extern const bfd_target * const *bfd_associated_vector ATTRIBUTE_HIDDEN; +extern const bfd_target *const *const bfd_associated_vector ATTRIBUTE_HIDDEN; /* Functions shared by the ECOFF and MIPS ELF backends, which have no other common header files. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 74d7e4111d..6384922b98 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -830,11 +830,11 @@ extern FILE *_bfd_real_fopen /* List of supported target vectors, and the default vector (if bfd_default_vector[0] is NULL, there is no default). */ -extern const bfd_target * const *bfd_target_vector ATTRIBUTE_HIDDEN; +extern const bfd_target *const *const bfd_target_vector ATTRIBUTE_HIDDEN; extern const bfd_target *bfd_default_vector[] ATTRIBUTE_HIDDEN; /* List of associated target vectors. */ -extern const bfd_target * const *bfd_associated_vector ATTRIBUTE_HIDDEN; +extern const bfd_target *const *const bfd_associated_vector ATTRIBUTE_HIDDEN; /* Functions shared by the ECOFF and MIPS ELF backends, which have no other common header files. */ diff --git a/bfd/targets.c b/bfd/targets.c index b18800928c..8ae5c489fc 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -1405,7 +1405,7 @@ static const bfd_target * const _bfd_target_vector[] = NULL /* end of list marker */ }; -const bfd_target * const *bfd_target_vector = _bfd_target_vector; +const bfd_target *const *const bfd_target_vector = _bfd_target_vector; /* bfd_default_vector[0] contains either the address of the default vector, if there is one, or zero if there isn't. */ @@ -1420,13 +1420,13 @@ const bfd_target *bfd_default_vector[] = { /* bfd_associated_vector[] contains the associated target vectors used to reduce the ambiguity in bfd_check_format_matches. */ -static const bfd_target *_bfd_associated_vector[] = { +static const bfd_target *const _bfd_associated_vector[] = { #ifdef ASSOCIATED_VECS ASSOCIATED_VECS, #endif NULL }; -const bfd_target * const *bfd_associated_vector = _bfd_associated_vector; +const bfd_target *const *const bfd_associated_vector = _bfd_associated_vector; /* When there is an ambiguous match, bfd_check_format_matches puts the names of the matching targets in an array. This variable is the maximum diff --git a/include/ChangeLog b/include/ChangeLog index 9c19b8765c..24f16888a4 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2020-12-18 Alan Modra + + * opcode/arc-attrs.h (CONFLICT_LIST): Make const. + 2020-12-16 Alan Modra * bfdlink.h (struct bfd_link_info): Add maxpagesize and diff --git a/include/opcode/arc-attrs.h b/include/opcode/arc-attrs.h index 5162db0111..c12470fd82 100644 --- a/include/opcode/arc-attrs.h +++ b/include/opcode/arc-attrs.h @@ -58,7 +58,7 @@ const struct feature_type #endif /* A table with conflicting features. */ -unsigned CONFLICT_LIST [] = { +const unsigned CONFLICT_LIST [] = { NPS400 | SPX, NPS400 | DPX, DPX | DPA, -- 2.34.1