From 2a78304e29bf783142001958730d4adf8f6a1f09 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 17 Jan 2022 10:25:08 +0100 Subject: [PATCH] x86: constify disassembler static data Now that the code is intended to be largely thread-safe, we'd better not have any writable static objects. --- opcodes/i386-dis.c | 116 ++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index ddb4b72325b..bee7b372f03 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -219,22 +219,22 @@ struct instr_info vex; unsigned char need_vex; - const char **names64; - const char **names32; - const char **names16; - const char **names8; - const char **names8rex; - const char **names_seg; + const char *const *names64; + const char *const *names32; + const char *const *names16; + const char *const *names8; + const char *const *names8rex; + const char *const *names_seg; const char *index64; const char *index32; - const char **index16; - const char **names_bnd; - const char **names_mm; - const char **names_xmm; - const char **names_ymm; - const char **names_zmm; - const char **names_tmm; - const char **names_mask; + const char *const *index16; + const char *const *names_bnd; + const char *const *names_mm; + const char *const *names_xmm; + const char *const *names_ymm; + const char *const *names_zmm; + const char *const *names_tmm; + const char *const *names_mask; /* Remember if the current op is a jump instruction. */ bool op_is_jump; @@ -2423,80 +2423,80 @@ struct op need to update onebyte_has_modrm or twobyte_has_modrm. */ #define MODRM_CHECK if (!ins->need_modrm) abort () -static const char *intel_names64[] = { +static const char *const intel_names64[] = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }; -static const char *intel_names32[] = { +static const char *const intel_names32[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }; -static const char *intel_names16[] = { +static const char *const intel_names16[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }; -static const char *intel_names8[] = { +static const char *const intel_names8[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", }; -static const char *intel_names8rex[] = { +static const char *const intel_names8rex[] = { "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }; -static const char *intel_names_seg[] = { +static const char *const intel_names_seg[] = { "es", "cs", "ss", "ds", "fs", "gs", "?", "?", }; -static const char *intel_index64 = "riz"; -static const char *intel_index32 = "eiz"; -static const char *intel_index16[] = { +static const char intel_index64[] = "riz"; +static const char intel_index32[] = "eiz"; +static const char *const intel_index16[] = { "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx" }; -static const char *att_names64[] = { +static const char *const att_names64[] = { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }; -static const char *att_names32[] = { +static const char *const att_names32[] = { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi", "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" }; -static const char *att_names16[] = { +static const char *const att_names16[] = { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di", "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" }; -static const char *att_names8[] = { +static const char *const att_names8[] = { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh", }; -static const char *att_names8rex[] = { +static const char *const att_names8rex[] = { "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil", "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" }; -static const char *att_names_seg[] = { +static const char *const att_names_seg[] = { "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?", }; -static const char *att_index64 = "%riz"; -static const char *att_index32 = "%eiz"; -static const char *att_index16[] = { +static const char att_index64[] = "%riz"; +static const char att_index32[] = "%eiz"; +static const char *const att_index16[] = { "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx" }; -static const char *intel_names_mm[] = { +static const char *const intel_names_mm[] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }; -static const char *att_names_mm[] = { +static const char *const att_names_mm[] = { "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" }; -static const char *intel_names_bnd[] = { +static const char *const intel_names_bnd[] = { "bnd0", "bnd1", "bnd2", "bnd3" }; -static const char *att_names_bnd[] = { +static const char *const att_names_bnd[] = { "%bnd0", "%bnd1", "%bnd2", "%bnd3" }; -static const char *intel_names_xmm[] = { +static const char *const intel_names_xmm[] = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", @@ -2506,7 +2506,7 @@ static const char *intel_names_xmm[] = { "xmm24", "xmm25", "xmm26", "xmm27", "xmm28", "xmm29", "xmm30", "xmm31" }; -static const char *att_names_xmm[] = { +static const char *const att_names_xmm[] = { "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", @@ -2517,7 +2517,7 @@ static const char *att_names_xmm[] = { "%xmm28", "%xmm29", "%xmm30", "%xmm31" }; -static const char *intel_names_ymm[] = { +static const char *const intel_names_ymm[] = { "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", "ymm8", "ymm9", "ymm10", "ymm11", @@ -2527,7 +2527,7 @@ static const char *intel_names_ymm[] = { "ymm24", "ymm25", "ymm26", "ymm27", "ymm28", "ymm29", "ymm30", "ymm31" }; -static const char *att_names_ymm[] = { +static const char *const att_names_ymm[] = { "%ymm0", "%ymm1", "%ymm2", "%ymm3", "%ymm4", "%ymm5", "%ymm6", "%ymm7", "%ymm8", "%ymm9", "%ymm10", "%ymm11", @@ -2538,7 +2538,7 @@ static const char *att_names_ymm[] = { "%ymm28", "%ymm29", "%ymm30", "%ymm31" }; -static const char *intel_names_zmm[] = { +static const char *const intel_names_zmm[] = { "zmm0", "zmm1", "zmm2", "zmm3", "zmm4", "zmm5", "zmm6", "zmm7", "zmm8", "zmm9", "zmm10", "zmm11", @@ -2548,7 +2548,7 @@ static const char *intel_names_zmm[] = { "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31" }; -static const char *att_names_zmm[] = { +static const char *const att_names_zmm[] = { "%zmm0", "%zmm1", "%zmm2", "%zmm3", "%zmm4", "%zmm5", "%zmm6", "%zmm7", "%zmm8", "%zmm9", "%zmm10", "%zmm11", @@ -2559,19 +2559,19 @@ static const char *att_names_zmm[] = { "%zmm28", "%zmm29", "%zmm30", "%zmm31" }; -static const char *intel_names_tmm[] = { +static const char *const intel_names_tmm[] = { "tmm0", "tmm1", "tmm2", "tmm3", "tmm4", "tmm5", "tmm6", "tmm7" }; -static const char *att_names_tmm[] = { +static const char *const att_names_tmm[] = { "%tmm0", "%tmm1", "%tmm2", "%tmm3", "%tmm4", "%tmm5", "%tmm6", "%tmm7" }; -static const char *intel_names_mask[] = { +static const char *const intel_names_mask[] = { "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" }; -static const char *att_names_mask[] = { +static const char *const att_names_mask[] = { "%k0", "%k1", "%k2", "%k3", "%k4", "%k5", "%k6", "%k7" }; @@ -10185,7 +10185,7 @@ static const struct dis386 float_reg[][8] = { }, }; -static char *fgrps[][8] = { +static const char *const fgrps[][8] = { /* Bad opcode 0 */ { "(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", @@ -11283,7 +11283,7 @@ static void print_register (instr_info *ins, unsigned int reg, unsigned int rexmask, int bytemode, int sizeflag) { - const char **names; + const char *const *names; USED_REX (rexmask); if (ins->rex & rexmask) @@ -11524,8 +11524,8 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) || bytemode == bnd_mode || bytemode == bnd_swap_mode); bool check_gather = false; - const char **indexes64 = ins->names64; - const char **indexes32 = ins->names32; + const char *const *indexes64 = ins->names64; + const char *const *indexes32 = ins->names32; havesib = 0; havebase = 1; @@ -12556,7 +12556,7 @@ OP_MMX (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { int reg = ins->modrm.reg; - const char **names; + const char *const *names; ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); if (ins->prefixes & PREFIX_DATA) @@ -12574,7 +12574,7 @@ OP_MMX (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, static void print_vector_reg (instr_info *ins, unsigned int reg, int bytemode) { - const char **names; + const char *const *names; if (bytemode == xmmq_mode || bytemode == evex_half_bcst_xmmqh_mode @@ -12670,7 +12670,7 @@ static void OP_EM (instr_info *ins, int bytemode, int sizeflag) { int reg; - const char **names; + const char *const *names; if (ins->modrm.mod != 3) { @@ -13040,8 +13040,8 @@ OP_Monitor (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, /* monitor %{e,r,}ax,%ecx,%edx" */ if (!ins->intel_syntax) { - const char **names = (ins->address_mode == mode_64bit - ? ins->names64 : ins->names32); + const char *const *names = (ins->address_mode == mode_64bit + ? ins->names64 : ins->names32); if (ins->prefixes & PREFIX_ADDR) { @@ -13217,7 +13217,7 @@ CMPXCHG8B_Fixup (instr_info *ins, int bytemode, int sizeflag) static void XMM_Fixup (instr_info *ins, int reg, int sizeflag ATTRIBUTE_UNUSED) { - const char **names; + const char *const *names; if (ins->need_vex) { @@ -13261,7 +13261,7 @@ static void OP_VEX (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { int reg, modrm_reg, sib_index = -1; - const char **names; + const char *const *names; if (!ins->need_vex) abort (); @@ -13432,7 +13432,7 @@ static void OP_REG_VexI4 (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { int reg; - const char **names = ins->names_xmm; + const char *const *names = ins->names_xmm; FETCH_DATA (ins->info, ins->codep + 1); reg = *ins->codep++; -- 2.30.2