From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by sourceware.org (Postfix) with ESMTPS id CC9DA3971C77 for ; Fri, 25 Sep 2020 16:45:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CC9DA3971C77 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R421e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04426; MF=cooper.qu@linux.alibaba.com; NM=1; PH=DS; RN=3; SR=0; TI=SMTPD_---0UA2lfVl_1601052309; Received: from L-X0CGLVDL-0840.local(mailfrom:cooper.qu@linux.alibaba.com fp:SMTPD_---0UA2lfVl_1601052309) by smtp.aliyun-inc.com(127.0.0.1); Sat, 26 Sep 2020 00:45:10 +0800 Subject: Re: [PATCH] CSKY: Add objdump option -M abi-names. To: Alan Modra , Lifang Xia Cc: binutils@sourceware.org References: <20200917063028.74459-1-cooper.qu@linux.alibaba.com> <20200925131837.GO5452@bubble.grove.modra.org> From: Cooper Qu Message-ID: <5b38e893-3c8c-784d-5c89-79aaf93b4d7d@linux.alibaba.com> Date: Sat, 26 Sep 2020 00:45:09 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200925131837.GO5452@bubble.grove.modra.org> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-15.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2020 16:45:21 -0000 On 9/25/20 9:18 PM, Alan Modra wrote: > On Wed, Sep 23, 2020 at 11:50:35PM +0800, Lifang Xia wrote: >> On 2020/9/17 14:30, Cooper Qu wrote: >>> Add option parser for disassembler, and refine the codes of >>> parse register operand and disassemble register operand. >>> While strengthen the operands legality check of some instructions. >>> >>> Co-Authored-By: Lifang Xia >>> >>> gas/ >>> * config/tc-csky.c (parse_type_ctrlreg): Use function >>> csky_get_control_regno to operand. >>> (csky_get_reg_val): Likewise. >>> (is_reg_sp_with_bracket): Use function csky_get_reg_val >>> to parse operand. >>> (is_reg_sp): Refine. >>> (is_oimm_within_range): Fix, report error when operand >>> is not constant. >>> (parse_type_cpreg): Refine. >>> (parse_type_cpcreg): Refine. >>> (get_operand_value): Add handle of OPRND_TYPE_IMM5b_LS. >>> (md_assemble): Fix no error reporting somtimes when >>> operands number are not fit. >>> (csky_addc64): Refine. >>> (csky_subc64): Refine. >>> (csky_or64): Refine. >>> (v1_work_fpu_fo): Refine. >>> (v1_work_fpu_read): Refine. >>> (v1_work_fpu_writed): Refine. >>> (v1_work_fpu_readd): Refine. >>> (v2_work_addc): New function, strengthen the operands legality >>> check of addc. >>> * gas/testsuite/gas/csky/all.d : Use register number format when >>> disassemble register name by default. >>> * gas/testsuite/gas/csky/cskyv2_all.d : Likewise. >>> * gas/testsuite/gas/csky/trust.d: Likewise. >>> * gas/testsuite/gas/csky/cskyv2_ck860.d : Fix. >>> * gas/testsuite/gas/csky/trust.s : Fix. >>> >>> opcodes/ >>> * csky-dis.c (using_abi): New. >>> (parse_csky_dis_options): New function. >>> (get_gr_name): New function. >>> (get_cr_name): New function. >>> (csky_output_operand): Use get_gr_name and get_cr_name to >>> disassemble and add handle of OPRND_TYPE_IMM5b_LS. >>> (print_insn_csky): Parse disassembler options. >>> * opcodes/csky-opc.h (OPRND_TYPE_IMM5b_LS): New enum. >>> (GENARAL_REG_BANK): Define. >>> (REG_SUPPORT_ALL): Define. >>> (REG_SUPPORT_ALL): New. >>> (ASH): Define. >>> (REG_SUPPORT_A): Define. >>> (REG_SUPPORT_B): Define. >>> (REG_SUPPORT_C): Define. >>> (REG_SUPPORT_D): Define. >>> (REG_SUPPORT_E): Define. >>> (csky_abiv1_general_regs): New. >>> (csky_abiv1_control_regs): New. >>> (csky_abiv2_general_regs): New. >>> (csky_abiv2_control_regs): New. >>> (get_register_name): New function. >>> (get_register_number): New function. >>> (csky_get_general_reg_name): New function. >>> (csky_get_general_regno): New function. >>> (csky_get_control_reg_name): New function. >>> (csky_get_control_regno): New function. >>> (csky_v2_opcodes): Prefer two oprerans format for bclri and >>> bseti, strengthen the operands legality check of addc, zext >>> and sext. > This patch results in ubsan errors, for example > opcodes/csky-opc.h:929 shift exponent 536870912 is too large > > I took a look at what I think the code is trying to do, and came up > with the following fix. Please check that this is correct. > > opcodes/ > * csky-opc.h: Formatting. > (GENERAL_REG_BANK): Correct spelling. Update use throughout file. > (get_register_name): Mask arch with CSKY_ARCH_MASK for shift, > and shift 1u. > (get_register_number): Likewise. > * csky-dis.c (get_gr_name, get_cr_name): Don't mask mach_flag. > gas/ > * config/tc-csky.c (parse_type_ctrlreg): Don't mask mach_flag > for csky_get_control_regno. > (csky_get_reg_val): Likewise when calling csky_get_general_regno. > Hi Alan, The patch looks good and I have tested it, there is no problem. Thanks for fixing the bug and improving the code, these bugs will prompt me to write and test better next time. Best Regards, Cooper