From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe12::62d]) by sourceware.org (Postfix) with ESMTPS id 17C223857B98 for ; Tue, 4 Apr 2023 07:00:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17C223857B98 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a5dmgVhxxAu62adAasi0rSgk6frbFGkV7Onx8iVlOstAlCVfJErc3TPn5GvuXxPICzl7F6fl/ajq89feNn4sml+sVEDf3n/8IKeLFzch7Z4qshwjtQtNIHafOxwSaOywz/ncUb51F+68nXuTvWBh0rrLc2PrjEtO0kPB5uXa5apKNggabqARWCrXifGXGnUEn08LQEP7L8Ni7ZwSFFKh9duU5xbIwVtS0RVIXKcng9/JuFZSX+jnpP2dIVk+rUsPgMQ+JHeitGUkVGK2UBvVtdDrYzlkdjBFQx01HJq5Do5Ep+yhAvslxjZk5mtROgXNIb0tv8O2PKbo2Akib//AdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BBF5UP47JreI32UO5pcGEjrbOyRBnCkipQGBylZLrKI=; b=iNVIp32oxJ2vINpb1IbRLOHBMdQ0M6hkU7/ZIVb645fwFKn84C6hm70e2lOsftQaQKqvQvDqqTtmyeKFyEK+AqKxfHIh2mTmMKWjqOFSErIhm18N8MXH0HWKZYGBoVHGRzIkeaBjPLJpvZ76WLPKMHuc0fVKwQvA8QzUF+4LinfAvquZVDVabKzhPhW68XQp2/jugCrLAUq+L1Ld63B2pBxLXyIPCw873pVNdr3hR9IJrBVDwestzDFA41CTSSQ9m9PJuZjfUcxlPpGoX+vcVD2e7regwz/IJRb0mVldVkATQWEjT29esrfuimOBEyrktbmZsIc8xHEoD8td1tK5qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BBF5UP47JreI32UO5pcGEjrbOyRBnCkipQGBylZLrKI=; b=Zea/OU0KFYDdRsLveofXEd5XUkbiNky2zTHkCK0ngxGKf4tzy76MNolpNkldD6zDhscmVuGbgtZZQ1kpkEGrW65t6UAgnNgQcZKZAWjD6dEbPL7cyTgcds44dOG291SrDO6iH47fPHrrL35jCo4J0jVjctBhgduNPxi5i+p1sZgKixTmsdkbMIadqUOEow2B1AC+8mp4yd5d4zuBtOYZhmVL1s+QH3LtRxmu5VeOXsntcfuaVLLRUD+phVntVeyqHvYhHgZsho4aElh/V4QpkZwM/KNq1S4SQqBx+dHE8yJJYg85tK0aUmtv8hrJRU1GyYDOhpmRJgOGExhOeBRVSA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AM8PR04MB7314.eurprd04.prod.outlook.com (2603:10a6:20b:1df::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Tue, 4 Apr 2023 07:00:26 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%6]) with mapi id 15.20.6254.035; Tue, 4 Apr 2023 07:00:26 +0000 Message-ID: <3231104b-ffc0-e471-79be-f18e14c3264e@suse.com> Date: Tue, 4 Apr 2023 09:00:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 5/8] x86: change fetch error handling when processing operands Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> From: Jan Beulich In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0082.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::21) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AM8PR04MB7314:EE_ X-MS-Office365-Filtering-Correlation-Id: 12f7948e-713c-4e6f-3d07-08db34da4468 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H2oTBWgeV35R+y9hxlVbwMucDFjq/ar3UVLbJRUvIPWvWNShEcnhPHjVawBCeXyoBLf9U9bQ2H1zAaWpPQHWxa1xu4ZOfS68ghvAbnQHY3QLNjxjqePQbVrv9PJqzPJ5TnoPQSmq7ah0z9T/IYGMpG/H0I0g2HU8no6XKx3YZUuJEkeOMZA9/dvEvInLrxrB55byh9GKoyuUQlVzjyAtsTytazJhG9ycMPIuNYSCtlZBRIbPb0dhyfQOGble5pikTlzX5NZiT8CqdYvMMR9RJdAue6mQX0JOyCF5R7n4pD64zrhYnGGEpa6X6pmyUCyYU+uf9sAEgZKvCBBoNbSquKHg9P/7fK+6nAV+Bg6aRPytzUMOl0B1cDEbJDR0Ek2rzpFWrgsL9Ekzieae9IXSLixWiZ3cfLbkbIJWlSNBxSc49nxXIEc/qrKD/5TJKCjSrC3L+YJ1+7wFif0fYr1ZK2PNIBpD2k15WeCITA39Uj7UgnSgwpL53zedkF+KqTbdelYQ59M8OIOpcqgPUBFKaRS1XwBJhMEP3aDZeo3AjOVb0ZSxKU+XK1NsJbEyO8LcV9P/rRPu4rXsJ+bnpDi4XE7EcAyrEFJ30rrLlbFd5o7fscmkqfo6ZurCFct0xGkTpyVBK3ZUTa8PTI4WUIRiXQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(346002)(376002)(39860400002)(136003)(396003)(451199021)(41300700001)(5660300002)(8676002)(8936002)(38100700002)(6916009)(66556008)(66476007)(66946007)(36756003)(86362001)(31696002)(30864003)(2906002)(4326008)(2616005)(31686004)(6486002)(186003)(6512007)(26005)(6506007)(54906003)(83380400001)(316002)(478600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V0NrUVZCRVBrZy9YRFMvcSs0SysvejNhcDFiVWxDUmRsVlFNMm04V3NUS25C?= =?utf-8?B?SE54VWx4bWZlK2FmeEI4em9aUjZWcFByWWJxNGVKWHhZcC9Jd3U4MlBJT1l6?= =?utf-8?B?cjVleGpPREVVUGw2OTNqN3czR0NWcnhPNGpZdjBEd1d5ZW12SVN1VG1EOC9N?= =?utf-8?B?Tkp6WXllNnRPVytBT0NqYzFDdE1wbEgrMFg2bkdtRDlIRTU4czhDZTloQTFW?= =?utf-8?B?L1ZMMzRwWHdQQXVSNExEcWMvdHdRcUhicC91YWNyWkRNV3BRUGtJTXV6TnBu?= =?utf-8?B?U1NqY2crY1FWbmJVU2FXVjQ0a1VQZWNkTm45a2tjdFlaMFZlNmhFZDIyNVFU?= =?utf-8?B?UzRBY2prSFlUdkxKV0VCbjN3aC90UzZjMnA4eWFlRmF1UUtnMUVWN2h0Ukxt?= =?utf-8?B?UExtVEY0QU8yUDY5Q0h4dllxbFVTNHRRL09oSUQ0Ni9yeFJ0Q2Z4L3RIUGpo?= =?utf-8?B?bHBFbU9SMm9UQnNXK0lKTHY1RmtCZStIdkN0NWNyQzFCSkRLdTRmMFBveGkw?= =?utf-8?B?ekZiV1JsNmE3UG9PZ2krSFdhVHlVK0szNkVGVjc4Y0FBNjB5ZEh0M215SitF?= =?utf-8?B?dklESnJ0aUlEWG5SMmgyTk0rc2hMZndPdXBUVTFVbUlPZ3dGMXpjOEp6RTB6?= =?utf-8?B?anpDVXRxSm1jSGUxYkMwNUtzci92UTJYTDRvdmR4L25XdGE3MnJqbGwyQzR2?= =?utf-8?B?eGprWTg2QWVGcUp1M3BnbFR5N0oydUF3THpTM3ExWm05aWJTMVNQM2szWFda?= =?utf-8?B?WERNUVp2OEF2bXJ6eFpoeFoyZmZxNUhaeHErSWVpc3hxU0p4WllhellYYURs?= =?utf-8?B?ZUxUSWRweEQyZVRrRGRqUkRWYTNxZllIbm9UcTlxc3pOaE1mZ2dzWFZtc2xs?= =?utf-8?B?aWFyc29mMGFnd1hoVmJ0a3RsaEMxTWpXNFRqcTAyb2huMktlT1d6RkQ2bkR0?= =?utf-8?B?TENNNGxmQXE4Wlp2aFlVWGt3QWxQQTkwcWg5bm5jZG1obTJEY3oxSWFXMWtr?= =?utf-8?B?NEw4VGF6NWN3WkxqZ09IVm1ab2lJd3Zqak1NU0xpTkR5d3VQMjRlNEVsVUFF?= =?utf-8?B?YTJWZVIxdDRLQlVLejh0dWEvQWRzd1hKSTBYdzV1WUovVEE3Q1FFamZOS0lJ?= =?utf-8?B?YUxtVXZ0b2VxYmFBa2RWM3VvQThiSlRDek1sL0xwZ3M1by8ydTNRRG5rN3Fr?= =?utf-8?B?S0dPcTFQZVlVRUVHZkJHeTBGQ1RMT3ArZkFGR2EyeDFJNFNvNlVJRXdwUFJC?= =?utf-8?B?dHBJekc2dW1EdlN6VmpGL0Y4OW56SGtPNTd2RnMwYTJHOGRjelE5aHo3clli?= =?utf-8?B?bmY5ZFpyVjZqaW16SWszajN5NHdaQTlQWHpHdTRWbitGNUN0dEJndGNQWGdz?= =?utf-8?B?aXBJcnlReW1VcGNXM0NneGpvUDhkcWlNbDJGeExIT2NRemxNRnZZNU5zOW5k?= =?utf-8?B?dHJoYTBGZ09QeStVRU8yU1F6cGEzNlNVQmNYM1dmdm5kcFIrUEdqOFppOWNP?= =?utf-8?B?VTI0U3ZTNk55ZkUzNmJYekplOWtpa3JoaHdGZXpwZnp5SFZzQkFIQ2pJanpM?= =?utf-8?B?eW1pNnVQYkpZVzVCeWcxa1ArSVZNdDRTeDNad2c0UkZnelVWWFZ6dk1MRWx2?= =?utf-8?B?S21vd0V1Mi9BMXJuOGJLTkxjMW9IMzlYdmZkeGxnS0c4QVBvYzJoOXVTdFgv?= =?utf-8?B?KzJoYWxsNnVsSDU5QS8zb2N3elBob2RyMmhRNWhjWElSbVdtclVpV0puYmcz?= =?utf-8?B?QnNLNXp5WXFZM2Myak03UnNlUWp2VW13Ui8wN2l6dloxRzcvZWpoTzZVZ0NP?= =?utf-8?B?L0VzYlN4VzZUZ0hhelM2Zi96S2tYL0Y4L0wwZDNIejdhaWdMbTdKdFdYVFVy?= =?utf-8?B?KzF2eEJVL1BLdXkzWS9mMExUazhHZk4rZ2FLYlBuekVpeHFSMy8zeXgrUkRI?= =?utf-8?B?NGNJN1N3Z2xRcitrR2dwVTMrV1dVZVpiS2RNYWN0eVFGeTRzdGFDZXY1b3p3?= =?utf-8?B?NmpiVldnY0d5anJrQm9rTnFPMldFc2ZnSDh4RU84N3BGMkVDVHJTcG9DdVFD?= =?utf-8?B?b0c4blY4c0hHTUlTQjZuYXRMRDdiR2VoUnlDWHBMNDhpYTNTaDc1c3MyMGFu?= =?utf-8?Q?a7heDdOxMqTpcqblgMX4CaEjh?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12f7948e-713c-4e6f-3d07-08db34da4468 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 07:00:26.0617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r6WzU28jqbN1RVMyCSN4R1MeFMmr51ScGsjBguBbCURzstq1zOrAomjAURuJ6OnVs/1NjogPHD7KZQtjaWEUdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7314 X-Spam-Status: No, score=-3028.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS,TXREP,T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Make the handler functions all return boolean and convert FETCH_DATA() uses to fetch_code(). --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -42,79 +42,80 @@ #include typedef struct instr_info instr_info; -static void dofloat (instr_info *, int); -static void OP_ST (instr_info *, int, int); -static void OP_STi (instr_info *, int, int); +static bool dofloat (instr_info *, int); static int putop (instr_info *, const char *, int); static void oappend_with_style (instr_info *, const char *, enum disassembler_style); static void oappend (instr_info *, const char *); static void append_seg (instr_info *); -static void OP_indirE (instr_info *, int, int); -static void OP_E_memory (instr_info *, int, int); -static void OP_E (instr_info *, int, int); -static void OP_G (instr_info *, int, int); static bfd_vma get64 (instr_info *); static bfd_signed_vma get32 (instr_info *); static bfd_signed_vma get32s (instr_info *); static int get16 (instr_info *); static void set_op (instr_info *, bfd_vma, bool); -static void OP_Skip_MODRM (instr_info *, int, int); -static void OP_REG (instr_info *, int, int); -static void OP_IMREG (instr_info *, int, int); -static void OP_I (instr_info *, int, int); -static void OP_I64 (instr_info *, int, int); -static void OP_sI (instr_info *, int, int); -static void OP_J (instr_info *, int, int); -static void OP_SEG (instr_info *, int, int); -static void OP_DIR (instr_info *, int, int); -static void OP_OFF (instr_info *, int, int); -static void OP_OFF64 (instr_info *, int, int); -static void ptr_reg (instr_info *, int, int); -static void OP_ESreg (instr_info *, int, int); -static void OP_DSreg (instr_info *, int, int); -static void OP_C (instr_info *, int, int); -static void OP_D (instr_info *, int, int); -static void OP_T (instr_info *, int, int); -static void OP_MMX (instr_info *, int, int); -static void OP_XMM (instr_info *, int, int); -static void OP_EM (instr_info *, int, int); -static void OP_EX (instr_info *, int, int); -static void OP_EMC (instr_info *, int,int); -static void OP_MXC (instr_info *, int,int); -static void OP_MS (instr_info *, int, int); -static void OP_XS (instr_info *, int, int); -static void OP_M (instr_info *, int, int); -static void OP_VEX (instr_info *, int, int); -static void OP_VexR (instr_info *, int, int); -static void OP_VexW (instr_info *, int, int); -static void OP_Rounding (instr_info *, int, int); -static void OP_REG_VexI4 (instr_info *, int, int); -static void OP_VexI4 (instr_info *, int, int); -static void PCLMUL_Fixup (instr_info *, int, int); -static void VPCMP_Fixup (instr_info *, int, int); -static void VPCOM_Fixup (instr_info *, int, int); -static void OP_0f07 (instr_info *, int, int); -static void OP_Monitor (instr_info *, int, int); -static void OP_Mwait (instr_info *, int, int); -static void NOP_Fixup (instr_info *, int, int); -static void OP_3DNowSuffix (instr_info *, int, int); -static void CMP_Fixup (instr_info *, int, int); -static void BadOp (instr_info *); -static void REP_Fixup (instr_info *, int, int); -static void SEP_Fixup (instr_info *, int, int); -static void BND_Fixup (instr_info *, int, int); -static void NOTRACK_Fixup (instr_info *, int, int); -static void HLE_Fixup1 (instr_info *, int, int); -static void HLE_Fixup2 (instr_info *, int, int); -static void HLE_Fixup3 (instr_info *, int, int); -static void CMPXCHG8B_Fixup (instr_info *, int, int); -static void XMM_Fixup (instr_info *, int, int); -static void FXSAVE_Fixup (instr_info *, int, int); - -static void MOVSXD_Fixup (instr_info *, int, int); -static void DistinctDest_Fixup (instr_info *, int, int); -static void PREFETCHI_Fixup (instr_info *, int, int); + +static bool OP_E (instr_info *, int, int); +static bool OP_E_memory (instr_info *, int, int); +static bool OP_indirE (instr_info *, int, int); +static bool OP_G (instr_info *, int, int); +static bool OP_ST (instr_info *, int, int); +static bool OP_STi (instr_info *, int, int); +static bool OP_Skip_MODRM (instr_info *, int, int); +static bool OP_REG (instr_info *, int, int); +static bool OP_IMREG (instr_info *, int, int); +static bool OP_I (instr_info *, int, int); +static bool OP_I64 (instr_info *, int, int); +static bool OP_sI (instr_info *, int, int); +static bool OP_J (instr_info *, int, int); +static bool OP_SEG (instr_info *, int, int); +static bool OP_DIR (instr_info *, int, int); +static bool OP_OFF (instr_info *, int, int); +static bool OP_OFF64 (instr_info *, int, int); +static bool OP_ESreg (instr_info *, int, int); +static bool OP_DSreg (instr_info *, int, int); +static bool OP_C (instr_info *, int, int); +static bool OP_D (instr_info *, int, int); +static bool OP_T (instr_info *, int, int); +static bool OP_MMX (instr_info *, int, int); +static bool OP_XMM (instr_info *, int, int); +static bool OP_EM (instr_info *, int, int); +static bool OP_EX (instr_info *, int, int); +static bool OP_EMC (instr_info *, int,int); +static bool OP_MXC (instr_info *, int,int); +static bool OP_MS (instr_info *, int, int); +static bool OP_XS (instr_info *, int, int); +static bool OP_M (instr_info *, int, int); +static bool OP_VEX (instr_info *, int, int); +static bool OP_VexR (instr_info *, int, int); +static bool OP_VexW (instr_info *, int, int); +static bool OP_Rounding (instr_info *, int, int); +static bool OP_REG_VexI4 (instr_info *, int, int); +static bool OP_VexI4 (instr_info *, int, int); +static bool OP_0f07 (instr_info *, int, int); +static bool OP_Monitor (instr_info *, int, int); +static bool OP_Mwait (instr_info *, int, int); + +static bool BadOp (instr_info *); + +static bool PCLMUL_Fixup (instr_info *, int, int); +static bool VPCMP_Fixup (instr_info *, int, int); +static bool VPCOM_Fixup (instr_info *, int, int); +static bool NOP_Fixup (instr_info *, int, int); +static bool OP_3DNowSuffix (instr_info *, int, int); +static bool CMP_Fixup (instr_info *, int, int); +static bool REP_Fixup (instr_info *, int, int); +static bool SEP_Fixup (instr_info *, int, int); +static bool BND_Fixup (instr_info *, int, int); +static bool NOTRACK_Fixup (instr_info *, int, int); +static bool HLE_Fixup1 (instr_info *, int, int); +static bool HLE_Fixup2 (instr_info *, int, int); +static bool HLE_Fixup3 (instr_info *, int, int); +static bool CMPXCHG8B_Fixup (instr_info *, int, int); +static bool XMM_Fixup (instr_info *, int, int); +static bool FXSAVE_Fixup (instr_info *, int, int); +static bool MOVSXD_Fixup (instr_info *, int, int); +static bool DistinctDest_Fixup (instr_info *, int, int); +static bool PREFETCHI_Fixup (instr_info *, int, int); static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const instr_info *, enum disassembler_style, @@ -1815,7 +1816,7 @@ enum EVEX_W_MAP5_7A_P_3, }; -typedef void (*op_rtn) (instr_info *ins, int bytemode, int sizeflag); +typedef bool (*op_rtn) (instr_info *ins, int bytemode, int sizeflag); struct dis386 { const char *name; @@ -9953,9 +9954,9 @@ print_insn (bfd_vma pc, disassemble_info if (dp->name == NULL && dp->op[0].bytemode == FLOATCODE) { - if (!get_sib (&ins, sizeflag)) + if (!get_sib (&ins, sizeflag) + || !dofloat (&ins, sizeflag)) return fetch_error (&ins); - dofloat (&ins, sizeflag); } else { @@ -9970,8 +9971,9 @@ print_insn (bfd_vma pc, disassemble_info { ins.obufp = ins.op_out[i]; ins.op_ad = MAX_OPERANDS - 1 - i; - if (dp->op[i].rtn) - (*dp->op[i].rtn) (&ins, dp->op[i].bytemode, sizeflag); + if (dp->op[i].rtn + && !dp->op[i].rtn (&ins, dp->op[i].bytemode, sizeflag)) + return fetch_error (&ins); /* For EVEX instruction after the last operand masking should be printed. */ if (i == 0 && ins.vex.evex) @@ -10610,16 +10612,17 @@ swap_operand (instr_info *ins) ins->mnemonicendp += 2; } -static void +static bool OP_Skip_MODRM (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { /* Skip mod/rm byte. */ MODRM_CHECK; ins->codep++; + return true; } -static void +static bool dofloat (instr_info *ins, int sizeflag) { const struct dis386 *dp; @@ -10634,8 +10637,7 @@ dofloat (instr_info *ins, int sizeflag) putop (ins, float_mem[fp_indx], sizeflag); ins->obufp = ins->op_out[0]; ins->op_ad = 2; - OP_E (ins, float_mem_mode[fp_indx], sizeflag); - return; + return OP_E (ins, float_mem_mode[fp_indx], sizeflag); } /* Skip mod/rm byte. */ MODRM_CHECK; @@ -10656,24 +10658,28 @@ dofloat (instr_info *ins, int sizeflag) ins->obufp = ins->op_out[0]; ins->op_ad = 2; - if (dp->op[0].rtn) - (*dp->op[0].rtn) (ins, dp->op[0].bytemode, sizeflag); + if (dp->op[0].rtn + && !dp->op[0].rtn (ins, dp->op[0].bytemode, sizeflag)) + return false; ins->obufp = ins->op_out[1]; ins->op_ad = 1; - if (dp->op[1].rtn) - (*dp->op[1].rtn) (ins, dp->op[1].bytemode, sizeflag); + if (dp->op[1].rtn + && !dp->op[1].rtn (ins, dp->op[1].bytemode, sizeflag)) + return false; } + return true; } -static void +static bool OP_ST (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { oappend_register (ins, "%st"); + return true; } -static void +static bool OP_STi (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -10683,6 +10689,7 @@ OP_STi (instr_info *ins, int bytemode AT if (res < 0 || (size_t) res >= ARRAY_SIZE (scratch)) abort (); oappend_register (ins, scratch); + return true; } /* Capital letters in template are macros. */ @@ -11371,12 +11378,12 @@ append_seg (instr_info *ins) oappend_char (ins, ':'); } -static void +static bool OP_indirE (instr_info *ins, int bytemode, int sizeflag) { if (!ins->intel_syntax) oappend (ins, "*"); - OP_E (ins, bytemode, sizeflag); + return OP_E (ins, bytemode, sizeflag); } static void @@ -11820,7 +11827,7 @@ print_register (instr_info *ins, unsigne oappend_register (ins, names[reg]); } -static void +static bool OP_E_memory (instr_info *ins, int bytemode, int sizeflag) { bfd_vma disp = 0; @@ -12010,7 +12017,7 @@ OP_E_memory (instr_info *ins, int bytemo || bytemode == vex_sibmem_mode) { oappend (ins, "(bad)"); - return; + return true; } } rbase = base + add; @@ -12027,12 +12034,13 @@ OP_E_memory (instr_info *ins, int bytemo if (riprel && bytemode == v_bndmk_mode) { oappend (ins, "(bad)"); - return; + return true; } } break; case 1: - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; disp = *ins->codep++; if ((disp & 0x80) != 0) disp -= 0x100; @@ -12196,7 +12204,7 @@ OP_E_memory (instr_info *ins, int bytemo || bytemode == vex_vsib_q_w_dq_mode) { oappend (ins, "(bad)"); - return; + return true; } else { @@ -12213,7 +12221,8 @@ OP_E_memory (instr_info *ins, int bytemo } break; case 1: - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; disp = *ins->codep++; if ((disp & 0x80) != 0) disp -= 0x100; @@ -12336,9 +12345,11 @@ OP_E_memory (instr_info *ins, int bytemo if (ins->vex.no_broadcast) oappend (ins, "{bad}"); } + + return true; } -static void +static bool OP_E (instr_info *ins, int bytemode, int sizeflag) { /* Skip mod/rm byte. */ @@ -12354,21 +12365,20 @@ OP_E (instr_info *ins, int bytemode, int swap_operand (ins); print_register (ins, ins->modrm.rm, REX_B, bytemode, sizeflag); + return true; } - else - OP_E_memory (ins, bytemode, sizeflag); + + return OP_E_memory (ins, bytemode, sizeflag); } -static void +static bool OP_G (instr_info *ins, int bytemode, int sizeflag) { if (ins->vex.evex && !ins->vex.r && ins->address_mode == mode_64bit) - { - oappend (ins, "(bad)"); - return; - } - - print_register (ins, ins->modrm.reg, REX_R, bytemode, sizeflag); + oappend (ins, "(bad)"); + else + print_register (ins, ins->modrm.reg, REX_R, bytemode, sizeflag); + return true; } #ifdef BFD64 @@ -12451,7 +12461,7 @@ set_op (instr_info *ins, bfd_vma op, boo ins->op_riprel[ins->op_ad] = riprel; } -static void +static bool OP_REG (instr_info *ins, int code, int sizeflag) { const char *s; @@ -12462,7 +12472,7 @@ OP_REG (instr_info *ins, int code, int s case es_reg: case ss_reg: case cs_reg: case ds_reg: case fs_reg: case gs_reg: oappend_register (ins, att_names_seg[code - es_reg]); - return; + return true; } USED_REX (REX_B); @@ -12512,12 +12522,13 @@ OP_REG (instr_info *ins, int code, int s break; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); - return; + return true; } oappend_register (ins, s); + return true; } -static void +static bool OP_IMREG (instr_info *ins, int code, int sizeflag) { const char *s; @@ -12528,7 +12539,7 @@ OP_IMREG (instr_info *ins, int code, int if (!ins->intel_syntax) { oappend (ins, "(%dx)"); - return; + return true; } s = att_names16[dx_reg - ax_reg]; break; @@ -12553,12 +12564,13 @@ OP_IMREG (instr_info *ins, int code, int break; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); - return; + return true; } oappend_register (ins, s); + return true; } -static void +static bool OP_I (instr_info *ins, int bytemode, int sizeflag) { bfd_signed_vma op; @@ -12567,7 +12579,8 @@ OP_I (instr_info *ins, int bytemode, int switch (bytemode) { case b_mode: - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; op = *ins->codep++; mask = 0xff; break; @@ -12601,32 +12614,31 @@ OP_I (instr_info *ins, int bytemode, int case const_1_mode: if (ins->intel_syntax) oappend (ins, "1"); - return; + return true; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); - return; + return true; } op &= mask; oappend_immediate (ins, op); + return true; } -static void +static bool OP_I64 (instr_info *ins, int bytemode, int sizeflag) { if (bytemode != v_mode || ins->address_mode != mode_64bit || !(ins->rex & REX_W)) - { - OP_I (ins, bytemode, sizeflag); - return; - } + return OP_I (ins, bytemode, sizeflag); USED_REX (REX_W); oappend_immediate (ins, get64 (ins)); + return true; } -static void +static bool OP_sI (instr_info *ins, int bytemode, int sizeflag) { bfd_signed_vma op; @@ -12635,7 +12647,8 @@ OP_sI (instr_info *ins, int bytemode, in { case b_mode: case b_T_mode: - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; op = *ins->codep++; if ((op & 0x80) != 0) op -= 0x100; @@ -12671,13 +12684,14 @@ OP_sI (instr_info *ins, int bytemode, in break; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); - return; + return true; } oappend_immediate (ins, op); + return true; } -static void +static bool OP_J (instr_info *ins, int bytemode, int sizeflag) { bfd_vma disp; @@ -12687,7 +12701,8 @@ OP_J (instr_info *ins, int bytemode, int switch (bytemode) { case b_mode: - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; disp = *ins->codep++; if ((disp & 0x80) != 0) disp -= 0x100; @@ -12719,24 +12734,27 @@ OP_J (instr_info *ins, int bytemode, int break; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); - return; + return true; } disp = ((ins->start_pc + (ins->codep - ins->start_codep) + disp) & mask) | segment; set_op (ins, disp, false); print_operand_value (ins, disp, dis_style_text); + return true; } -static void +static bool OP_SEG (instr_info *ins, int bytemode, int sizeflag) { if (bytemode == w_mode) - oappend_register (ins, att_names_seg[ins->modrm.reg]); - else - OP_E (ins, ins->modrm.mod == 3 ? bytemode : w_mode, sizeflag); + { + oappend_register (ins, att_names_seg[ins->modrm.reg]); + return true; + } + return OP_E (ins, ins->modrm.mod == 3 ? bytemode : w_mode, sizeflag); } -static void +static bool OP_DIR (instr_info *ins, int dummy ATTRIBUTE_UNUSED, int sizeflag) { int seg, offset, res; @@ -12760,9 +12778,10 @@ OP_DIR (instr_info *ins, int dummy ATTRI if (res < 0 || (size_t) res >= ARRAY_SIZE (scratch)) abort (); oappend (ins, scratch); + return true; } -static void +static bool OP_OFF (instr_info *ins, int bytemode, int sizeflag) { bfd_vma off; @@ -12785,19 +12804,17 @@ OP_OFF (instr_info *ins, int bytemode, i } } print_operand_value (ins, off, dis_style_address_offset); + return true; } -static void +static bool OP_OFF64 (instr_info *ins, int bytemode, int sizeflag) { bfd_vma off; if (ins->address_mode != mode_64bit || (ins->prefixes & PREFIX_ADDR)) - { - OP_OFF (ins, bytemode, sizeflag); - return; - } + return OP_OFF (ins, bytemode, sizeflag); if (ins->intel_syntax && (sizeflag & SUFFIX_ALWAYS)) intel_operand_size (ins, bytemode, sizeflag); @@ -12814,6 +12831,7 @@ OP_OFF64 (instr_info *ins, int bytemode, } } print_operand_value (ins, off, dis_style_address_offset); + return true; } static void @@ -12838,7 +12856,7 @@ ptr_reg (instr_info *ins, int code, int oappend_char (ins, ins->close_char); } -static void +static bool OP_ESreg (instr_info *ins, int code, int sizeflag) { if (ins->intel_syntax) @@ -12861,9 +12879,10 @@ OP_ESreg (instr_info *ins, int code, int oappend_register (ins, att_names_seg[0]); oappend_char (ins, ':'); ptr_reg (ins, code, sizeflag); + return true; } -static void +static bool OP_DSreg (instr_info *ins, int code, int sizeflag) { if (ins->intel_syntax) @@ -12888,9 +12907,10 @@ OP_DSreg (instr_info *ins, int code, int ins->active_seg_prefix = PREFIX_DS; append_seg (ins); ptr_reg (ins, code, sizeflag); + return true; } -static void +static bool OP_C (instr_info *ins, int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -12915,9 +12935,10 @@ OP_C (instr_info *ins, int dummy ATTRIBU if (res < 0 || (size_t) res >= ARRAY_SIZE (scratch)) abort (); oappend_register (ins, scratch); + return true; } -static void +static bool OP_D (instr_info *ins, int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -12935,9 +12956,10 @@ OP_D (instr_info *ins, int dummy ATTRIBU if (res < 0 || (size_t) res >= ARRAY_SIZE (scratch)) abort (); oappend (ins, scratch); + return true; } -static void +static bool OP_T (instr_info *ins, int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -12948,9 +12970,10 @@ OP_T (instr_info *ins, int dummy ATTRIBU if (res < 0 || (size_t) res >= ARRAY_SIZE (scratch)) abort (); oappend_register (ins, scratch); + return true; } -static void +static bool OP_MMX (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -12968,6 +12991,7 @@ OP_MMX (instr_info *ins, int bytemode AT else names = att_names_mm; oappend_register (ins, names[reg]); + return true; } static void @@ -13045,7 +13069,7 @@ print_vector_reg (instr_info *ins, unsig oappend_register (ins, names[reg]); } -static void +static bool OP_XMM (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { unsigned int reg = ins->modrm.reg; @@ -13065,9 +13089,10 @@ OP_XMM (instr_info *ins, int bytemode, i ins->vex.no_broadcast = true; print_vector_reg (ins, reg, bytemode); + return true; } -static void +static bool OP_EM (instr_info *ins, int bytemode, int sizeflag) { int reg; @@ -13081,8 +13106,7 @@ OP_EM (instr_info *ins, int bytemode, in bytemode = (ins->prefixes & PREFIX_DATA) ? x_mode : q_mode; ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); } - OP_E (ins, bytemode, sizeflag); - return; + return OP_E (ins, bytemode, sizeflag); } if ((sizeflag & SUFFIX_ALWAYS) && bytemode == v_swap_mode) @@ -13103,6 +13127,7 @@ OP_EM (instr_info *ins, int bytemode, in else names = att_names_mm; oappend_register (ins, names[reg]); + return true; } /* cvt* are the only instructions in sse2 which have @@ -13110,7 +13135,7 @@ OP_EM (instr_info *ins, int bytemode, in in their opcode. 0x66 was originally used to differentiate between SSE and MMX instruction(operands). So we have to handle the cvt* separately using OP_EMC and OP_MXC */ -static void +static bool OP_EMC (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 3) @@ -13120,8 +13145,7 @@ OP_EMC (instr_info *ins, int bytemode, i bytemode = (ins->prefixes & PREFIX_DATA) ? x_mode : q_mode; ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); } - OP_E (ins, bytemode, sizeflag); - return; + return OP_E (ins, bytemode, sizeflag); } /* Skip mod/rm byte. */ @@ -13129,17 +13153,19 @@ OP_EMC (instr_info *ins, int bytemode, i ins->codep++; ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); oappend_register (ins, att_names_mm[ins->modrm.rm]); + return true; } -static void +static bool OP_MXC (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); oappend_register (ins, att_names_mm[ins->modrm.reg]); + return true; } -static void +static bool OP_EX (instr_info *ins, int bytemode, int sizeflag) { int reg; @@ -13152,10 +13178,7 @@ OP_EX (instr_info *ins, int bytemode, in bytemode = ins->vex.w ? q_mode : d_mode; if (ins->modrm.mod != 3) - { - OP_E_memory (ins, bytemode, sizeflag); - return; - } + return OP_E_memory (ins, bytemode, sizeflag); reg = ins->modrm.rm; USED_REX (REX_B); @@ -13179,57 +13202,56 @@ OP_EX (instr_info *ins, int bytemode, in ins->modrm.rm = reg; print_vector_reg (ins, reg, bytemode); + return true; } -static void +static bool OP_MS (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod == 3) - OP_EM (ins, bytemode, sizeflag); - else - BadOp (ins); + return OP_EM (ins, bytemode, sizeflag); + return BadOp (ins); } -static void +static bool OP_XS (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod == 3) - OP_EX (ins, bytemode, sizeflag); - else - BadOp (ins); + return OP_EX (ins, bytemode, sizeflag); + return BadOp (ins); } -static void +static bool OP_M (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod == 3) /* bad bound,lea,lds,les,lfs,lgs,lss,cmpxchg8b,vmptrst modrm */ - BadOp (ins); - else - OP_E (ins, bytemode, sizeflag); + return BadOp (ins); + return OP_E (ins, bytemode, sizeflag); } -static void +static bool OP_0f07 (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 3 || ins->modrm.rm != 0) - BadOp (ins); - else - OP_E (ins, bytemode, sizeflag); + return BadOp (ins); + return OP_E (ins, bytemode, sizeflag); } /* NOP is an alias of "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in 32bit mode and "xchg %rax,%rax" in 64bit mode. */ -static void +static bool NOP_Fixup (instr_info *ins, int opnd, int sizeflag) { if ((ins->prefixes & PREFIX_DATA) == 0 && (ins->rex & REX_B) == 0) - ins->mnemonicendp = stpcpy (ins->obuf, "nop"); - else if (opnd == 0) - OP_REG (ins, eAX_reg, sizeflag); - else - OP_IMREG (ins, eAX_reg, sizeflag); + { + ins->mnemonicendp = stpcpy (ins->obuf, "nop"); + return true; + } + if (opnd == 0) + return OP_REG (ins, eAX_reg, sizeflag); + return OP_IMREG (ins, eAX_reg, sizeflag); } static const char *const Suffix3DNow[] = { @@ -13299,13 +13321,14 @@ static const char *const Suffix3DNow[] = /* FC */ NULL, NULL, NULL, NULL, }; -static void +static bool OP_3DNowSuffix (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { const char *mnemonic; - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; /* AMD 3DNow! instructions are specified by an opcode suffix in the place where an 8-bit immediate would normally go. ie. the last byte of the instruction. */ @@ -13324,6 +13347,7 @@ OP_3DNowSuffix (instr_info *ins, int byt BadOp (ins); } ins->mnemonicendp = ins->obufp; + return true; } static const struct op simd_cmp_op[] = @@ -13366,13 +13390,14 @@ static const struct op vex_cmp_op[] = { STRING_COMMA_LEN ("true_us") }, }; -static void +static bool CMP_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { unsigned int cmp_type; - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; cmp_type = *ins->codep++ & 0xff; if (cmp_type < ARRAY_SIZE (simd_cmp_op)) { @@ -13401,9 +13426,10 @@ CMP_Fixup (instr_info *ins, int bytemode /* We have a reserved extension byte. Output it directly. */ oappend_immediate (ins, cmp_type); } + return true; } -static void +static bool OP_Mwait (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { /* mwait %eax,%ecx / mwaitx %eax,%ecx,%ebx */ @@ -13418,9 +13444,10 @@ OP_Mwait (instr_info *ins, int bytemode, /* Skip mod/rm byte. */ MODRM_CHECK; ins->codep++; + return true; } -static void +static bool OP_Monitor (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -13448,17 +13475,19 @@ OP_Monitor (instr_info *ins, int bytemod /* Skip mod/rm byte. */ MODRM_CHECK; ins->codep++; + return true; } -static void +static bool BadOp (instr_info *ins) { /* Throw away prefixes and 1st. opcode byte. */ ins->codep = ins->insn_codep + 1; ins->obufp = stpcpy (ins->obufp, "(bad)"); + return true; } -static void +static bool REP_Fixup (instr_info *ins, int bytemode, int sizeflag) { /* The 0xf3 prefix should be displayed as "rep" for ins, outs, movs, @@ -13471,48 +13500,48 @@ REP_Fixup (instr_info *ins, int bytemode case al_reg: case eAX_reg: case indir_dx_reg: - OP_IMREG (ins, bytemode, sizeflag); - break; + return OP_IMREG (ins, bytemode, sizeflag); case eDI_reg: - OP_ESreg (ins, bytemode, sizeflag); - break; + return OP_ESreg (ins, bytemode, sizeflag); case eSI_reg: - OP_DSreg (ins, bytemode, sizeflag); - break; + return OP_DSreg (ins, bytemode, sizeflag); default: abort (); break; } + return true; } -static void +static bool SEP_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { if (ins->isa64 != amd64) - return; + return true; ins->obufp = ins->obuf; BadOp (ins); ins->mnemonicendp = ins->obufp; ++ins->codep; + return true; } /* For BND-prefixed instructions 0xF2 prefix should be displayed as "bnd". */ -static void +static bool BND_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { if (ins->prefixes & PREFIX_REPNZ) ins->all_prefixes[ins->last_repnz_prefix] = BND_PREFIX; + return true; } /* For NOTRACK-prefixed instructions, 0x3E prefix should be displayed as "notrack". */ -static void +static bool NOTRACK_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -13526,13 +13555,14 @@ NOTRACK_Fixup (instr_info *ins, int byte ins->active_seg_prefix = 0; ins->all_prefixes[ins->last_seg_prefix] = NOTRACK_PREFIX; } + return true; } /* Similar to OP_E. But the 0xf2/0xf3 ins->prefixes should be displayed as "xacquire"/"xrelease" for memory operand if there is a LOCK prefix. */ -static void +static bool HLE_Fixup1 (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 3 @@ -13544,14 +13574,14 @@ HLE_Fixup1 (instr_info *ins, int bytemod ins->all_prefixes[ins->last_repnz_prefix] = XACQUIRE_PREFIX; } - OP_E (ins, bytemode, sizeflag); + return OP_E (ins, bytemode, sizeflag); } /* Similar to OP_E. But the 0xf2/0xf3 ins->prefixes should be displayed as "xacquire"/"xrelease" for memory operand. No check for LOCK prefix. */ -static void +static bool HLE_Fixup2 (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 3) @@ -13562,13 +13592,13 @@ HLE_Fixup2 (instr_info *ins, int bytemod ins->all_prefixes[ins->last_repnz_prefix] = XACQUIRE_PREFIX; } - OP_E (ins, bytemode, sizeflag); + return OP_E (ins, bytemode, sizeflag); } /* Similar to OP_E. But the 0xf3 prefixes should be displayed as "xrelease" for memory operand. No check for LOCK prefix. */ -static void +static bool HLE_Fixup3 (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 3 @@ -13576,10 +13606,10 @@ HLE_Fixup3 (instr_info *ins, int bytemod && (ins->prefixes & PREFIX_REPZ) != 0) ins->all_prefixes[ins->last_repz_prefix] = XRELEASE_PREFIX; - OP_E (ins, bytemode, sizeflag); + return OP_E (ins, bytemode, sizeflag); } -static void +static bool CMPXCHG8B_Fixup (instr_info *ins, int bytemode, int sizeflag) { USED_REX (REX_W); @@ -13598,10 +13628,10 @@ CMPXCHG8B_Fixup (instr_info *ins, int by ins->all_prefixes[ins->last_repnz_prefix] = XACQUIRE_PREFIX; } - OP_M (ins, bytemode, sizeflag); + return OP_M (ins, bytemode, sizeflag); } -static void +static bool XMM_Fixup (instr_info *ins, int reg, int sizeflag ATTRIBUTE_UNUSED) { const char (*names)[8] = att_names_xmm; @@ -13620,9 +13650,10 @@ XMM_Fixup (instr_info *ins, int reg, int } } oappend_register (ins, names[reg]); + return true; } -static void +static bool FXSAVE_Fixup (instr_info *ins, int bytemode, int sizeflag) { /* Add proper suffix to "fxsave" and "fxrstor". */ @@ -13635,13 +13666,13 @@ FXSAVE_Fixup (instr_info *ins, int bytem *p = '\0'; ins->mnemonicendp = p; } - OP_M (ins, bytemode, sizeflag); + return OP_M (ins, bytemode, sizeflag); } /* Display the destination register operand for instructions with VEX. */ -static void +static bool OP_VEX (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { int reg, modrm_reg, sib_index = -1; @@ -13657,7 +13688,7 @@ OP_VEX (instr_info *ins, int bytemode, i if (ins->vex.evex && !ins->vex.v) { oappend (ins, "(bad)"); - return; + return true; } reg &= 7; @@ -13669,7 +13700,7 @@ OP_VEX (instr_info *ins, int bytemode, i { case scalar_mode: oappend_register (ins, att_names_xmm[reg]); - return; + return true; case vex_vsib_d_w_dq_mode: case vex_vsib_q_w_dq_mode: @@ -13702,7 +13733,7 @@ OP_VEX (instr_info *ins, int bytemode, i if (sib_index == modrm_reg || sib_index == reg) strcat (ins->op_out[1], "/(bad)"); - return; + return true; case tmm_mode: /* All 3 TMM registers must be distinct. */ @@ -13729,7 +13760,7 @@ OP_VEX (instr_info *ins, int bytemode, i strcat (ins->op_out[1], "/(bad)"); } - return; + return true; } switch (ins->vex.length) @@ -13752,13 +13783,13 @@ OP_VEX (instr_info *ins, int bytemode, i if (reg > 0x7) { oappend (ins, "(bad)"); - return; + return true; } names = att_names_mask; break; default: abort (); - return; + return true; } break; case 256: @@ -13770,17 +13801,16 @@ OP_VEX (instr_info *ins, int bytemode, i break; case mask_bd_mode: case mask_mode: - if (reg > 0x7) + if (reg <= 0x7) { - oappend (ins, "(bad)"); - return; + names = att_names_mask; + break; } - names = att_names_mask; - break; + /* Fall through. */ default: /* See PR binutils/20893 for a reproducer. */ oappend (ins, "(bad)"); - return; + return true; } break; case 512: @@ -13792,16 +13822,18 @@ OP_VEX (instr_info *ins, int bytemode, i break; } oappend_register (ins, names[reg]); + return true; } -static void +static bool OP_VexR (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod == 3) - OP_VEX (ins, bytemode, sizeflag); + return OP_VEX (ins, bytemode, sizeflag); + return true; } -static void +static bool OP_VexW (instr_info *ins, int bytemode, int sizeflag) { OP_VEX (ins, bytemode, sizeflag); @@ -13814,15 +13846,17 @@ OP_VexW (instr_info *ins, int bytemode, ins->op_out[2] = ins->op_out[1]; ins->op_out[1] = tmp; } + return true; } -static void +static bool OP_REG_VexI4 (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { int reg; const char (*names)[8] = att_names_xmm; - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; reg = *ins->codep++; if (bytemode != x_mode && bytemode != scalar_mode) @@ -13845,16 +13879,18 @@ OP_REG_VexI4 (instr_info *ins, int bytem ins->op_out[3] = ins->op_out[2]; ins->op_out[2] = tmp; } + return true; } -static void +static bool OP_VexI4 (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { oappend_immediate (ins, ins->codep[-1] & 0xf); + return true; } -static void +static bool VPCMP_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { @@ -13863,7 +13899,8 @@ VPCMP_Fixup (instr_info *ins, int bytemo if (!ins->vex.evex) abort (); - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; cmp_type = *ins->codep++ & 0xff; /* There are aliases for immediates 0, 1, 2, 4, 5, 6. If it's the case, print suffix, otherwise - print the immediate. */ @@ -13896,6 +13933,7 @@ VPCMP_Fixup (instr_info *ins, int bytemo /* We have a reserved extension byte. Output it directly. */ oappend_immediate (ins, cmp_type); } + return true; } static const struct op xop_cmp_op[] = @@ -13910,13 +13948,14 @@ static const struct op xop_cmp_op[] = { STRING_COMMA_LEN ("true") } }; -static void +static bool VPCOM_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { unsigned int cmp_type; - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; cmp_type = *ins->codep++ & 0xff; if (cmp_type < ARRAY_SIZE (xop_cmp_op)) { @@ -13945,6 +13984,7 @@ VPCOM_Fixup (instr_info *ins, int bytemo /* We have a reserved extension byte. Output it directly. */ oappend_immediate (ins, cmp_type); } + return true; } static const struct op pclmul_op[] = @@ -13955,13 +13995,14 @@ static const struct op pclmul_op[] = { STRING_COMMA_LEN ("hqh") } }; -static void +static bool PCLMUL_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { unsigned int pclmul_type; - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return false; pclmul_type = *ins->codep++ & 0xff; switch (pclmul_type) { @@ -13990,9 +14031,10 @@ PCLMUL_Fixup (instr_info *ins, int bytem /* We have a reserved extension byte. Output it directly. */ oappend_immediate (ins, pclmul_type); } + return true; } -static void +static bool MOVSXD_Fixup (instr_info *ins, int bytemode, int sizeflag) { /* Add proper suffix to "movsxd". */ @@ -14022,10 +14064,10 @@ MOVSXD_Fixup (instr_info *ins, int bytem ins->mnemonicendp = p; *p = '\0'; - OP_E (ins, bytemode, sizeflag); + return OP_E (ins, bytemode, sizeflag); } -static void +static bool DistinctDest_Fixup (instr_info *ins, int bytemode, int sizeflag) { unsigned int reg = ins->vex.register_specifier; @@ -14060,22 +14102,22 @@ DistinctDest_Fixup (instr_info *ins, int && modrm_reg == modrm_rm)) { oappend (ins, "(bad)"); + return true; } - else - OP_XMM (ins, bytemode, sizeflag); + return OP_XMM (ins, bytemode, sizeflag); } -static void +static bool OP_Rounding (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) { if (ins->modrm.mod != 3 || !ins->vex.b) - return; + return true; switch (bytemode) { case evex_rounding_64_mode: if (ins->address_mode != mode_64bit || !ins->vex.w) - return; + return true; /* Fall through. */ case evex_rounding_mode: ins->evex_used |= EVEX_b_used; @@ -14089,9 +14131,10 @@ OP_Rounding (instr_info *ins, int bytemo abort (); } oappend (ins, "sae}"); + return true; } -static void +static bool PREFETCHI_Fixup (instr_info *ins, int bytemode, int sizeflag) { if (ins->modrm.mod != 0 || ins->modrm.rm != 5) @@ -14117,5 +14160,5 @@ PREFETCHI_Fixup (instr_info *ins, int by bytemode = v_mode; } - OP_M (ins, bytemode, sizeflag); + return OP_M (ins, bytemode, sizeflag); }