From e0471c16c5ac8eddf49daf781248822f4a1ebc58 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 25 Feb 2016 16:55:21 +0000 Subject: Convert more variables to a constant form. * as.c (select_emulation_mode): Add const qualifiers. * as.h: Likewise. * config/bfin-defs.h: Likewise. * config/bfin-parse.y: Likewise. * config/rx-parse.y: Likewise. * config/tc-aarch64.c (struct aarch64_option_table): Likewise. (struct aarch64_cpu_option_table): Likewise. (struct aarch64_arch_option_table): Likewise. (struct aarch64_option_cpu_value_table): Likewise. (struct aarch64_long_option_table): Likewise. (struct aarch64_option_abi_value_table): Likewise. * config/tc-arm.c (struct reloc_entry): Likewise. (tc_gen_reloc): Likewise. (struct arm_option_table): Likewise. (struct arm_legacy_option_table): Likewise. (struct arm_cpu_option_table): Likewise. (struct arm_arch_option_table): Likewise. (struct arm_option_extension_value_table): Likewise. (struct arm_option_fpu_value_table): Likewise. (struct arm_option_value_table): Likewise. (struct arm_long_option_table): Likewise. * config/tc-avr.c (struct avr_opcodes_s): Likewise. (struct mcu_type_s): Likewise. (struct exp_mod_s): Likewise. (avr_operand): Likewise. (avr_operands): Likewise. * config/tc-d10v.c (md_begin): Likewise. * config/tc-dlx.c: Likewise. * config/tc-fr30.c (fr30_is_colon_insn): Likewise. * config/tc-ft32.c (parse_condition): Likewise. * config/tc-h8300.c (do_a_fix_imm): Likewise. * config/tc-hppa.c (pa_ip): Likewise. (hppa_regname_to_dw2regnum): Likewise. * config/tc-i370.c (i370_elf_suffix): Likewise. * config/tc-i960.c (struct tabentry): Likewise. * config/tc-m32r.c: Likewise. * config/tc-m68k.c: Likewise. * config/tc-m68k.h: Likewise. * config/tc-mcore.c (parse_psrmod): Likewise. * config/tc-metag.c (struct metag_core_option): Likewise. (struct metag_long_option): Likewise. * config/tc-microblaze.c: Likewise. * config/tc-mips.c (macro): Likewise. * config/tc-mn10200.c: Likewise. * config/tc-mn10300.c: Likewise. * config/tc-msp430.c (struct rcodes_s): Likewise. (struct hcodes_s): Likewise. (md_parse_option): Likewise. * config/tc-ns32k.c (struct ns32k_option): Likewise. (optlist): Likewise. * config/tc-ppc.c (ppc_elf_suffix): Likewise. (tc_ppc_regname_to_dw2regnum): Likewise. * config/tc-ppc.h: Likewise. * config/tc-rl78.c: Likewise. * config/tc-rx.c (struct cpu_type): Likewise. * config/tc-sh.c (sh_regname_to_dw2regnum): Likewise. * config/tc-sparc.c (struct priv_reg_entry): Likewise. (sparc_ip): Likewise. * config/tc-spu.c (insn_fmt_string): Likewise. * config/tc-tic54x.c (tic54x_set_default_include): Likewise. * config/tc-v850.c: Likewise. * config/tc-visium.c (struct visium_arch_option_table): Likewise. (struct visium_long_option_table): Likewise. * config/tc-xgate.c: Likewise. * config/tc-z8k.c: Likewise. * read.c (add_include_dir): Likewise. * read.h: Likewise. --- gas/ChangeLog | 70 ++++++++++++++++++++++++++++++++++++++++++++++ gas/as.c | 5 ++-- gas/as.h | 2 +- gas/config/bfin-defs.h | 2 +- gas/config/bfin-parse.y | 10 +++---- gas/config/rx-parse.y | 6 ++-- gas/config/tc-aarch64.c | 16 +++++------ gas/config/tc-arm.c | 30 ++++++++++---------- gas/config/tc-avr.c | 16 +++++------ gas/config/tc-d10v.c | 2 +- gas/config/tc-dlx.c | 4 +-- gas/config/tc-fr30.c | 4 +-- gas/config/tc-ft32.c | 2 +- gas/config/tc-h8300.c | 6 ++-- gas/config/tc-hppa.c | 10 +++---- gas/config/tc-i370.c | 4 +-- gas/config/tc-i960.c | 8 +++--- gas/config/tc-m32r.c | 2 +- gas/config/tc-m68k.c | 2 +- gas/config/tc-m68k.h | 2 +- gas/config/tc-mcore.c | 8 +++--- gas/config/tc-metag.c | 10 +++---- gas/config/tc-microblaze.c | 2 +- gas/config/tc-mips.c | 8 +++--- gas/config/tc-mn10200.c | 2 +- gas/config/tc-mn10300.c | 4 +-- gas/config/tc-msp430.c | 6 ++-- gas/config/tc-ns32k.c | 4 +-- gas/config/tc-ppc.c | 8 +++--- gas/config/tc-ppc.h | 2 +- gas/config/tc-rl78.c | 4 +-- gas/config/tc-rx.c | 4 +-- gas/config/tc-sh.c | 6 ++-- gas/config/tc-sparc.c | 26 ++++++++--------- gas/config/tc-spu.c | 2 +- gas/config/tc-tic54x.c | 2 +- gas/config/tc-v850.c | 2 +- gas/config/tc-visium.c | 8 +++--- gas/config/tc-xgate.c | 2 +- gas/config/tc-z8k.c | 12 ++++---- gas/read.c | 11 ++++---- gas/read.h | 4 +-- 42 files changed, 205 insertions(+), 135 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index e4b4deb0ad4..0e9222e65a7 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,73 @@ +2016-02-25 Trevor Saunders + + * as.c (select_emulation_mode): Add const qualifiers. + * as.h: Likewise. + * config/bfin-defs.h: Likewise. + * config/bfin-parse.y: Likewise. + * config/rx-parse.y: Likewise. + * config/tc-aarch64.c (struct aarch64_option_table): Likewise. + (struct aarch64_cpu_option_table): Likewise. + (struct aarch64_arch_option_table): Likewise. + (struct aarch64_option_cpu_value_table): Likewise. + (struct aarch64_long_option_table): Likewise. + (struct aarch64_option_abi_value_table): Likewise. + * config/tc-arm.c (struct reloc_entry): Likewise. + (tc_gen_reloc): Likewise. + (struct arm_option_table): Likewise. + (struct arm_legacy_option_table): Likewise. + (struct arm_cpu_option_table): Likewise. + (struct arm_arch_option_table): Likewise. + (struct arm_option_extension_value_table): Likewise. + (struct arm_option_fpu_value_table): Likewise. + (struct arm_option_value_table): Likewise. + (struct arm_long_option_table): Likewise. + * config/tc-avr.c (struct avr_opcodes_s): Likewise. + (struct mcu_type_s): Likewise. + (struct exp_mod_s): Likewise. + (avr_operand): Likewise. + (avr_operands): Likewise. + * config/tc-d10v.c (md_begin): Likewise. + * config/tc-dlx.c: Likewise. + * config/tc-fr30.c (fr30_is_colon_insn): Likewise. + * config/tc-ft32.c (parse_condition): Likewise. + * config/tc-h8300.c (do_a_fix_imm): Likewise. + * config/tc-hppa.c (pa_ip): Likewise. + (hppa_regname_to_dw2regnum): Likewise. + * config/tc-i370.c (i370_elf_suffix): Likewise. + * config/tc-i960.c (struct tabentry): Likewise. + * config/tc-m32r.c: Likewise. + * config/tc-m68k.c: Likewise. + * config/tc-m68k.h: Likewise. + * config/tc-mcore.c (parse_psrmod): Likewise. + * config/tc-metag.c (struct metag_core_option): Likewise. + (struct metag_long_option): Likewise. + * config/tc-microblaze.c: Likewise. + * config/tc-mips.c (macro): Likewise. + * config/tc-mn10200.c: Likewise. + * config/tc-mn10300.c: Likewise. + * config/tc-msp430.c (struct rcodes_s): Likewise. + (struct hcodes_s): Likewise. + (md_parse_option): Likewise. + * config/tc-ns32k.c (struct ns32k_option): Likewise. + (optlist): Likewise. + * config/tc-ppc.c (ppc_elf_suffix): Likewise. + (tc_ppc_regname_to_dw2regnum): Likewise. + * config/tc-ppc.h: Likewise. + * config/tc-rl78.c: Likewise. + * config/tc-rx.c (struct cpu_type): Likewise. + * config/tc-sh.c (sh_regname_to_dw2regnum): Likewise. + * config/tc-sparc.c (struct priv_reg_entry): Likewise. + (sparc_ip): Likewise. + * config/tc-spu.c (insn_fmt_string): Likewise. + * config/tc-tic54x.c (tic54x_set_default_include): Likewise. + * config/tc-v850.c: Likewise. + * config/tc-visium.c (struct visium_arch_option_table): Likewise. + (struct visium_long_option_table): Likewise. + * config/tc-xgate.c: Likewise. + * config/tc-z8k.c: Likewise. + * read.c (add_include_dir): Likewise. + * read.h: Likewise. + 2016-02-25 Andrew Burgess * testsuite/gas/all/gas.exp: Change target pattern to cover diff --git a/gas/as.c b/gas/as.c index 9bfac6100d3..55214f43904 100644 --- a/gas/as.c +++ b/gas/as.c @@ -142,7 +142,8 @@ static void select_emulation_mode (int argc, char **argv) { int i; - char *p, *em = 0; + char *p; + const char *em = NULL; for (i = 1; i < argc; i++) if (!strncmp ("--em", argv[i], 4)) @@ -275,7 +276,7 @@ Options:\n\ #ifdef USE_EMULATIONS { int i; - char *def_em; + const char *def_em; fprintf (stream, "\ --em=["); diff --git a/gas/as.h b/gas/as.h index 4ee3f1bf9bf..bf1206faed1 100644 --- a/gas/as.h +++ b/gas/as.h @@ -380,7 +380,7 @@ COMMON int flag_execstack; COMMON int flag_noexecstack; /* name of emitted object file */ -COMMON char *out_file_name; +COMMON const char *out_file_name; /* name of file defining extensions to the basic instruction set */ COMMON char *insttbl_file_name; diff --git a/gas/config/bfin-defs.h b/gas/config/bfin-defs.h index 5f05406db33..4c1d8b7bd2c 100644 --- a/gas/config/bfin-defs.h +++ b/gas/config/bfin-defs.h @@ -378,7 +378,7 @@ extern "C" { extern int debug_codeselection; -void error (char *format, ...); +void error (const char *format, ...); void warn (char *format, ...); int semantic_error (char *syntax); void semantic_error_2 (char *syntax); diff --git a/gas/config/bfin-parse.y b/gas/config/bfin-parse.y index bb478e6c1fa..be532808a86 100644 --- a/gas/config/bfin-parse.y +++ b/gas/config/bfin-parse.y @@ -158,16 +158,16 @@ extern INSTR_T insn; static Expr_Node *binary (Expr_Op_Type, Expr_Node *, Expr_Node *); static Expr_Node *unary (Expr_Op_Type, Expr_Node *); -static void notethat (char *, ...); +static void notethat (const char *, ...); char *current_inputline; extern char *yytext; -int yyerror (char *); +int yyerror (const char *); /* Used to set SRCx fields to all 1s as described in the PRM. */ static Register reg7 = {REG_R7, 0}; -void error (char *format, ...) +void error (const char *format, ...) { va_list ap; static char buffer[2000]; @@ -180,7 +180,7 @@ void error (char *format, ...) } int -yyerror (char *msg) +yyerror (const char *msg) { if (msg[0] == '\0') error ("%s", msg); @@ -4651,7 +4651,7 @@ unary (Expr_Op_Type op, Expr_Node *x) int debug_codeselection = 0; static void -notethat (char *format, ...) +notethat (const char *format, ...) { va_list ap; va_start (ap, format); diff --git a/gas/config/rx-parse.y b/gas/config/rx-parse.y index 7a7eb7043e1..3bd37d0cae7 100644 --- a/gas/config/rx-parse.y +++ b/gas/config/rx-parse.y @@ -1277,7 +1277,7 @@ token_table[] = static struct { - char * string; + const char * string; int token; } condition_opcode_table[] = @@ -1291,7 +1291,7 @@ condition_opcode_table[] = static struct { - char * string; + const char * string; int val; } condition_table[] = @@ -1333,7 +1333,7 @@ rx_lex_init (char * beginning, char * ending) } static int -check_condition (char * base) +check_condition (const char * base) { char * cp; unsigned int i; diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index b455dc8c803..b06c46ab38a 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -7715,8 +7715,8 @@ size_t md_longopts_size = sizeof (md_longopts); struct aarch64_option_table { - char *option; /* Option name to match. */ - char *help; /* Help information. */ + const char *option; /* Option name to match. */ + const char *help; /* Help information. */ int *var; /* Variable to change. */ int value; /* What to change it to. */ char *deprecated; /* If non-null, print this message. */ @@ -7738,7 +7738,7 @@ static struct aarch64_option_table aarch64_opts[] = { struct aarch64_cpu_option_table { - char *name; + const char *name; const aarch64_feature_set value; /* The canonical name of the CPU, or NULL to use NAME converted to upper case. */ @@ -7780,7 +7780,7 @@ static const struct aarch64_cpu_option_table aarch64_cpus[] = { struct aarch64_arch_option_table { - char *name; + const char *name; const aarch64_feature_set value; }; @@ -7797,7 +7797,7 @@ static const struct aarch64_arch_option_table aarch64_archs[] = { /* ISA extensions. */ struct aarch64_option_cpu_value_table { - char *name; + const char *name; const aarch64_feature_set value; }; @@ -7819,8 +7819,8 @@ static const struct aarch64_option_cpu_value_table aarch64_features[] = { struct aarch64_long_option_table { - char *option; /* Substring to match. */ - char *help; /* Help information. */ + const char *option; /* Substring to match. */ + const char *help; /* Help information. */ int (*func) (char *subopt); /* Function to decode sub-option. */ char *deprecated; /* If non-null, print this message. */ }; @@ -7979,7 +7979,7 @@ aarch64_parse_arch (char *str) /* ABIs. */ struct aarch64_option_abi_value_table { - char *name; + const char *name; enum aarch64_abi_type value; }; diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 6cc7edccfcd..5d3bae4ace3 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -516,7 +516,7 @@ struct asm_barrier_opt struct reloc_entry { - char * name; + const char * name; bfd_reloc_code_real_type reloc; }; @@ -24095,7 +24095,7 @@ tc_gen_reloc (asection *section, fixS *fixp) default: { - char * type; + const char * type; switch (fixp->fx_r_type) { @@ -24906,11 +24906,11 @@ size_t md_longopts_size = sizeof (md_longopts); struct arm_option_table { - char *option; /* Option name to match. */ - char *help; /* Help information. */ + const char *option; /* Option name to match. */ + const char *help; /* Help information. */ int *var; /* Variable to change. */ int value; /* What to change it to. */ - char *deprecated; /* If non-null, print this message. */ + const char *deprecated; /* If non-null, print this message. */ }; struct arm_option_table arm_opts[] = @@ -24943,10 +24943,10 @@ struct arm_option_table arm_opts[] = struct arm_legacy_option_table { - char *option; /* Option name to match. */ + const char *option; /* Option name to match. */ const arm_feature_set **var; /* Variable to change. */ const arm_feature_set value; /* What to change it to. */ - char *deprecated; /* If non-null, print this message. */ + const char *deprecated; /* If non-null, print this message. */ }; const struct arm_legacy_option_table arm_legacy_opts[] = @@ -25064,7 +25064,7 @@ const struct arm_legacy_option_table arm_legacy_opts[] = struct arm_cpu_option_table { - char *name; + const char *name; size_t name_len; const arm_feature_set value; /* For some CPUs we assume an FPU unless the user explicitly sets @@ -25245,7 +25245,7 @@ static const struct arm_cpu_option_table arm_cpus[] = struct arm_arch_option_table { - char *name; + const char *name; size_t name_len; const arm_feature_set value; const arm_feature_set default_fpu; @@ -25316,7 +25316,7 @@ static const struct arm_arch_option_table arm_archs[] = /* ISA extensions in the co-processor and main instruction set space. */ struct arm_option_extension_value_table { - char *name; + const char *name; size_t name_len; const arm_feature_set merge_value; const arm_feature_set clear_value; @@ -25378,7 +25378,7 @@ static const struct arm_option_extension_value_table arm_extensions[] = /* ISA floating-point and Advanced SIMD extensions. */ struct arm_option_fpu_value_table { - char *name; + const char *name; const arm_feature_set value; }; @@ -25434,7 +25434,7 @@ static const struct arm_option_fpu_value_table arm_fpus[] = struct arm_option_value_table { - char *name; + const char *name; long value; }; @@ -25459,10 +25459,10 @@ static const struct arm_option_value_table arm_eabis[] = struct arm_long_option_table { - char * option; /* Substring to match. */ - char * help; /* Help information. */ + const char * option; /* Substring to match. */ + const char * help; /* Help information. */ int (* func) (char * subopt); /* Function to decode sub-option. */ - char * deprecated; /* If non-null, print this message. */ + const char * deprecated; /* If non-null, print this message. */ }; static bfd_boolean diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c index 767e82ceb84..69881b70e74 100644 --- a/gas/config/tc-avr.c +++ b/gas/config/tc-avr.c @@ -37,9 +37,9 @@ struct avr_property_record_link struct avr_opcodes_s { - char * name; - char * constraints; - char * opcode; + const char * name; + const char * constraints; + const char * opcode; int insn_size; /* In words. */ int isa; unsigned int bin_opcode; @@ -61,7 +61,7 @@ const char line_separator_chars[] = "$"; const char *md_shortopts = "m:"; struct mcu_type_s { - char *name; + const char *name; int isa; int mach; }; @@ -380,7 +380,7 @@ const pseudo_typeS md_pseudo_table[] = struct exp_mod_s { - char * name; + const char * name; bfd_reloc_code_real_type reloc; bfd_reloc_code_real_type neg_reloc; int have_pm; @@ -860,7 +860,7 @@ avr_ldi_expression (expressionS *exp) static unsigned int avr_operand (struct avr_opcodes_s *opcode, int where, - char *op, + const char *op, char **line) { expressionS op_expr; @@ -998,7 +998,7 @@ avr_operand (struct avr_opcodes_s *opcode, if (*str == '+') { ++str; - char *s; + const char *s; for (s = opcode->opcode; *s; ++s) { if (*s == '+') @@ -1145,7 +1145,7 @@ avr_operand (struct avr_opcodes_s *opcode, static unsigned int avr_operands (struct avr_opcodes_s *opcode, char **line) { - char *op = opcode->constraints; + const char *op = opcode->constraints; unsigned int bin = opcode->bin_opcode; char *frag = frag_more (opcode->insn_size * 2); char *str = *line; diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c index fca7b6b1454..f2855fcd1e4 100644 --- a/gas/config/tc-d10v.c +++ b/gas/config/tc-d10v.c @@ -275,7 +275,7 @@ md_section_align (asection *seg, valueT addr) void md_begin (void) { - char *prev_name = ""; + const char *prev_name = ""; struct d10v_opcode *opcode; d10v_hash = hash_new (); diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c index 3efd36fec8f..39b19038bc0 100644 --- a/gas/config/tc-dlx.c +++ b/gas/config/tc-dlx.c @@ -84,7 +84,7 @@ const char EXP_CHARS[] = "eE"; const char FLT_CHARS[] = "rRsSfFdDxXpP"; static void -insert_sreg (char *regname, int regnum) +insert_sreg (const char *regname, int regnum) { /* Must be large enough to hold the names of the special registers. */ char buf[80]; @@ -153,7 +153,7 @@ match_sft_register (char *name) #define MAX_REG_NO 35 /* Currently we have 35 software registers defined - we borrowed from MIPS. */ - static char *soft_reg[] = + static const char *soft_reg[] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", diff --git a/gas/config/tc-fr30.c b/gas/config/tc-fr30.c index 83714aab0da..683da32f7ce 100644 --- a/gas/config/tc-fr30.c +++ b/gas/config/tc-fr30.c @@ -363,7 +363,7 @@ fr30_is_colon_insn (char *start, char *nul_char) { /* Yup - it might be delay slot instruction. */ int i; - static char * delay_insns [] = + static const char * delay_insns [] = { "call", "jmp", "ret", "bra", "bno", "beq", "bne", "bc", "bnc", "bn", @@ -373,7 +373,7 @@ fr30_is_colon_insn (char *start, char *nul_char) for (i = sizeof (delay_insns) / sizeof (delay_insns[0]); i--;) { - char * insn = delay_insns[i]; + const char * insn = delay_insns[i]; int len = strlen (insn); if (start [len] != 0) diff --git a/gas/config/tc-ft32.c b/gas/config/tc-ft32.c index 85722b3a5fa..88ea4f7dfbe 100644 --- a/gas/config/tc-ft32.c +++ b/gas/config/tc-ft32.c @@ -79,7 +79,7 @@ parse_condition (char **ptr) { char *s = *ptr; static const struct { - char *name; + const char *name; int bits; } ccs[] = { { "gt," , (2 << FT32_FLD_CR_BIT) | (5 << FT32_FLD_CB_BIT) | (1 << FT32_FLD_CV_BIT)}, diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c index 063c40dcfb2..5e6695f9f6b 100644 --- a/gas/config/tc-h8300.c +++ b/gas/config/tc-h8300.c @@ -355,7 +355,7 @@ static void clever_message (const struct h8_instruction *, struct h8_op *); static void fix_operand_size (struct h8_op *, int); static void build_bytes (const struct h8_instruction *, struct h8_op *); static void do_a_fix_imm (int, int, struct h8_op *, int, const struct h8_instruction *); -static void check_operand (struct h8_op *, unsigned int, char *); +static void check_operand (struct h8_op *, unsigned int, const char *); static const struct h8_instruction * get_specific (const struct h8_instruction *, struct h8_op *, int) ; static char *get_operands (unsigned, char *, struct h8_op *); static void get_operand (char **, struct h8_op *, int); @@ -1286,7 +1286,7 @@ get_specific (const struct h8_instruction *instruction, } static void -check_operand (struct h8_op *operand, unsigned int width, char *string) +check_operand (struct h8_op *operand, unsigned int width, const char *string) { if (operand->exp.X_add_symbol == 0 && operand->exp.X_op_symbol == 0) @@ -1340,7 +1340,7 @@ do_a_fix_imm (int offset, int nibble, struct h8_op *operand, int relaxmode, cons int where; char *bytes = frag_now->fr_literal + offset; - char *t = ((operand->mode & MODE) == IMM) ? "#" : "@"; + const char *t = ((operand->mode & MODE) == IMM) ? "#" : "@"; if (operand->exp.X_add_symbol == 0) { diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index 765398ed2e8..c3e1d75c56b 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -465,7 +465,7 @@ struct hppa_fix_struct struct pd_reg { - char *name; + const char *name; int value; }; @@ -473,7 +473,7 @@ struct pd_reg to a condition number which can be recorded in an instruction. */ struct fp_cond_map { - char *string; + const char *string; int cond; }; @@ -481,7 +481,7 @@ struct fp_cond_map string to a field selector type. */ struct selector_entry { - char *prefix; + const char *prefix; int field_selector; }; @@ -3167,7 +3167,7 @@ pa_parse_addb_64_cmpltr (char **s) static void pa_ip (char *str) { - char *error_message = ""; + const char *error_message = ""; char *s, c, *argstart, *name, *save_s; const char *args; int match = FALSE; @@ -8694,7 +8694,7 @@ hppa_regname_to_dw2regnum (char *regname) unsigned int i; const char *p; char *q; - static struct { char *name; int dw2regnum; } regnames[] = + static struct { const char *name; int dw2regnum; } regnames[] = { { "sp", 30 }, { "rp", 2 }, }; diff --git a/gas/config/tc-i370.c b/gas/config/tc-i370.c index 47955601ca7..bfcc0b3b4dc 100644 --- a/gas/config/tc-i370.c +++ b/gas/config/tc-i370.c @@ -102,7 +102,7 @@ static bfd_boolean reg_names_p = TARGET_REG_NAMES_P; /* Structure to hold information about predefined registers. */ struct pd_reg { - char *name; + const char *name; int value; }; @@ -582,7 +582,7 @@ i370_elf_suffix (char **str_p, expressionS *exp_p) { struct map_bfd { - char *string; + const char *string; int length; bfd_reloc_code_real_type reloc; }; diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index b927965bc95..d09e3cfbc53 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -240,7 +240,7 @@ struct regop operands. */ static const struct { - char *reg_name; + const char *reg_name; int reg_num; } regnames[] = @@ -335,7 +335,7 @@ regnames[] = 'abase' (indirect addressing) registers. */ static const struct { - char *areg_name; + const char *areg_name; int areg_num; } aregs[] = @@ -559,7 +559,7 @@ emit (long instr) /* Word to be output, host byte order. */ static void get_cdisp (char *dispP, /* Displacement as specified in source instruction. */ - char *ifmtP, /* "COBR" or "CTRL" (for use in error message). */ + const char *ifmtP, /* "COBR" or "CTRL" (for use in error message). */ long instr, /* Instruction needing the displacement. */ int numbits, /* # bits of displacement (13 for COBR, 24 for CTRL). */ int var_frag,/* 1 if varying length code fragment should be emitted; @@ -1809,7 +1809,7 @@ size_t md_longopts_size = sizeof (md_longopts); struct tabentry { - char *flag; + const char *flag; int arch; }; static const struct tabentry arch_tab[] = diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c index 833cbffbd40..18553bb7a9d 100644 --- a/gas/config/tc-m32r.c +++ b/gas/config/tc-m32r.c @@ -2300,7 +2300,7 @@ printf(" => %s\n",reloc->howto->name); } inline static char * -m32r_end_of_match (char *cont, char *what) +m32r_end_of_match (char *cont, const char *what) { int len = strlen (what); diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index 7ef5ff41234..bd6eac623db 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -8098,7 +8098,7 @@ m68k_elf_cons (int nbytes /* 4=.long */) #endif int -tc_m68k_regname_to_dw2regnum (char *regname) +tc_m68k_regname_to_dw2regnum (const char *regname) { unsigned int regnum; static const char *const regnames[] = diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h index f5a75952108..30ca2cb35e0 100644 --- a/gas/config/tc-m68k.h +++ b/gas/config/tc-m68k.h @@ -172,7 +172,7 @@ extern struct relax_type md_relax_table[]; #define DWARF2_CIE_DATA_ALIGNMENT (-4) #define tc_regname_to_dw2regnum tc_m68k_regname_to_dw2regnum -extern int tc_m68k_regname_to_dw2regnum (char *regname); +extern int tc_m68k_regname_to_dw2regnum (const char *regname); #define tc_cfi_frame_initial_instructions tc_m68k_frame_initial_instructions extern void tc_m68k_frame_initial_instructions (void); diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c index f73f3b71f36..6e573164905 100644 --- a/gas/config/tc-mcore.c +++ b/gas/config/tc-mcore.c @@ -141,7 +141,7 @@ static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */ #define POOL_START_LABEL ".LS" static void -make_name (char * s, char * p, int n) +make_name (char * s, const char * p, int n) { static const char hex[] = "0123456789ABCDEF"; @@ -455,7 +455,7 @@ void md_begin (void) { const mcore_opcode_info * opcode; - char * prev_name = ""; + const char * prev_name = ""; opcode_hash_control = hash_new (); @@ -523,7 +523,7 @@ parse_reg (char * s, unsigned * reg) static struct Cregs { - char * name; + const char * name; unsigned int crnum; } cregs[] = @@ -611,7 +611,7 @@ parse_psrmod (char * s, unsigned * reg) char buf[10]; static struct psrmods { - char * name; + const char * name; unsigned int value; } psrmods[] = diff --git a/gas/config/tc-metag.c b/gas/config/tc-metag.c index ff4d2cf7f67..b0b26042184 100644 --- a/gas/config/tc-metag.c +++ b/gas/config/tc-metag.c @@ -5791,7 +5791,7 @@ static const insn_parser insn_parsers[ENC_MAX] = struct metag_core_option { - char *name; + const char *name; unsigned int value; }; @@ -5899,10 +5899,10 @@ metag_parse_dsp (char * str) struct metag_long_option { - char * option; /* Substring to match. */ - char * help; /* Help information. */ + const char * option; /* Substring to match. */ + const char * help; /* Help information. */ int (* func) (char * subopt); /* Function to decode sub-option. */ - char * deprecated; /* If non-null, print this message. */ + const char * deprecated; /* If non-null, print this message. */ }; struct metag_long_option metag_long_opts[] = @@ -6879,7 +6879,7 @@ metag_handle_align (fragS * fragP) } static char * -metag_end_of_match (char * cont, char * what) +metag_end_of_match (char * cont, const char * what) { int len = strlen (what); diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c index 16c70ad1d60..70ceb213290 100644 --- a/gas/config/tc-microblaze.c +++ b/gas/config/tc-microblaze.c @@ -621,7 +621,7 @@ parse_exp (char *s, expressionS *e) #define IMM_MAX 9 struct imm_type { - char *isuffix; /* Suffix String */ + const char *isuffix; /* Suffix String */ int itype; /* Suffix Type */ int otype; /* Offset Type */ }; diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 862454df751..4657ce25012 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -12693,8 +12693,8 @@ macro (struct mips_cl_insn *ip, char *str) case M_DROL_I: { unsigned int rot; - char *l; - char *rr; + const char *l; + const char *rr; rot = imm_expr.X_add_number & 0x3f; if (ISA_HAS_DROR (mips_opts.isa) || CPU_HAS_DROR (mips_opts.arch)) @@ -12773,8 +12773,8 @@ macro (struct mips_cl_insn *ip, char *str) case M_DROR_I: { unsigned int rot; - char *l; - char *rr; + const char *l; + const char *rr; rot = imm_expr.X_add_number & 0x3f; if (ISA_HAS_DROR (mips_opts.isa) || CPU_HAS_DROR (mips_opts.arch)) diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c index d6b4006be16..a7fd980aeed 100644 --- a/gas/config/tc-mn10200.c +++ b/gas/config/tc-mn10200.c @@ -682,7 +682,7 @@ md_section_align (asection *seg, valueT addr) void md_begin (void) { - char *prev_name = ""; + const char *prev_name = ""; const struct mn10200_opcode *op; mn10200_hash = hash_new (); diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index 736960259dd..63d790ad882 100644 --- a/gas/config/tc-mn10300.c +++ b/gas/config/tc-mn10300.c @@ -911,7 +911,7 @@ md_section_align (asection *seg, valueT addr) void md_begin (void) { - char *prev_name = ""; + const char *prev_name = ""; const struct mn10300_opcode *op; mn10300_hash = hash_new (); @@ -2443,7 +2443,7 @@ set_arch_mach (int mach) } static inline char * -mn10300_end_of_match (char *cont, char *what) +mn10300_end_of_match (char *cont, const char *what) { int len = strlen (what); diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c index bf6594446a1..4004b44dc31 100644 --- a/gas/config/tc-msp430.c +++ b/gas/config/tc-msp430.c @@ -105,7 +105,7 @@ int linkrelax = 1; struct rcodes_s { - char * name; + const char * name; int index; /* Corresponding insn_opnumb. */ int sop; /* Opcode if jump length is short. */ long lpos; /* Label position. */ @@ -160,7 +160,7 @@ static struct rcodes_s msp430x_rcodes[] = struct hcodes_s { - char * name; + const char * name; int index; /* Corresponding insn_opnumb. */ int tlab; /* Number of labels in short mode. */ int op0; /* Opcode for first word of short jump. */ @@ -1339,7 +1339,7 @@ md_parse_option (int c, char * arg) signed int i; const struct { - char * name; + const char * name; unsigned int length; unsigned int bitfield; } erratas[] = diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c index 6fdca2b9b30..2b88bf4462c 100644 --- a/gas/config/tc-ns32k.c +++ b/gas/config/tc-ns32k.c @@ -102,7 +102,7 @@ const char FLT_CHARS[] = "fd"; /* We don't want to support lowercase, /* Internal structs. */ struct ns32k_option { - char *pattern; + const char *pattern; unsigned long or; unsigned long and; }; @@ -803,7 +803,7 @@ optlist (char *str, /* The string to extract options from. */ unsigned long *default_map) /* Default pattern and output. */ { int i, j, k, strlen1, strlen2; - char *patternP, *strP; + const char *patternP, *strP; strlen1 = strlen (str); diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 71b2dac9060..02cbb9514ec 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -302,7 +302,7 @@ const pseudo_typeS md_pseudo_table[] = /* Structure to hold information about predefined registers. */ struct pd_reg { - char *name; + const char *name; int value; }; @@ -1402,7 +1402,7 @@ ppc_mach (void) return bfd_mach_ppc; } -extern char* +extern const char* ppc_target_format (void) { #ifdef OBJ_COFF @@ -1864,7 +1864,7 @@ static bfd_reloc_code_real_type ppc_elf_suffix (char **str_p, expressionS *exp_p) { struct map_bfd { - char *string; + const char *string; unsigned int length : 8; unsigned int valid32 : 1; unsigned int valid64 : 1; @@ -7171,7 +7171,7 @@ tc_ppc_regname_to_dw2regnum (char *regname) unsigned int i; const char *p; char *q; - static struct { char *name; int dw2regnum; } regnames[] = + static struct { const char *name; int dw2regnum; } regnames[] = { { "sp", 1 }, { "r.sp", 1 }, { "rtoc", 2 }, { "r.toc", 2 }, { "mq", 64 }, { "lr", 65 }, { "ctr", 66 }, { "ap", 67 }, diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index 92120f9b919..e64107ef28b 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -51,7 +51,7 @@ extern int target_big_endian; /* The target BFD format. */ #define TARGET_FORMAT (ppc_target_format ()) -extern char *ppc_target_format (void); +extern const char *ppc_target_format (void); /* Permit temporary numeric labels. */ #define LOCAL_LABELS_FB 1 diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c index 1c7c9cf5617..bd0503987e0 100644 --- a/gas/config/tc-rl78.c +++ b/gas/config/tc-rl78.c @@ -436,7 +436,7 @@ md_number_to_chars (char * buf, valueT val, int n) } static void -require_end_of_expr (char *fname) +require_end_of_expr (const char *fname) { while (* input_line_pointer == ' ' || * input_line_pointer == '\t') @@ -454,7 +454,7 @@ require_end_of_expr (char *fname) static struct { - char * fname; + const char * fname; int reloc; } reloc_functions[] = diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c index 91d4828a17d..b74ee7212f7 100644 --- a/gas/config/tc-rx.c +++ b/gas/config/tc-rx.c @@ -108,7 +108,7 @@ size_t md_longopts_size = sizeof (md_longopts); struct cpu_type { - char *cpu_name; + const char *cpu_name; int type; }; @@ -1223,7 +1223,7 @@ md_number_to_chars (char * buf, valueT val, int n) static struct { - char * fname; + const char * fname; int reloc; } reloc_functions[] = diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 6d25907c759..9da94a85b5f 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -950,7 +950,7 @@ void md_begin (void) { const sh_opcode_info *opcode; - char *prev_name = ""; + const char *prev_name = ""; unsigned int target_arch; target_arch @@ -4490,7 +4490,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) #ifdef OBJ_ELF inline static char * -sh_end_of_match (char *cont, char *what) +sh_end_of_match (char *cont, const char *what) { int len = strlen (what); @@ -4603,7 +4603,7 @@ sh_regname_to_dw2regnum (char *regname) unsigned int i; const char *p; char *q; - static struct { char *name; int dw2regnum; } regnames[] = + static struct { const char *name; int dw2regnum; } regnames[] = { { "pr", 17 }, { "t", 18 }, { "gbr", 19 }, { "mach", 20 }, { "macl", 21 }, { "fpul", 23 } diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index bfa9aacabac..cac5d18bd6f 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -47,7 +47,7 @@ static int get_expression (char *); #ifndef DEFAULT_ARCH #define DEFAULT_ARCH "sparclite" #endif -static char *default_arch = DEFAULT_ARCH; +static const char *default_arch = DEFAULT_ARCH; /* Non-zero if the initial values of `max_architecture' and `sparc_arch_size' have been set. */ @@ -241,8 +241,8 @@ enum sparc_arch_types {v6, v7, v8, leon, sparclet, sparclite, sparc86x, v8plus, | HWCAP2_XMPMUL | HWCAP2_XMONT static struct sparc_arch { - char *name; - char *opcode_arch; + const char *name; + const char *opcode_arch; enum sparc_arch_types arch_type; /* Default word size, as specified during configuration. A value of zero means can't be used to specify default architecture. */ @@ -300,7 +300,7 @@ static struct sparc_arch { static enum sparc_arch_types default_arch_type; static struct sparc_arch * -lookup_arch (char *name) +lookup_arch (const char *name) { struct sparc_arch *sa; @@ -760,9 +760,9 @@ md_show_usage (FILE *stream) /* Native operand size opcode translation. */ struct { - char *name; - char *name32; - char *name64; + const char *name; + const char *name32; + const char *name64; } native_op_table[] = { {"ldn", "ld", "ldx"}, @@ -782,7 +782,7 @@ struct struct priv_reg_entry { - char *name; + const char *name; int regnum; }; @@ -904,7 +904,7 @@ md_begin (void) for (i = 0; native_op_table[i].name; i++) { const struct sparc_opcode *insn; - char *name = ((sparc_arch_size == 32) + const char *name = ((sparc_arch_size == 32) ? native_op_table[i].name32 : native_op_table[i].name64); insn = (struct sparc_opcode *) hash_find (op_hash, name); @@ -1547,7 +1547,7 @@ get_hwcap_name (bfd_uint64_t mask) static int sparc_ip (char *str, const struct sparc_opcode **pinsn) { - char *error_message = ""; + const char *error_message = ""; char *s; const char *args; char c; @@ -2065,7 +2065,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn) static const struct ops { /* The name as it appears in assembler. */ - char *name; + const char *name; /* strlen (name), precomputed for speed */ int len; /* The reloc this pseudo-op translates to. */ @@ -2518,7 +2518,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn) { char *s1; - char *op_arg = NULL; + const char *op_arg = NULL; static expressionS op_exp; bfd_reloc_code_real_type old_reloc = the_insn.reloc; @@ -2527,7 +2527,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn) { static const struct ops { /* The name as it appears in assembler. */ - char *name; + const char *name; /* strlen (name), precomputed for speed */ int len; /* The reloc this pseudo-op translates to. */ diff --git a/gas/config/tc-spu.c b/gas/config/tc-spu.c index 205df4667c4..69264c11ae8 100644 --- a/gas/config/tc-spu.c +++ b/gas/config/tc-spu.c @@ -245,7 +245,7 @@ insn_fmt_string (struct spu_opcode *format) for (i = 1; i <= format->arg[0]; i++) { int arg = format->arg[i]; - char *exp; + const char *exp; if (i > 1 && arg != A_P && format->arg[i-1] != A_P) buf[len++] = ','; if (arg == A_P) diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c index 3ed7933b560..e071f956640 100644 --- a/gas/config/tc-tic54x.c +++ b/gas/config/tc-tic54x.c @@ -1891,7 +1891,7 @@ tic54x_set_default_include (int dot) len = strlen (dir); if (include_dir_count == 0) { - include_dirs = (char **) xmalloc (sizeof (*include_dirs)); + include_dirs = XNEWVEC (const char *, 1); include_dir_count = 1; } include_dirs[0] = dir; diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c index 53c9077361b..00ff00d3713 100644 --- a/gas/config/tc-v850.c +++ b/gas/config/tc-v850.c @@ -1885,7 +1885,7 @@ md_section_align (asection *seg, valueT addr) void md_begin (void) { - char *prev_name = ""; + const char *prev_name = ""; const struct v850_opcode *op; if (strncmp (TARGET_CPU, "v850e3v5", 8) == 0) diff --git a/gas/config/tc-visium.c b/gas/config/tc-visium.c index c81a7fabe0b..3758a35061a 100644 --- a/gas/config/tc-visium.c +++ b/gas/config/tc-visium.c @@ -265,7 +265,7 @@ static struct visium_option_table visium_opts[] = struct visium_arch_option_table { - char *name; + const char *name; enum visium_arch_val value; }; @@ -280,10 +280,10 @@ static struct visium_arch_option_table visium_archs[] = struct visium_long_option_table { - char *option; /* Substring to match. */ - char *help; /* Help information. */ + const char *option; /* Substring to match. */ + const char *help; /* Help information. */ int (*func) (char *subopt); /* Function to decode sub-option. */ - char *deprecated; /* If non-null, print this message. */ + const char *deprecated; /* If non-null, print this message. */ }; static int diff --git a/gas/config/tc-xgate.c b/gas/config/tc-xgate.c index cafca95eda4..70554fe028b 100644 --- a/gas/config/tc-xgate.c +++ b/gas/config/tc-xgate.c @@ -291,7 +291,7 @@ md_begin (void) struct xgate_opcode *xgate_opcode_ptr = NULL; struct xgate_opcode *xgate_op_table = NULL; struct xgate_opcode_handle *op_handles = 0; - char *prev_op_name = 0; + const char *prev_op_name = 0; int handle_enum = 0; int number_of_op_handles = 0; int i, j = 0; diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c index e8d04bf43b1..c09d8260098 100644 --- a/gas/config/tc-z8k.c +++ b/gas/config/tc-z8k.c @@ -380,7 +380,7 @@ checkfor (char *ptr, char what) /* Make sure the mode supplied is the size of a word. */ static void -regword (int mode, char *string) +regword (int mode, const char *string) { int ok; @@ -394,7 +394,7 @@ regword (int mode, char *string) /* Make sure the mode supplied is the size of an address. */ static void -regaddr (int mode, char *string) +regaddr (int mode, const char *string) { int ok; @@ -407,7 +407,7 @@ regaddr (int mode, char *string) struct ctrl_names { int value; - char *name; + const char *name; }; static struct ctrl_names ctrl_table[] = { @@ -450,7 +450,7 @@ get_ctrl_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UN struct flag_names { int value; - char *name; + const char *name; }; static struct flag_names flag_table[] = { @@ -500,7 +500,7 @@ get_flags_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_U struct interrupt_names { int value; - char *name; + const char *name; }; static struct interrupt_names intr_table[] = { @@ -564,7 +564,7 @@ get_interrupt_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBU struct cc_names { int value; - char *name; + const char *name; }; static struct cc_names table[] = { diff --git a/gas/read.c b/gas/read.c index e992534bce7..f308cdcd5a7 100644 --- a/gas/read.c +++ b/gas/read.c @@ -166,7 +166,7 @@ int target_big_endian = TARGET_BYTES_BIG_ENDIAN; /* Variables for handling include file directory table. */ /* Table of pointers to directories to search for .include's. */ -char **include_dirs; +const char **include_dirs; /* How many are in the table. */ int include_dir_count; @@ -809,7 +809,7 @@ do_align (unsigned int n, char *fill, unsigned int len, unsigned int max) /* We read the file, putting things into a web that represents what we have been reading. */ void -read_a_source_file (char *name) +read_a_source_file (const char *name) { char nul_char; char next_char; @@ -5972,16 +5972,15 @@ add_include_dir (char *path) if (include_dir_count == 0) { - include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs)); + include_dirs = XNEWVEC (const char *, 2); include_dirs[0] = "."; /* Current dir. */ include_dir_count = 2; } else { include_dir_count++; - include_dirs = - (char **) xrealloc (include_dirs, - include_dir_count * sizeof (*include_dirs)); + include_dirs = XRESIZEVEC (const char *, include_dirs, + include_dir_count); } include_dirs[include_dir_count - 1] = path; /* New one. */ diff --git a/gas/read.h b/gas/read.h index 146dc3657c7..0787eab5e9b 100644 --- a/gas/read.h +++ b/gas/read.h @@ -74,7 +74,7 @@ extern const char line_comment_chars[]; extern const char line_separator_chars[]; /* Table of -I directories. */ -extern char **include_dirs; +extern const char **include_dirs; extern int include_dir_count; extern int include_dir_maxlen; @@ -134,7 +134,7 @@ extern void ignore_rest_of_line (void); #define discard_rest_of_line ignore_rest_of_line extern unsigned output_leb128 (char *, valueT, int); extern void pseudo_set (symbolS * symbolP); -extern void read_a_source_file (char *name); +extern void read_a_source_file (const char *name); extern void read_begin (void); extern void read_print_statistics (FILE *); extern char *read_symbol_name (void); -- cgit v1.2.1