From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id A49D43857033; Tue, 22 Aug 2023 00:06:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A49D43857033 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] kvx_dis_init X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: fddbba54a4b8224c848010048102ddcdbae1ec78 X-Git-Newrev: 5bf26ab7cb82c2e6308b269af44b989a51ee7903 Message-Id: <20230822000616.A49D43857033@sourceware.org> Date: Tue, 22 Aug 2023 00:06:16 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2023 00:06:16 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5bf26ab7cb82= c2e6308b269af44b989a51ee7903 commit 5bf26ab7cb82c2e6308b269af44b989a51ee7903 Author: Alan Modra Date: Tue Aug 22 07:31:03 2023 +0930 kvx_dis_init =20 kvx_dis_init currently always returns true, but error conditions do so by "return -1" which converts to true. The return status is ignored anyway, and it doesn't make much sense to error on unexpected arch or mach: If print_insn_kvx is called then the atch is known to be kvx, and it's better to choose some default for a user passing an unknown mach value rather than segfaulting in decode_insn when env.opc_table is NULL. =20 I've chosen the default mach to be bfd_mach_kv3_1, the default in bfd/cpu-kvx.c, not that it matters very much. In normal objdump/gdb usage, info->mach won't be an unexpected value. =20 * kvx-dis.c (kvx_dis_init): Return void. Don't error on unexpected arch or mach. Default to bfd_mach_kv3_1 for unknown mach. Don't clear info->disassembler_options. Diff: --- opcodes/kvx-dis.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/opcodes/kvx-dis.c b/opcodes/kvx-dis.c index eabef4af171..d7b86791c30 100644 --- a/opcodes/kvx-dis.c +++ b/opcodes/kvx-dis.c @@ -207,15 +207,9 @@ static struct kvx_dis_env env =3D { .kvx_max_dec_registers =3D 0 }; =20 -static bool +static void kvx_dis_init (struct disassemble_info *info) { - if (info->arch !=3D bfd_arch_kvx) - { - (*info->fprintf_func) (info->stream, "error: Unknown architecture\n"= ); - return -1; - } - env.kvx_arch_size =3D 32; switch (info->mach) { @@ -224,6 +218,7 @@ kvx_dis_init (struct disassemble_info *info) /* fallthrough */ case bfd_mach_kv3_1_usr: case bfd_mach_kv3_1: + default: env.opc_table =3D kvx_kv3_v1_optab; env.kvx_regfiles =3D kvx_kv3_v1_regfiles; env.kvx_registers =3D kvx_kv3_v1_registers; @@ -252,26 +247,14 @@ kvx_dis_init (struct disassemble_info *info) env.kvx_modifiers =3D kvx_kv4_v1_modifiers; env.kvx_dec_registers =3D kvx_kv4_v1_dec_registers; break; - - default: - /* Core not supported. */ - (*info->fprintf_func) (info->stream, "disassembling not supported fo= r " - "this KVX core! (core:%d)", (int) info->mach); - return -1; } =20 env.kvx_max_dec_registers =3D env.kvx_regfiles[KVX_REGFILE_DEC_REGISTERS= ]; =20 if (info->disassembler_options) - { - parse_kvx_dis_options (info->disassembler_options); + parse_kvx_dis_options (info->disassembler_options); =20 - /* To avoid repeated parsing of these options, we remove them here. = */ - info->disassembler_options =3D NULL; - } env.initialized_p =3D 1; - - return env.initialized_p; } =20 static int