From patchwork Tue Apr 4 06:58:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2822082vqo; Mon, 3 Apr 2023 23:58:28 -0700 (PDT) X-Google-Smtp-Source: AKy350Zs2dEP3YjGP1IvhFsSdANhvkO6EQ7munothiMNUfNe/jrPpNHg3iBOcx4YxUxoGi5TGV0n X-Received: by 2002:aa7:c684:0:b0:4fd:247a:9873 with SMTP id n4-20020aa7c684000000b004fd247a9873mr1305618edq.5.1680591508781; Mon, 03 Apr 2023 23:58:28 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m8-20020aa7c488000000b004fc4b73c1b8si2025907edq.300.2023.04.03.23.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 23:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TYvRVCHr; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B67E53858C31 for ; Tue, 4 Apr 2023 06:58:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B67E53858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591507; bh=wphEUJc9C+M8Djc6qKOG+Td2+tHWMNEpZ+i21HIxLcM=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TYvRVCHrMN6UkJ27FTq1eqlLQc13OqB5jr3w0z9rrAdI4La2hkFdX/P2zrJbRSAdX peOhIJ+jlurlqaaHTxAPf7yIP18QJRM4DTgUfmaIvHMRcTSIgHXnzQLbcg7gjQGv/6 ELzA7tJ9vV10rk9zJENxNtoTqhKqOJZSxiBMiqGs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2048.outbound.protection.outlook.com [40.107.8.48]) by sourceware.org (Postfix) with ESMTPS id 35AFB3858404 for ; Tue, 4 Apr 2023 06:58:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35AFB3858404 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cpdVpiLbfw8/ZYwCR35asoFfPejJaxNClMrkLWWLSoABjEF4J2seVnQlFPkf47mbdNNPmL+2YJ9lPEYIowDHBgBv1MVvyH//yzPI0Yf+2D574TZNgwYe9nCtpikEXuRJEVZbnNv/nJ3yY4OGMf0pzA1CeIkfFAbiljqA1Ic+S3rq9nyYJrzU85XLcMr1ruCm7YaVdMJzeBaJ02JeT9zjRqPMOR4u8BcCKJmsBbntpsRgCTXw/XSAeRU+HK65kAdfUufPIODSnr9D3vj0cjWMaAQkx9Xml3OOI9foTLzIwHLtsV2+HeoNtoNRWQJOcbjnWRikmRrNWfAyN008Cco7iA== 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=wphEUJc9C+M8Djc6qKOG+Td2+tHWMNEpZ+i21HIxLcM=; b=S+vN21WXhj7lOixJq8FftOfs28xiGpvgf0bmIjNP/q5ObAWYLaN4PO0QWdFf0H+EEKuyj0CzQYG0+6eX0ZTkMAnF0/Md4A0Vx96tsc8uiPUD6DqaWXH7ng0uNk889qefh+EkzJHoEDA2iuyQ6UMATgn2NObaV8YkwoOnVkykU1crkK5pyJQqx8ZU4ql9oolOu3EhZCDYfDFsX6M4DMC5Vy+kblSZB8qj1SkktfcdNSjRVwwhFufeGb8YPyeO2Qu1LdwYE5nAFOBPjFEIRztuaLUh4r3PuPjghkNVLv8Dq0sLWfkIe6iT2XLQJxkH6yziUIxkR0NhzrGiaseskdlwjA== 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 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DBAPR04MB7447.eurprd04.prod.outlook.com (2603:10a6:10:1b2::14) 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 06:58:16 +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 06:58:16 +0000 Message-ID: <9b770800-dc80-2c00-40a2-903cbe4ffb8c@suse.com> Date: Tue, 4 Apr 2023 08:58:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 1/8] x86: move fetch error handling into a helper function Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR2P281CA0011.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::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_|DBAPR04MB7447:EE_ X-MS-Office365-Filtering-Correlation-Id: aac73850-88c5-4b2e-db97-08db34d9f761 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YTcTx8C9bfVlZm9N1qlIadrRLIY3hpNjGbdhmEi6OgYLIqMwFFgcuj8OG05Un2v2yYnp0hCaVC7NYzF5U7GrgSpQG7SChn2ftr1oW1jIVjWC9K2NEW3+0BN0kU9cBUXJYEOXH4ElZzZZ9vLvpKPPaXnaOAH48N8UIiONgOd6XgEdTMh8nohm/FrVhOgv9UPGiC2/2wyy5/I2usKaGVyAFZinu8z+lG+O3Eb5SP+xSBUzv/CohVTNkeMTpk/ZkpqyuWwNa/Z0DM5OAYQhEDdlhBV8ULHHR3xBi//3sfjKkFttP7fzZUdcN7PblcAjjfe3wktFwjeTKoPDP/sLsiOYyVV2/HERL8kg/BzVxShYElZmxuPJOoNhdu+EjvewUxoOgiAlQvtIkow6kkp4X/HfJMDiLq+v89Tpki8hD46FPTJftZl/DilEXzjsux+jwZucIi4H+QXhvMJlr4xIiMNM+KeRkJf0eRwsbdErhRaL6hJ2CdZ3V2G90AvkudOfyQZnAC0srjc8wbEc/l5g+i/4YKTWHNhQn1HFbdz7pGaA0i3YT3QpjF4cNJkHbDwVzR3Dh6YCziJQkofEYRriTUvwqNXvaEES6zq9nrUSoXWEtPbKRoj+qVx7Q3nt9VQay8bhWi3S4e4yaQUAnJc/Ps85uw== 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)(376002)(39850400004)(396003)(366004)(136003)(346002)(451199021)(478600001)(316002)(54906003)(8936002)(5660300002)(36756003)(86362001)(31696002)(2906002)(4326008)(8676002)(6916009)(66476007)(66556008)(38100700002)(41300700001)(26005)(6506007)(6512007)(66946007)(6486002)(2616005)(31686004)(186003)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RryhU32Imx3CrdFINiR5SwhB2A86?= =?utf-8?q?b8MSvjqTOKz9ScKRjwyB54Xj31e2uc9+XxAAZ1b0CWQN4FImDyo4Sngxc5c0F+cmF?= =?utf-8?q?7uGDf2rbSlsim9NoRN+XMM4qpTFSUg5nq/Z0DI9+5StT0Vj0GBRk85KvNy0vSufTx?= =?utf-8?q?69sfsOQkY2VLg8qyjFSoftKh9Y1o4HiBYCXxAxt3yWO5ssyn9K4x1CPQC2063FfMn?= =?utf-8?q?NJxMnXqV/uLOhAG7PZp8AR+dnKxwRZVw2/+o8VsunLNYFxa+EeP5r7qZ3qSNCnFc9?= =?utf-8?q?f2huXBGmDdO86Os8LZcneLFnv4walaU1U+LfyGDXQNO4omi3cfPpfrcpQI7X0c/6J?= =?utf-8?q?wLcsgU36HVB+8rE136dZ1/mLQuBX3gXNd1QJnjZSj+7TcpMuducEeUmTTs5IOlCsv?= =?utf-8?q?03Q9+ZTIp+fQvik9DLtI2ldgIy+9lThdfl5oo6WrcPfeXgXLcvd/BAZAiHJN/oMhT?= =?utf-8?q?Q+6SXwWjs6ra+UzrSmdr2bPYRC3/CuCFOCRauLrwqRlJRVf3yV5Se75KrFQjWlKAz?= =?utf-8?q?cv+/xMOPY7dFs29AUDcDfn0olCE95wgI7lcRkL292RI99iLoUuKUJBTHSaSl/PlH3?= =?utf-8?q?zYx46RArgiwbqnk7MDSqmUUWrp3E66b9626zFiC4lRkzmey45L4dJ1e+x5ZOwC4Rh?= =?utf-8?q?9XETRGjdEVPYB+RaPmYnpnczsN8Vf5NIth1gmCtRYcrxbTNIxbFxMo5Gtljc4l3ld?= =?utf-8?q?ag765oPrmOIeWrxqwyV1eeg0OIN+Xh8niQoO6V9SlyCEeId0gaF+Bpkb4oyBTih59?= =?utf-8?q?pa/3Svrd4bt2opEtSyqjC9kkNLXhll6MACPnt85u3nbAZL5KUnfSfXlBQshcJJMPc?= =?utf-8?q?BG2yTULXF0Nt5l55rkB+UoJWkF8NCSvfiIdG6iSGuO8JequaF8iULt5f+NXe7Pr2s?= =?utf-8?q?6c253K3bJpqsYGiqWYWJISfHRrJRtn2SEJA/VJCOUrynHwbgwgSYUJWIypHTpz7M1?= =?utf-8?q?kiD3ilYwzDFTmMErFw4HHlzA5C4Cn06BY2tJExNFeGZh0/AZuwfX833GZtazT5aqW?= =?utf-8?q?rslnKKXd+2V9xKdJWX4QJy6pI0CT8Ci1sWHJeWUMje0dUJwGgYIdaikRbpVxbkjlL?= =?utf-8?q?L96gFgw3MQfPZ1HC+H/nnFJm7bk+rIzBkYuj4tJM06Z0YmA5KY2gdydMBqH31Xzex?= =?utf-8?q?mGQ9zygm6dBCIDboSX1l7fw1bpNzpnbiEwDo99gqUOOaCHIZ1J/6sLOD5LYJiuznm?= =?utf-8?q?tacNnOSUOJMtm0fMlctzs2o+Iqn/Sg0M0YMqA6QNq2gnct9lXqHXm5IW6Ps0f8uiX?= =?utf-8?q?vH+fF99wLehbIXW7AsHBQx7ezh2HKp8eHv9rqBHkVw+X1Xgda2fu4fLVeSFqddI6w?= =?utf-8?q?cFjhs5FUKMxZncYPQUqA7wBbGhrVEW86nKU3ZEGnT//YspLUTAZMCUomekn0eQpgQ?= =?utf-8?q?34xvXHhkuqrGsMzjfaCeb8bWkpaSrx9uHapKM1F4hkvy4jCBmrVAt2NoK3Q2VJVe5?= =?utf-8?q?EGGAL5iVg1JmpucQCBbKSKyC3FpLIa+7Egjk6pbMx4FAIcH3FubgFAimQiFRO5X1L?= =?utf-8?q?4+kqJljQpvZs?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: aac73850-88c5-4b2e-db97-08db34d9f761 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 06:58:16.8471 (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: eDdF594B2xJq65bJWPB5+fr6SkZvfAt9I+hyDUFYCLaa3o1zKtAnIQjJ6c2OTISQkQzeAbWhoZf2x218w1hLxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7447 X-Spam-Status: No, score=-3027.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762227921637993372?= X-GMAIL-MSGID: =?utf-8?q?1762227921637993372?= ... such that it can be used from other than the setjmp() error handling path. Since I'd like the function's parameter to be pointer-to-const, two other functions need respective constification then, too (along with needing to be forward-declared). --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -116,6 +116,11 @@ static void MOVSXD_Fixup (instr_info *, static void DistinctDest_Fixup (instr_info *, int, int); static void PREFETCHI_Fixup (instr_info *, int, int); +static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const instr_info *, + enum disassembler_style, + const char *, ...); +static const char *prefix_name (const instr_info *, int, int); + /* This character is used to encode style information within the output buffers. See oappend_insert_style for more details. */ #define STYLE_MARKER_CHAR '\002' @@ -324,6 +329,33 @@ fetch_data (struct disassemble_info *inf return 1; } +static int +fetch_error (const instr_info *ins) +{ + /* Getting here means we tried for data but didn't get it. That + means we have an incomplete instruction of some sort. Just + print the first byte as a prefix or a .byte pseudo-op. */ + const struct dis_private *priv = ins->info->private_data; + const char *name = NULL; + + if (ins->codep <= priv->the_buffer) + return -1; + + if (ins->prefixes || ins->fwait_prefix >= 0 || (ins->rex & REX_OPCODE)) + name = prefix_name (ins, priv->the_buffer[0], priv->orig_sizeflag); + if (name != NULL) + i386_dis_printf (ins, dis_style_mnemonic, "%s", name); + else + { + /* Just print the first byte as a .byte instruction. */ + i386_dis_printf (ins, dis_style_assembler_directive, ".byte "); + i386_dis_printf (ins, dis_style_immediate, "%#x", + (unsigned int) priv->the_buffer[0]); + } + + return 1; +} + /* Possible values for prefix requirement. */ #define PREFIX_IGNORED_SHIFT 16 #define PREFIX_IGNORED_REPZ (PREFIX_REPZ << PREFIX_IGNORED_SHIFT) @@ -8975,7 +9007,7 @@ ckprefix (instr_info *ins) prefix byte. */ static const char * -prefix_name (instr_info *ins, int pref, int sizeflag) +prefix_name (const instr_info *ins, int pref, int sizeflag) { static const char *rexes [16] = { @@ -9576,7 +9608,7 @@ oappend_register (instr_info *ins, const used in the next fprintf_styled_func call. */ static void ATTRIBUTE_PRINTF_3 -i386_dis_printf (instr_info *ins, enum disassembler_style style, +i386_dis_printf (const instr_info *ins, enum disassembler_style style, const char *fmt, ...) { va_list ap; @@ -9804,32 +9836,7 @@ print_insn (bfd_vma pc, disassemble_info } if (OPCODES_SIGSETJMP (priv.bailout) != 0) - { - /* Getting here means we tried for data but didn't get it. That - means we have an incomplete instruction of some sort. Just - print the first byte as a prefix or a .byte pseudo-op. */ - if (ins.codep > priv.the_buffer) - { - const char *name = NULL; - - if (ins.prefixes || ins.fwait_prefix >= 0 || (ins.rex & REX_OPCODE)) - name = prefix_name (&ins, priv.the_buffer[0], priv.orig_sizeflag); - if (name != NULL) - i386_dis_printf (&ins, dis_style_mnemonic, "%s", name); - else - { - /* Just print the first byte as a .byte instruction. */ - i386_dis_printf (&ins, dis_style_assembler_directive, - ".byte "); - i386_dis_printf (&ins, dis_style_immediate, "0x%x", - (unsigned int) priv.the_buffer[0]); - } - - return 1; - } - - return -1; - } + return fetch_error (&ins); sizeflag = priv.orig_sizeflag; From patchwork Tue Apr 4 06:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2822264vqo; Mon, 3 Apr 2023 23:58:56 -0700 (PDT) X-Google-Smtp-Source: AKy350au0mKAy0TbZTIThVe22wQCAdMwLFO/lurJjvlfyeuJ3wrT2G1wApnm+5idVCFvFbAKN7nF X-Received: by 2002:a05:6402:1a46:b0:4fd:2155:74ef with SMTP id bf6-20020a0564021a4600b004fd215574efmr1696721edb.19.1680591536100; Mon, 03 Apr 2023 23:58:56 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f11-20020a056402150b00b004ad0affbc61si9685877edw.135.2023.04.03.23.58.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 23:58:56 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=f4VBaUgz; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43E243857C55 for ; Tue, 4 Apr 2023 06:58:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43E243857C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591531; bh=7r3EWOIslWOeZHq6SuMcKDG+GgDVfhmCtYlIy2vF2CU=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=f4VBaUgzyX3YycTVprQHa+hpDQ4MfpSXSG1DCdZQ56ukNmEjRPzuTzy6fCeFIZa0W PYxctoNgOvsiDXZZxWhGL+bSB2faTnwQzIIWEMbycOZVCRZYtB80lM/jazqOILjdfM nMz9NA/Z0ypJn+v62SvwENVTY/DG3/X5+DlkAR/Y= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2068.outbound.protection.outlook.com [40.107.22.68]) by sourceware.org (Postfix) with ESMTPS id 4E4573858C2D for ; Tue, 4 Apr 2023 06:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E4573858C2D ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcWHheIq+7FlJMtStC2Mh3nzcCk+05kFF34oMwjRWjFCvdiYOvdLl0WEhYEhZSFH5Zcvd6/r3tQ1my6CjPO7H2hQPMkW2IcsClFKk6pxXbV2g9+ejRcZ1MWf76Ysh8eo/MeQdfDLdlUwerJvnDfxDhaZsaqg2zmyM3KOJLhqrhZ3OIDa6QBX9xcZwSDfnFs+WLoMksv/qaI+cbVOHEepcSM/fvU7KzPsevIacOCK3I9LRs2XLHsx4uraEbfQeR+W9dYel8lmvcsqV0V8HyE8ubq8kxGcTnt2XDP1Y3REMCEuDN8uBHQII9gueC03bXUf5kYMxpiDjBBAg61irF5TUg== 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=7r3EWOIslWOeZHq6SuMcKDG+GgDVfhmCtYlIy2vF2CU=; b=DWzavH18D6kfwMjIYOkGUnP17u0d9RQFPkcfdtq1nmQGridq6/OpiuyBZIB6gd1LVCvM4xIMLg/PIGQX2UoKpwy8YRZjqE5GV8bD73U+mGOZrlkRrBzlPu4yApYZ1DyMCCdh63i+KwgEJiVTWQcl+xe5Qhg+1Nx57PuPiRvUgX+NDOW5JI8d183vgI1pCSaLfPf1VUEjnFfcXv62BSOiy1ht2g3yrlyRZ+m0//JZJrmnw6Lm/ZuZUiBlR+xvlffI/EYSY3vtFrb8SUk9+x09K1qKiXzv0JT086ajfdq67mz15ZruXwv9t4P38iynx139enJ7RmC+nRTdUFLmflBQEg== 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 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 06:58:39 +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 06:58:39 +0000 Message-ID: <39b50a10-ad10-aca0-2ef1-4d32be787762@suse.com> Date: Tue, 4 Apr 2023 08:58:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 2/8] x86: change fetch error handling in top-level function Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR2P281CA0006.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::16) 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: ac936a9b-5187-4099-16d1-08db34da04c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dTGbV93EOMs7PJXnvljr57BT3WH8AYU/58IC0JX4ssT3njujCN6ZJs1fhClo4EZSo9Q4rAxQMYTZ740GvegomOZ7FW7xucjQaYY6mw15nIo82uMtXxDLnd91McLkdm+TICD4dwF6c21toajlg9SSzIwbv3QYpxxv7ieBmujEdmW9wV+6S1ec0RrxN3RgAi03B2dBD0hei3fihqIkm+O2mXAtGNAjXEjk295QYu3W5CZIu61ljmvDywVL/av9CovgYAH+B1YVTBPFJUU2g2DsNMrPJwJ4jvLbk4uGO2dT/Y6EdFql8fMSZRy5RI6eo2Zz9HPxSFImxzssnkubDdOjomGCWYOh5aNfjHi1IhW5sUOadO83zckEXcl0QTONut5i27lEvrfXPYnk8H8EIsPk+meKzggRDmhdLnJ2veG837KTJ+ewEWhvv1qrh2b/m64PoAMr9sYH7i8622ShZRQ75E9vUNaogJhSKbIws6aYJwwvieV4JKYlWL4nvMw4C8hfpvPC5My6DNlW6mr/Mmgb5+2l//vLStYI2J1k+0+5/maW1CRuXoSnn+5MhLu1Fja09uGuvmobt1yPzAmdl+uyTvMraVt3NgJdJUHhQHi42XurPbKvhxo5///UGFKgPf9z 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)(2906002)(4326008)(2616005)(966005)(31686004)(6486002)(186003)(6512007)(26005)(6506007)(54906003)(316002)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JXXzfV51rmdM5TXCDO5Afu5FVHyX?= =?utf-8?q?3IJnDiy6Zlwu/7cGAcFJ25w01+3PxXriA4en4Zdh/fyXoPprJyteSyThbbcs/EK2L?= =?utf-8?q?I3A6ZWCv6xUik42yO2tdX1NBJSqN5TpXEA4EJng96XZF3OYd1MeIw+SlodfkRriw6?= =?utf-8?q?z4cq+oykdLdN+kNxq52pyF0NlthYp9uO8tRPjEilWUlxD87kYTMsiM6N591/dEP9l?= =?utf-8?q?nwNjC2tvWR3Cj41rSdLGKzLFZJOG5xbKRHYHiG7ut50XNTlo9mXOW/FHuLOqivCmA?= =?utf-8?q?4qkspS+nO9PXCDcx+Ks05itMflHLVNYf3aYrbs1qyfZTypJf/DmB3WHrDv/fp67mC?= =?utf-8?q?NAX2/UqrXWf5qOtxKEO/meHUYoTQAcYIgw/szP8rO2ff/VjNDyuu/rZW8ORSbhC52?= =?utf-8?q?0KJBEjM3xN3wTpN98VnWH0TOGMKzVkygssTPM70WkZMk0oXHxBJ3VbTmAig+ZYLZ2?= =?utf-8?q?7jZHh7JQtF/py0qiBO/93dZhVSSDzkePTCVT1fLQt32hDkAnCG6PyIh4AtzwnFe35?= =?utf-8?q?8VBqsZLI5mav/CWNXzGKjIg/metwEGAbqyH/dr05gxUB/u2gy1UIndAn+Mw2vZqfk?= =?utf-8?q?TrC/b4infEj7cG7sNCrvMc36qjh+UdY2tok+1fPn0HsLchmidZd774OCJHkbMbWzA?= =?utf-8?q?C5hm0F8mM9R/Gn2JkQjJfu7BjoCrjZHGrvpZvK4x5tLneKyI/Jmmo9EQM5cFfXDbH?= =?utf-8?q?8SOy35NudmKDdBrydrmmQ/wnVBOg8Atu82dbRdfASgLqHSWR5Zl464JS9aS+rHKWW?= =?utf-8?q?VcRv5hqVxAJtqMEJ94d2Z+1+5YiRSoRpea6k197JPMdlp0VLeL0fPRScbMI1wq/8e?= =?utf-8?q?A45PPPWVIJhmayzf5jmgaKGPmrrPqZw1YJtvUyC4Wf7YtOyC9YbYGlYksPA6TMFc7?= =?utf-8?q?8xfFFdo89uJaDYs/6yWPe9Y8fyFkaYkYAMjoBLLHa+Vl2YdQctPQsXlVyVOcEod1y?= =?utf-8?q?InBAcNjJ0FI8Io/cJDladfEDVqkO+LHrnik2Q7R0a2i/g8QFDzWtE3xgJMKK5QvVK?= =?utf-8?q?Pw+yHAxyCC19D55ELxDPM6be1L4nDuGgpdZJTSSbxvp/xfA4DJcFTub0K/NE4PuTE?= =?utf-8?q?Qy2tc0Dp/LqXybBR424zgYYb38BIXoHrKceCpFZGIAQBCxW6o7Q4lMaqp22RXY4kf?= =?utf-8?q?n++J/JntG+6+eLLvRCMz/HQmEjuJxtIoc7Qum4OTazVmUqVGCZ90JWTTpIwcrLno6?= =?utf-8?q?F43F6uK07ibHAtcAUZzuga0Y/esltPBl3BkIEeFUJTPfkiZnDQe09oDqmI1zV6U+q?= =?utf-8?q?BR1Z4OURskoAmu0J4NdaCyjgZa2sl4u1uNl1R9GuqnZkz72HL9Q7ANPksAeFzkBxA?= =?utf-8?q?vZrILRLuIc7vQDVaeVrzccb17Ll1PELfmepDuP8GcOF+WzYv0bUghGYbS/ed8L+Br?= =?utf-8?q?VuYWDTKPpPz1R6oCAyxjoFK7kjZLaM101rBMYA3JSUh/1S+LFJvb9aXxqyEbVK/6W?= =?utf-8?q?OgLaZivHhzRZ3gPhaTgZLllMCvpGg7r967OYUrvIU7SMXSCPteoZ8r11oX9vuSz8p?= =?utf-8?q?vDcI8+nUQXP7?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac936a9b-5187-4099-16d1-08db34da04c6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 06:58:39.2035 (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: GGMTn1a8aj8h4oHIfSzLsMQMgjZauGjgCRnXe42BuOUT1KlGjFJXxMRwjaNfH7+oRRxJBXsUisHnkc+rxYpaQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7314 X-Spam-Status: No, score=-3027.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762227950310942302?= X-GMAIL-MSGID: =?utf-8?q?1762227950310942302?= ... and its direct helper get_sib(). Using setjmp()/longjmp() for fetch error handling is problematic, as per https://sourceware.org/pipermail/binutils/2023-March/126687.html. Start using more conventional error handling instead. Also introduce a fetch_modrm() helper, for subsequent re-use. --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -329,6 +329,49 @@ fetch_data (struct disassemble_info *inf return 1; } +static bool +fetch_code (struct disassemble_info *info, bfd_byte *until) +{ + int status = -1; + struct dis_private *priv = info->private_data; + bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer); + + if (until <= priv->max_fetched) + return true; + + if (until <= priv->the_buffer + MAX_MNEM_SIZE) + status = (*info->read_memory_func) (start, + priv->max_fetched, + until - priv->max_fetched, + info); + if (status != 0) + { + /* If we did manage to read at least one byte, then + print_insn_i386 will do something sensible. Otherwise, print + an error. We do that here because this is where we know + STATUS. */ + if (priv->max_fetched == priv->the_buffer) + (*info->memory_error_func) (status, start, info); + return false; + } + + priv->max_fetched = until; + return true; +} + +static bool +fetch_modrm (instr_info *ins) +{ + if (!fetch_code (ins->info, ins->codep + 1)) + return false; + + ins->modrm.mod = (*ins->codep >> 6) & 3; + ins->modrm.reg = (*ins->codep >> 3) & 7; + ins->modrm.rm = *ins->codep & 7; + + return true; +} + static int fetch_error (const instr_info *ins) { @@ -9573,7 +9616,7 @@ get_valid_dis386 (const struct dis386 *d return get_valid_dis386 (dp, ins); } -static void +static bool get_sib (instr_info *ins, int sizeflag) { /* If modrm.mod == 3, operand must be register. */ @@ -9582,7 +9625,8 @@ get_sib (instr_info *ins, int sizeflag) && ins->modrm.mod != 3 && ins->modrm.rm == 4) { - FETCH_DATA (ins->info, ins->codep + 2); + if (!fetch_code (ins->info, ins->codep + 2)) + return false; ins->sib.index = (ins->codep[1] >> 3) & 7; ins->sib.scale = (ins->codep[1] >> 6) & 3; ins->sib.base = ins->codep[1] & 7; @@ -9590,6 +9634,8 @@ get_sib (instr_info *ins, int sizeflag) } else ins->has_sib = false; + + return true; } /* Like oappend (below), but S is a string starting with '%'. In @@ -9854,7 +9900,9 @@ print_insn (bfd_vma pc, disassemble_info ins.insn_codep = ins.codep; - FETCH_DATA (info, ins.codep + 1); + if (!fetch_code (info, ins.codep + 1)) + return fetch_error (&ins); + ins.two_source_ops = (*ins.codep == 0x62) || (*ins.codep == 0xc8); if (((ins.prefixes & PREFIX_FWAIT) @@ -9874,7 +9922,8 @@ print_insn (bfd_vma pc, disassemble_info unsigned char threebyte; ins.codep++; - FETCH_DATA (info, ins.codep + 1); + if (!fetch_code (info, ins.codep + 1)) + return fetch_error (&ins); threebyte = *ins.codep; dp = &dis386_twobyte[threebyte]; ins.need_modrm = twobyte_has_modrm[threebyte]; @@ -9897,17 +9946,13 @@ print_insn (bfd_vma pc, disassemble_info sizeflag ^= DFLAG; ins.end_codep = ins.codep; - if (ins.need_modrm) - { - FETCH_DATA (info, ins.codep + 1); - ins.modrm.mod = (*ins.codep >> 6) & 3; - ins.modrm.reg = (*ins.codep >> 3) & 7; - ins.modrm.rm = *ins.codep & 7; - } + if (ins.need_modrm && !fetch_modrm (&ins)) + return fetch_error (&ins); if (dp->name == NULL && dp->op[0].bytemode == FLOATCODE) { - get_sib (&ins, sizeflag); + if (!get_sib (&ins, sizeflag)) + return fetch_error (&ins); dofloat (&ins, sizeflag); } else @@ -9915,7 +9960,8 @@ print_insn (bfd_vma pc, disassemble_info dp = get_valid_dis386 (dp, &ins); if (dp != NULL && putop (&ins, dp->name, sizeflag) == 0) { - get_sib (&ins, sizeflag); + if (!get_sib (&ins, sizeflag)) + return fetch_error (&ins); for (i = 0; i < MAX_OPERANDS; ++i) { ins.obufp = ins.op_out[i]; From patchwork Tue Apr 4 06:59:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2822565vqo; Mon, 3 Apr 2023 23:59:43 -0700 (PDT) X-Google-Smtp-Source: AKy350YZhPGMtm2jZukzQkrV4oFgr7vR0GFGBrG5xcYCtkrQh3chW0LQ4gl38Bn9TXC6+btwbSSo X-Received: by 2002:aa7:d685:0:b0:4fe:9555:3a57 with SMTP id d5-20020aa7d685000000b004fe95553a57mr1605609edr.16.1680591583796; Mon, 03 Apr 2023 23:59:43 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h24-20020aa7c618000000b004ace3a42dc2si8009430edq.356.2023.04.03.23.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 23:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qyNmaGqP; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 806933857B98 for ; Tue, 4 Apr 2023 06:59:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 806933857B98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591569; bh=3/FEpWQoX23HW0mjOBTl1yQ8i10DXSBWgbFoyV08I0I=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qyNmaGqP0lyh2nnVPOFLLNTMwhmAAjHzXWf310nJW0p4LuzDSMT7J74T/8mMC+3PU pQGVCpUZiIwXbfGa4LMQbwuaDIZbZmzVasBkHssmusTyAU4e6glF4/M70TsYOfwV+j sHx1xXusqhui/UbA2/OOJcyk7m0k+nl33rWUZMAk= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2078.outbound.protection.outlook.com [40.107.249.78]) by sourceware.org (Postfix) with ESMTPS id C860B3858418 for ; Tue, 4 Apr 2023 06:59:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C860B3858418 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SncJAvHHUPm2t/degIIOjTngZaLqgz5Wu7+B70vvyqROfl4k3iY6b3OxVKAwvv/djVNEsJYBcl29E9bfUTsYuLG2zRsxAPvghaskapH6NHBoou8Cjv3EQ293N8WCuzeiA3lNdXgiomZ7AeFwbDmELn71unNF+94gXXT1NfsfYjQAp94kKTyDSjXTHWk1j7OQKjiuHbL6r6TbdotfYQ+iUiLfvxDbdFOSLUvj2W07gwyux3bygJlQZnhy0qRADPD04V8X7UiI6+CV1CMFSXM7LISPNnVGqcRzMXH2aKmj9TP5ekXncJOaIJy0OWTVfOlOAN6W3ZvId9tX+HIOswSSlA== 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=3/FEpWQoX23HW0mjOBTl1yQ8i10DXSBWgbFoyV08I0I=; b=Iad2rKHLdb5bMT4HeE6VYXJISYlsygyvYB1/5nSE4wgyrSnrkGjkP0vrHfgeLWaRX9JZKG8sjWU2LuQCiS0G3eSNbdFcwjVxHmRgCn/tVs2fuP8/kXNV+btUrSI+FJNNOR93XxIU1dNpf7w8UG1lizds5H1RfQZ/Us2az3iNCDj5UpCPocYVtiuNrcmFIJ+8ugoeC0wRWTRrg+YeLbp+9jx5HBFbWIAEnCM8f+w56RxmwakZuNwkPT7Xs5iB006OgtNUIvfkfbXUedIu7JplIG4edpZMosEtGGCL23kRGtx8EhONsRuotUi8H26k/7S2UwQiMho0g5YyApokBrCNiw== 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 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 06:59:19 +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 06:59:19 +0000 Message-ID: <838292bd-8855-00af-59c8-fcf0acb34d5c@suse.com> Date: Tue, 4 Apr 2023 08:59:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 3/8] x86: change fetch error handling in ckprefix() Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR2P281CA0007.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::17) 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: d32b30b1-b33f-48bb-0de8-08db34da1c77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VDBWqfJeIk8Tq6s+quLbeKW35UeHQ0cRQyjo0LNaNBJoV3lz+VPuzCyS2NUapKmvRiwQ21odqxW6+8A2x0djjvGTe7qjET1p5AoUKaI2sbIZkRb+6qNN4tHH5zHpJq+f9n/F8CpD/2oBgYY4JPDxVggCoN5JZBOUEThzRWvHpvSK00QWDNMqryt/jC0gjHFEvi5J54xZT1/4YZrLIoEloPnIgNhQh6J3HnsfkHAJ5OptI8khVkaofLfqvO+KivPNbiB5SB/R1Jwg7aUIJiR09dv1rNj7znm5J3zgM0fBRrnaWFHdfgLpiol1/Ip0Te8zKuhluc0b5kqs7XYzWM2+0udlMqCjJH+oqMdPGQi1BtoeCMEYvOvAunKjpmC0gYGlvOlY7MgQHmqKSzPgH/7CSZT6OANdUHsI/bVnww6PXuRlk/12IbD0ajoeEvQFEIPFs2fIuQu68YQ/19xDR8YcQ0ShRFV1deCrp/SFoafNYHMqSUuVr6+vECB/8N2gQqBalr74Klkus4g2CRqsPV6GyG4/hsxLQlk+XoU3qYxYAfE6Q8WE98sjUxoSSmuM8HwDJFkydpuGfeySDHDLNNwyP53PisPG0IaMHY67sm1jstjhzgxuyU1lWkjs/JpUB6b6tri9vR1tKDtdD6tmQ433mA== 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)(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?q?vrawmAQylDN1ZUZoFuZpYrreiiZn?= =?utf-8?q?3M5Q9uvypxvqmW2EqySOOUtch5fhik/eI38mGVWStgufHxiy5cxBuBr+bage1odB9?= =?utf-8?q?qXjYzxQf7w9T7hxjGzrrwFP+qf2GTl+IpxiLrFmqKBHaqGpu0NLALIXuLzgbl17+k?= =?utf-8?q?1pNpZcCnC4FhXfGMR6S8Um0VAD9tjiBcyraFSOY9XDEuC7qhU7APPzqc5c2YFl1sT?= =?utf-8?q?jYFKiKq717TKptkONJfqjnLQzjLoEpvQgg1f3QCyRkcgdhuqyGUkMD5V/sYSW+IHM?= =?utf-8?q?rmtOWDNgilH4mXBnEFjSXubifrguLG6o7p00WCon7s5Y0K77iy6Ouam+PfhP4MXtJ?= =?utf-8?q?NZKmuKU0u9iUzp7p+sq7uwXfniHHwHYCsuM7jcjDNJtqaiv0CDnJbiwkXF1/lao9z?= =?utf-8?q?a7YnFWHgx2+D+RPNCZ7+8K/UE3k5P37xsDtMmtYfhS5WS8OQbnwasgJpleWhgImzP?= =?utf-8?q?fuhkvTLnH0Fauu40YNMOT0zroPKgs2l0q2NUDqc+LulFdvKN2hc8TkVoiCSXUrL82?= =?utf-8?q?Kd0+NKLmRW2EYwvL7QJ2tubek7J214nNlel3SrmlDJ/drlPyVJwuwxvxdBxrvAzrH?= =?utf-8?q?xAceJv0CGQ+Y+UlVZiLfX/a7+QEwLJSanzWrdL7PqLHO0doBiWOmr0vigtZz0Ia5c?= =?utf-8?q?OH1Yhi6UQ8ZattiixVb8fd6zcbJb8E/diJQeEkSdI7KPGvnKDKXA6+m2vCazceWdY?= =?utf-8?q?FuVRuMMcobpyt2gbkivEB1vqjJgdmx4+t9WlLBGQ3BJUcg+PGsc4AlkTcg95t4xln?= =?utf-8?q?v4lw0eyPTjuESDF1rWEcfvgb0cgVUAZ4KmdYXdTTIJP/6oFxPtU99guwLQpl37d9O?= =?utf-8?q?dnouL+JTplpONkT4Gt7R2oIM62PhJRWLBp9FHmSWOeFILZ481M1PKahvg4x+huxrM?= =?utf-8?q?qx65FI9Y3qndDOHYXnz52BVFGZSeNGSQHLX8k/FdHYkVFFVfc+iUefu8lpy/GsPyL?= =?utf-8?q?varu+2vMZ1jaOIsgcMA3KxPmRJH+peXfiTdFfQRQKBpJd8jod0vdMsnWpHzzaxaC0?= =?utf-8?q?3cqfeXAicipeRVvUN/gdLLmcR2+7SVMoZ06zQrJ2R3/FT23NJ0ZY4veRoiJbYw/n2?= =?utf-8?q?JozVl5Mwy678eDu+66gXo6TSM+wbaBq+6Ya25VCYqNv5AaEstl6NltnC21Zo2/UTe?= =?utf-8?q?1iO+uQH2QlzeaVZOqKrzjOe7I1TE4bZk9j0qNBQDZ0WbTLHpYpCdAD4W2Obv4/40X?= =?utf-8?q?BYykLNMXYIFaSQxcUW+z/4WfUCZkI0TKktFyVgRSPiicf1lpsON0aHockwF/ZPadO?= =?utf-8?q?d98Ge8cv/I6KFUHCbcLIfS8hfS+I6iQCKtG0+pUd1NI9E01Do0QOmnhiVEnhNJkjI?= =?utf-8?q?BV9hIRmNmM0kRSpU/dWVprHXZgWvY0UhFwwgssXANNI4Md8lf8ZBD3ijb6R9ElE0G?= =?utf-8?q?SJu4wXmGnT5bwudYlxv3cbWfGS150/nywsTj/zmBQvcEmOu0S/CX6wrmqSkkmr9Jp?= =?utf-8?q?yHX92xeGg/OQrjBj5NQNyJG4P7siQcaZ92/K1UFgNipBAlL1ehJzuCkU7EWZsXoUx?= =?utf-8?q?v8bOkn6tXSr6?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d32b30b1-b33f-48bb-0de8-08db34da1c77 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 06:59:18.9559 (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: Pj8H7CDpnDc6gYXxSyvdqLAmx5KtS7N2TayOhVN+asAI+OlXdcmQh19HSEf7o/Sisf6yaULGQdOIrr7YJdd5YQ== 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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228000584740496?= X-GMAIL-MSGID: =?utf-8?q?1762228000584740496?= Use a tristate (enum) return value type to be able to express all three cases which are of interest to the (sole) caller. This also allows doing away with the abuse of "rex_used". --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -8921,7 +8921,11 @@ static const struct dis386 rm_table[][8] #define BND_PREFIX 0x04 #define NOTRACK_PREFIX 0x05 -static int +static enum { + ckp_okay, + ckp_bogus, + ckp_fetch_error, +} ckprefix (instr_info *ins) { int newrex, i, length; @@ -8931,7 +8935,8 @@ ckprefix (instr_info *ins) /* The maximum instruction length is 15bytes. */ while (length < MAX_CODE_LENGTH - 1) { - FETCH_DATA (ins->info, ins->codep + 1); + if (!fetch_code (ins->info, ins->codep + 1)) + return ckp_fetch_error; newrex = 0; switch (*ins->codep) { @@ -8955,7 +8960,7 @@ ckprefix (instr_info *ins) if (ins->address_mode == mode_64bit) newrex = *ins->codep; else - return 1; + return ckp_okay; ins->last_rex_prefix = i; break; case 0xf3: @@ -9023,27 +9028,23 @@ ckprefix (instr_info *ins) ins->codep++; /* This ensures that the previous REX prefixes are noticed as unused prefixes, as in the return case below. */ - ins->rex_used = ins->rex; - return 1; + return ins->rex ? ckp_bogus : ckp_okay; } ins->prefixes = PREFIX_FWAIT; break; default: - return 1; + return ckp_okay; } /* Rex is ignored when followed by another prefix. */ if (ins->rex) - { - ins->rex_used = ins->rex; - return 1; - } + return ckp_bogus; if (*ins->codep != FWAIT_OPCODE) ins->all_prefixes[i++] = *ins->codep; ins->rex = newrex; ins->codep++; length++; } - return 0; + return ckp_bogus; } /* Return the name of the prefix byte PREF, or NULL if PREF is not a @@ -9886,8 +9887,12 @@ print_insn (bfd_vma pc, disassemble_info sizeflag = priv.orig_sizeflag; - if (!ckprefix (&ins) || ins.rex_used) + switch (ckprefix (&ins)) { + case ckp_okay: + break; + + case ckp_bogus: /* Too many prefixes or unused REX prefixes. */ for (i = 0; i < (int) ARRAY_SIZE (ins.all_prefixes) && ins.all_prefixes[i]; @@ -9896,6 +9901,9 @@ print_insn (bfd_vma pc, disassemble_info (i == 0 ? "" : " "), prefix_name (&ins, ins.all_prefixes[i], sizeflag)); return i; + + case ckp_fetch_error: + return fetch_error (&ins); } ins.insn_codep = ins.codep; From patchwork Tue Apr 4 06:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2822857vqo; Tue, 4 Apr 2023 00:00:17 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmYOM4BpWl2fpYYa4UiE59jMc0K0nqmCKl0+dafChrSi4oQI04SGs7Gvo9IeLQPu06PWQm X-Received: by 2002:a17:906:655:b0:92b:eefb:b966 with SMTP id t21-20020a170906065500b0092beefbb966mr1313329ejb.0.1680591617138; Tue, 04 Apr 2023 00:00:17 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n11-20020a05640206cb00b0050295f63eecsi2913033edy.369.2023.04.04.00.00.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 00:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qtzD06JU; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FE593858035 for ; Tue, 4 Apr 2023 07:00:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FE593858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591601; bh=m4D2W19vaJZYArYqHulip4TqZRwza6X8SY+WzGaX7kA=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qtzD06JUFzBz7LGO8gez5hXzoZ+Nm9iZSGG/BTDgKuSbNyByGTgyqANaj21obp3k1 BVrd9gqx+7+EiCaMgNeD0mN0F3ouAn2/OtXUZ7DoorNzHolKzzbC3dmvKUKb9dX3QI BEegcmwvOlliLLDyeFOb/eDMipx7jewYAVFPfztA= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2069.outbound.protection.outlook.com [40.107.22.69]) by sourceware.org (Postfix) with ESMTPS id 7665E3857835 for ; Tue, 4 Apr 2023 06:59:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7665E3857835 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QGLwUpEIEZK9GqqGTzUSey1U7rIXGubhzzdlgKnuJbo7KjeYDG3b9IhbXKq2YQFYNLcEjmOnGhKAhIERmK1AosZzUlMi/geClziV6a68gTOIXZGTScXsR3WFbaevHR8BchcAmbw0SkBhLLK36YAkmfcUoN8Epqt+taSiwNbyA0pNPlBhFh15YZK992vyQnfHYRvxI51+QRC9NylsOLcJPvzOYS22hIWxH24VWNZFzpo+2c0gFk4WldA8HbD686vyh9OtLlpZVA+Ue4o9crzNLJ3VBDqhyvfDPHbnEdHE1j8QmWx+ETjU7fRX9UHPXDsWWCkSyEFyuVJfTAqhAlTM6w== 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=m4D2W19vaJZYArYqHulip4TqZRwza6X8SY+WzGaX7kA=; b=Rbt2wJoFugUG2mELIOH2zSzMRwZsNar9s35QyIQFnK+FsuDd8bfzzBIJk9LMiMGjsHHoeqVsBGV4cTB2bE8i0eQDrn+VwhG94QvtY+6aBSVY6aAQCdb7QR0eQAAsrT/mwIvE3H5l2HASeJuIDpyUqRvl2kVX/1yBeEtEtLhEkQ9ZRQmgSdRd/ppb2vJ3dy0kr9blUyAlcb8/f6SyoDPrJXr2BsQVcYWmny7c9q/Ktdq6nuiPRzhQM1h9pjjvjugULh0PqVHyJ3PIcTM4DY/mPpiDQZfU+74Ottev8PhnX/B6iB9tzr5d1ZAw5+jGc7i5OEvXZ8GZIS+1YPy+X0TeXg== 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 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 06:59:51 +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 06:59:51 +0000 Message-ID: Date: Tue, 4 Apr 2023 08:59:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 4/8] x86: change fetch error handling in get_valid_dis386() Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FRYP281CA0008.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::18) 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: 185c2047-5461-4c70-6abb-08db34da2f82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XsAoGR8AaSMrZly840TC12wYmJFOSRhrwej4uoyz9+1xb/63ujvMten/F8yCL1HkRGpKxbOyOzKq5maFK6nhnaEm97TkWk/ea2daUxTFGlN7yWoy+RddnyuCsG9zx/FeA/2QA/P6mwbwABmni7sJrrVVx4YAIDRs/eFQtuLbIzjRPWqcv1y/j2PRtb8/BcAr8fSC3CwGmgvZl4+rbi6P7r21mpvnyXhYMspa7A/FhmbNHmcsdAozvgTJ/mnsRN4wEw39GCmaRlROpdwi4EHCpvQeKJtiWTxltCYxolxwL0yr6OypmQ5/8I90Jd9mkMYnnR0t8h7t+K7Xf8a+WvtHPD2FThIadtOAnGoOx6GfBZR++csWlBdw8sN6AKVlCxE70EaWkshZ4ZcXxYzuaAt5pMLTLdSkQgVp5mqxBkkDVEyXZP9Igl4akN5LAgUz0gZ+tZdCsvXG7TXeIbTG7I840k1cCjTvOsVLi1m5fg+JWmD1wA6mqRoR/6XtIg7PMiOWNVR/hRBWT3rJCIEd2eJAonFeQvi75GQ6Qxqa4h8cdWZVlizBRxELiuY1GUnPus5T8tnW8o/q/9N8uL8A7osec178s/k0lZoLwdD+3cndF8O7VUGeckik2mNtd4kwyIiy8o/+azC81uWYcCFotMt6zA== 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)(2906002)(4326008)(2616005)(31686004)(6486002)(186003)(6512007)(26005)(6506007)(54906003)(316002)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?E8MmsdZKs5ycyf04YzNeNZeYx5QO?= =?utf-8?q?PIkZjwclSJDTa46+QF2iINNOYzpzvYpmJV+X+HR9vdYZclnzkPBs9LS51g4Kejx0E?= =?utf-8?q?3FKZAjSgj59w6UbWPIhxj/gosNjjbny1RA4+ZD2eDX864MyxTIVTC9c0nrQRzBh+N?= =?utf-8?q?PZPVchEnD+1PXMoSlrIEvhpfH/w0G9tdTZOiYiROl+YTNWaf6bLS+83aF1qubDVZZ?= =?utf-8?q?CzMBkfe5bir6FGAYY1Ms4rTqTC5sz6IJ47Ea6CsfgekcK4ckE1v7sEQmfoV5ojnND?= =?utf-8?q?RqxHzgtAaqUQoeTBS0vcPm3woOU33+bxpis+yudSqJ2oLOdGPts7WoLWKl2mr5CgV?= =?utf-8?q?kuHC5KWOsKB28is53CsUkRb65M4TOIVjYHqTIMcG/v0RrRcFPYQPcAC4b267rG46K?= =?utf-8?q?sIq2Uesjcsw8AsC6VujfcF2Xeq4F96jyl2PNVjS58TezsAg8ikzCw0mQ9QEnX2n7K?= =?utf-8?q?/CRTo57HKZYC87BhOBOjN+bTfGHfMU2no6+fOsY80P22wghGqVTVB621/tVXCPpJp?= =?utf-8?q?AWIOgToeyOmM8EPz58xsVgCEfco/dX4b6wNapWS12yNaM720oQng1gqux0BDg1NS7?= =?utf-8?q?NIuRBs/7+mdpVW8OJXLOL5XupC7JS61HQtrXVFQQ9DeYF1IkV3+MuMdbJfihMdUAB?= =?utf-8?q?iUpoUE3Y+IswVDTcuD/axeN9sYMTCww3UbSpydGnPOoEFRiszXUvS605R35IjtiFi?= =?utf-8?q?BjvW+pARU1YsXsH9/vZ0nPZ5RiEeENKRmxM5Sos2Dz7gY/FE1Sxa9T5tX4s9QpwI5?= =?utf-8?q?1c5eS2773HQ/DCM/bJzoOGgrSJA2w6Tu9bZljdSaAIR24BsJ5ECxUyUniTs196lH4?= =?utf-8?q?O4gLokwL/237uViyN4dinBRBh8o4V+q6miTJz0PoZ06EGJpZ4sxRs5eQ2RB3G1J56?= =?utf-8?q?nZk3OEdcSybMrJgGIjS2Ywapg0MFDuTmTI0tuX3UCE/SnIETEUfEIShBQkAnxwEmy?= =?utf-8?q?QVtIMgpyQnh/65Di4T6g+yhmHxYKWGHxe2tEfFEyE52zZD87TdO8G8OuGmq/VX1H0?= =?utf-8?q?XKlYq6E/jThX7QH3yWb4D5ZLSKyYecEvi7dQ7sjGeN2Rwr/nQC6puVArDa9AvFF1c?= =?utf-8?q?ZQwtUVov3AXE4Mzvv4gNuEP8X+bb5IkUG4XMolboZZHrsEJ92kgHoM5pbYOUM2RFq?= =?utf-8?q?FUIYQlW82+s4h3WbBh8UH43iP6djm+qytQ79WtVTetaNSSFaVmcFeZsN5BGPZGK96?= =?utf-8?q?5RoZwJaUiGg+06X4k59iGVxhYnAG/x083tNw/uKOgq2WJ4dzVA45lFR7hvARLWZZC?= =?utf-8?q?LCO+F+CGWip2BZYrAUvcBoPSvOWP4thcw2rhJd+TNRj7QCqopUMVUqoQGPfy3qzjD?= =?utf-8?q?vCKDVrKq7EoMD5oXLGvjI5HZ01RaIa3SI6Y2JawQ4OgmJibkKdk0VN+ZPs0u5nMBo?= =?utf-8?q?BwI6P06ErCxkukqMKzLRkLZ/kSo26lsZNVRz8XJRqw4ZJJOlEiVs1IDFH9NNTEzNr?= =?utf-8?q?/iwxqOrgGoFqAGAlGMAYQTYwa/CgiwxRpaw3QYqgGDYvhVpPLhA9ltBDXYxTtgzVC?= =?utf-8?q?sxYhv0MCAl+l?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 185c2047-5461-4c70-6abb-08db34da2f82 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2023 06:59:51.2661 (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: e5Ho+6NT5IQaSHfBRY5/rD/P4FeSRpmpO7p2aZR2FHEoe1BAiqEmEAK4WW+qEjCsBAv0ks27SLCiyov8P/grAA== 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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228035681436958?= X-GMAIL-MSGID: =?utf-8?q?1762228035681436958?= Introduce a special error indicator node, for the sole (real) caller to recognize and act upon. --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -9164,6 +9164,9 @@ with the -M switch (multiple options sho /* Bad opcode. */ static const struct dis386 bad_opcode = { "(bad)", { XX }, 0 }; +/* Fetch error indicator. */ +static const struct dis386 err_opcode = { NULL, { XX }, 0 }; + /* Get a pointer to struct dis386 with a valid name. */ static const struct dis386 * @@ -9265,13 +9268,13 @@ get_valid_dis386 (const struct dis386 *d break; case USE_3BYTE_TABLE: - FETCH_DATA (ins->info, ins->codep + 2); + if (!fetch_code (ins->info, ins->codep + 2)) + return &err_opcode; vindex = *ins->codep++; dp = &three_byte_table[dp->op[1].bytemode][vindex]; ins->end_codep = ins->codep; - ins->modrm.mod = (*ins->codep >> 6) & 3; - ins->modrm.reg = (*ins->codep >> 3) & 7; - ins->modrm.rm = *ins->codep & 7; + if (!fetch_modrm (ins)) + return &err_opcode; break; case USE_VEX_LEN_TABLE: @@ -9325,7 +9328,8 @@ get_valid_dis386 (const struct dis386 *d break; case USE_XOP_8F_TABLE: - FETCH_DATA (ins->info, ins->codep + 3); + if (!fetch_code (ins->info, ins->codep + 3)) + return &err_opcode; ins->rex = ~(*ins->codep >> 5) & 0x7; /* VEX_TABLE_INDEX is the mmmmm part of the XOP byte 1 "RCB.mmmmm". */ @@ -9377,10 +9381,8 @@ get_valid_dis386 (const struct dis386 *d dp = &xop_table[vex_table_index][vindex]; ins->end_codep = ins->codep; - FETCH_DATA (ins->info, ins->codep + 1); - ins->modrm.mod = (*ins->codep >> 6) & 3; - ins->modrm.reg = (*ins->codep >> 3) & 7; - ins->modrm.rm = *ins->codep & 7; + if (!fetch_modrm (ins)) + return &err_opcode; /* No XOP encoding so far allows for a non-zero embedded prefix. Avoid having to decode the bits for every otherwise valid encoding. */ @@ -9390,7 +9392,8 @@ get_valid_dis386 (const struct dis386 *d case USE_VEX_C4_TABLE: /* VEX prefix. */ - FETCH_DATA (ins->info, ins->codep + 3); + if (!fetch_code (ins->info, ins->codep + 3)) + return &err_opcode; ins->rex = ~(*ins->codep >> 5) & 0x7; switch ((*ins->codep & 0x1f)) { @@ -9443,18 +9446,15 @@ get_valid_dis386 (const struct dis386 *d dp = &vex_table[vex_table_index][vindex]; ins->end_codep = ins->codep; /* There is no MODRM byte for VEX0F 77. */ - if (vex_table_index != VEX_0F || vindex != 0x77) - { - FETCH_DATA (ins->info, ins->codep + 1); - ins->modrm.mod = (*ins->codep >> 6) & 3; - ins->modrm.reg = (*ins->codep >> 3) & 7; - ins->modrm.rm = *ins->codep & 7; - } + if ((vex_table_index != VEX_0F || vindex != 0x77) + && !fetch_modrm (ins)) + return &err_opcode; break; case USE_VEX_C5_TABLE: /* VEX prefix. */ - FETCH_DATA (ins->info, ins->codep + 2); + if (!fetch_code (ins->info, ins->codep + 2)) + return &err_opcode; ins->rex = (*ins->codep & 0x80) ? 0 : REX_R; /* For the 2-byte VEX prefix in 32-bit mode, the highest bit in @@ -9481,13 +9481,8 @@ get_valid_dis386 (const struct dis386 *d dp = &vex_table[dp->op[1].bytemode][vindex]; ins->end_codep = ins->codep; /* There is no MODRM byte for VEX 77. */ - if (vindex != 0x77) - { - FETCH_DATA (ins->info, ins->codep + 1); - ins->modrm.mod = (*ins->codep >> 6) & 3; - ins->modrm.reg = (*ins->codep >> 3) & 7; - ins->modrm.rm = *ins->codep & 7; - } + if (vindex != 0x77 && !fetch_modrm (ins)) + return &err_opcode; break; case USE_VEX_W_TABLE: @@ -9501,7 +9496,8 @@ get_valid_dis386 (const struct dis386 *d ins->two_source_ops = false; /* EVEX prefix. */ ins->vex.evex = true; - FETCH_DATA (ins->info, ins->codep + 4); + if (!fetch_code (ins->info, ins->codep + 4)) + return &err_opcode; /* The first byte after 0x62. */ ins->rex = ~(*ins->codep >> 5) & 0x7; ins->vex.r = *ins->codep & 0x10; @@ -9576,10 +9572,8 @@ get_valid_dis386 (const struct dis386 *d vindex = *ins->codep++; dp = &evex_table[vex_table_index][vindex]; ins->end_codep = ins->codep; - FETCH_DATA (ins->info, ins->codep + 1); - ins->modrm.mod = (*ins->codep >> 6) & 3; - ins->modrm.reg = (*ins->codep >> 3) & 7; - ins->modrm.rm = *ins->codep & 7; + if (!fetch_modrm (ins)) + return &err_opcode; /* Set vector length. */ if (ins->modrm.mod == 3 && ins->vex.b) @@ -9966,6 +9960,8 @@ print_insn (bfd_vma pc, disassemble_info else { dp = get_valid_dis386 (dp, &ins); + if (dp == &err_opcode) + return fetch_error (&ins); if (dp != NULL && putop (&ins, dp->name, sizeflag) == 0) { if (!get_sib (&ins, sizeflag)) From patchwork Tue Apr 4 07:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2823424vqo; Tue, 4 Apr 2023 00:01:06 -0700 (PDT) X-Google-Smtp-Source: AKy350aKJNxhjD/Us8iveJj7ASWI1NUC3U98sQKjtSeLG4DAuBGG3dcuZiqe6+E4qO+OhkI/cRIq X-Received: by 2002:a17:906:3b95:b0:926:8f9:735c with SMTP id u21-20020a1709063b9500b0092608f9735cmr1603063ejf.32.1680591666368; Tue, 04 Apr 2023 00:01:06 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gv26-20020a1709072bda00b008d7a24d918csi6283138ejc.823.2023.04.04.00.01.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 00:01:06 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=h7md0poi; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 660DD3853D12 for ; Tue, 4 Apr 2023 07:00:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 660DD3853D12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591641; bh=BBF5UP47JreI32UO5pcGEjrbOyRBnCkipQGBylZLrKI=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=h7md0poiuMx4ZagPVPJys1meMufNA/nAkUIkcvqgjojdDU7RQ9yBmIM70LbNrzm96 P9L4d4eYhUniezirgmb4pZD2883fOL01u4+yX2MRCQ6Nhlnv9+k0edN0x5qRqc29Sa QoP6fhlivbBjZ1PrgK/vbNuVxWD5S2zJ4Ga29+Vo= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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 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> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> 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?q?WCkQVBEPkg/XDS/q+4K+/z3ap1bU?= =?utf-8?q?lCRdlVQM2m8WsTKnBHNxUlxmfe+afxB8zoZR6VpPrYbq4eJXxYp/Iwu82PIOYzr5e?= =?utf-8?q?xjODEUPl693j7w3GCVrxO4jYv0DwWyemvISuTmD8/MNJzYye6tOW+AOCjc1CtMplH?= =?utf-8?q?+0X6nGmD9HE58s8Ce9hA1V/VL34pXwPAuR4LDqc/twQqHbp/uacrZDMWpQPkIMuzN?= =?utf-8?q?pnSSjcg+cQVnbUSaWV44kUPecdNn9kkctYZ0Ve6hEd225QTS4AcjkHYTvLJWEBn3w?= =?utf-8?q?h/tS6c2p8yaeFauQKg1EV7htRLmPLmTF4AO2P69CHxvYqlUS4tQ/OhID46/rxRtCf?= =?utf-8?q?x/tHPjhlpEmOR2oTBsW+IJLv5FkBe+HvCt5crC1BJDKu4f0Poxi0zFbWRl6a7PoOg?= =?utf-8?q?i+HWaTyU+K36EFV78cAA60ydHt3myJ+EvIDJrtiIDXnR2h2NM+shLfwOupTU1UmIO?= =?utf-8?q?gwF1zc8JzE0zjzCUtqJmcHe1bC05Ksr/vQ2XL4ovdx/nWta72rjll2C4vxjkY86Ae?= =?utf-8?q?FqJu3pglTy7J2uAwLzS3q1Zm9ibS1SP3k3XWZXDMQZv8AvmrzxZhxZ2ffq5HZxq+I?= =?utf-8?q?eisxqSJxZYazYXaDleLTIdpxD2eTkDdjRDVa3qfYHnoTq9qszNhMfggsXVmslliar?= =?utf-8?q?sof0agwXhVbtktlhC1MjW4Tjq02ohn2KeOWzFD6nDtLCM4lfAq8ZZvhYUXkwAlPA9?= =?utf-8?q?0qh9nncdmhm2Dcz1IaW1kk4L8Taz5cwZLjgOHVmZoiIwvjjMMSLiNDywuP24e4ElU?= =?utf-8?q?AEa2VeR1t4KBUKz8tua/AdswXJI0Xw5uYJ/TA7CQEjfNKIIaLmUvtoeqbaAkdV3uo?= =?utf-8?q?A8bJTCzMl/Lpgs5o/2u3QDnk7qkKGOq1PeYUEEGfBGy0FCTLOp+fAFGa2x1I4So6U?= =?utf-8?q?IEwpPRBtpIzG6umDvSzVjF/F89nzHkO57vFs0a2G8dczQ9hz7rYbnf9dZrV6jimzI?= =?utf-8?q?k3j3y4wZA9PXzGu4Vn+F5CttBgtcPXgsipIryQymUpcW3CgxjoP8dqiMl2FxLHOcQ?= =?utf-8?q?zlMFvY5Ns9ndtrha0FgOPy+UEO2SQzpa36SUBcX3WfvndpR+PGj8Zi9cOU24SvS6N?= =?utf-8?q?yfE36bXzJe9kikrhhwFezpfzyHVsBAHCjIjzLymi6uPbJYW5Byg1kP+IVMt4Sx3Zw?= =?utf-8?q?g4RFgzUVXVzvMLElvKmowEu2/A1rn8bKNLc1oH39XvfdxlgKG8APoc2h9uStX/+2h?= =?utf-8?q?all6ulH59A/3ocwzPhodr2hQ5hcXIRmWmrUiWJnbg3BsK5zyYqY3c2jM7RseQjvUm?= =?utf-8?q?wR/07izvZ1G7/ejhO6UgCO/EsbSxW6TgHazS6f/zKkX/F8/L0d3Hz7aigLm7JtWXT?= =?utf-8?q?Ur+1vxBU/PKuy3Y/f0LTk8GfN+gaKbPnzEixqR3/3yx+RDH4cI7SwglQr+kGgpU3+?= =?utf-8?q?WWUeZbKdMactyQFy4staCev5ozw6jbVWgcGyjrkBokNqO2WEsfgH8xEO87pF2ECTr?= =?utf-8?q?SpoCuQCoG8nV8sHGMISB6natLD7bGehRyCXpL48ia3Sh75ss20ana7heDdOxMqTpc?= =?utf-8?q?qblgMX4CaEjh?= 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 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228087395902699?= X-GMAIL-MSGID: =?utf-8?q?1762228087395902699?= 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); } From patchwork Tue Apr 4 07:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2823860vqo; Tue, 4 Apr 2023 00:01:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZAAavdQlq4VvDvV8ijY0eclzHXB+tssQ6KYy9z7P+us2yYrJcC2UrRI9rLMSuinUy7Igvi X-Received: by 2002:a17:906:600c:b0:93d:78e:d21d with SMTP id o12-20020a170906600c00b0093d078ed21dmr1136511ejj.64.1680591704413; Tue, 04 Apr 2023 00:01:44 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c2-20020a17090618a200b009337bae35c1si688899ejf.237.2023.04.04.00.01.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 00:01:44 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NC1q1lP9; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DAB67385480D for ; Tue, 4 Apr 2023 07:01:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAB67385480D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591661; bh=FWjaKqYe8S76QlzIymrz53DMJlSMKHK0xLFpLwLUbfU=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=NC1q1lP9MVN/fnst8681V4hb1RqaR08w/A6F+NY+ISQP9KEP9A6arB2StHEmLe+vs cQdDvCIXjpVlJCmuR09GK8AbzP6L4QbFvzqNsiijU0CuI8qdR4T13gNz8WCMkmX10I 5D2LS+III98StrSQ3OTL/j003Jr1qrVwLIh7wXgQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2042.outbound.protection.outlook.com [40.107.241.42]) by sourceware.org (Postfix) with ESMTPS id 2FAF83858020 for ; Tue, 4 Apr 2023 07:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FAF83858020 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IgTFBEMz4yxSEnfZOWQh5njxBUoaqRB4svI4DrYsjElzLdVnft7uQf2wH8SoKsQajt7nyE/6yNuhLa2gf2WrJ0YLvOccbvRORmy/lze5xgiYo3c1988M6yUhPvG9fuXeY2J0snabXBV1/mS1Igf7IqXY7UVfFH0oRC99yQqb+5rxqgmf/5F9ko6UeP6kRndQLn/sWucS9cF1h7SSr9z9g4Kd1KuT4J11MxLOQBtHHA6pbkwp1ZHfQIpKBb3tGXH5jleH4K6hxW+ksMsn5c5PNyDqNM+VT0wEVBUbpUb2mvOKe0wJzU7ViJzNWQqHcKEe0p+yVgI9wI+JmwCfXwsJQg== 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=FWjaKqYe8S76QlzIymrz53DMJlSMKHK0xLFpLwLUbfU=; b=DrsYpLPAeVENm6zFQgq5zlPVfhOgXMDFPfUteBTQYdxr3sGLHczgbJrDUmrefLfV7spkpxwNJ6prgB4El1XmqzLfsTn4JuZciYPKTRDJGsQLIernJOFbyiAVJg53zRKW++tuN3HwomO/X8kRhRxqtuckKiNPKwioyP6Jzh1Zzz7i9UNiHN7VKc9mLLIQ85vvKHZyUuz8+zRALHps1oSEHfcCUTggD+xioOOvM/S1/9FvBg+k0112SzMg+Xl2igjNsoSB7PMIh0HChqMaMT6wIBxNI8BKRTZ7zrXE0fFNBDGBNXFrsEQZQg1PHCYjp/ec8sfHZ9IepEUZYtCD8mv0Aw== 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 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8609.eurprd04.prod.outlook.com (2603:10a6:20b:424::9) 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:49 +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:48 +0000 Message-ID: Date: Tue, 4 Apr 2023 09:00:46 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 6/8] x86: change fetch error handling for get() Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR3P281CA0188.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a4::20) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8609:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ec12cd0-bce4-4dd3-fc1c-08db34da5184 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kmh76Z5Z0oD8Oi4k3IanSUnKwwLO8//xRBZqIJFcH+H7LLVf214xugUgdiEnkoUiOyLuo1VI3+PsvbbgFseJDKiDZykkpqfD1tzROENg6qU17kKhZbR8NAA8hoZjb8+NI7PWQ8IO1u5N6sSQQuOhlKHALZKbwVRufg57gHrzipZ9ycMq08s6p8tTxsI+/krO0cRmgXQ3pkFH+U3/yxRc8hLa922c9hNO0blozV4I65IPndU7bqk3nUTpwEIBOGZlIoKleAwpvqqveLI57A9H9Ua3Edmmvnr7vTWVfiuds96Cp9M6LzovjX5Y5v4mFMHvNK2qAsoRzhcQdkbqx07yfuNs0ArWvy6lkXHgaucgyVBBBzNxA6Fw38wDVKIhujPx6RErv9XLsrO9h1nrSkeubkKHYSxkEwUy8nKBr+eWLjS5xF9PEnFRc7nx+wvJba+VTGEA65GIMhkt2DvBAEZ/Aila8KaggoNFunmkCPavQNbXoBwQGrlmaCRG9npI9CUUiAEhC6OvUwPuafWTzgUpK2fK5fEvFACWwnXzCnOFFJruVP3s2rnjmuDIMdDQWDy6v5vQQfXEjAbcclNKpwVkv58RYcJn/IWA6xlo+lPlNUfJFd6qP8T535/hH3Nn6w4oSx7GFYDaSV3+qalVx/oQ2g== 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)(39860400002)(136003)(376002)(366004)(346002)(396003)(451199021)(31686004)(6486002)(54906003)(66476007)(66556008)(66946007)(8676002)(41300700001)(6916009)(4326008)(31696002)(36756003)(478600001)(316002)(86362001)(38100700002)(6506007)(6512007)(186003)(2616005)(8936002)(2906002)(5660300002)(26005)(30864003)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zKomzmHMlr2gO7vflcd7oxdug7cz?= =?utf-8?q?C3AsnstZdtmeHpfzfOjes6mQx8v/wGHX0HPohPpBS2AifQiU7ywqkVJuRUJHCFYoc?= =?utf-8?q?NpLfwsVW610uUP1LqWIEUR3MMwRCppRuczGIx30/i31dFHlyGVdslwfzeBjClUMSr?= =?utf-8?q?QFDv1odRbFEIOzRWywHxvkH2D+TTziFHZViYFnU8+892myuC8kt1xeyQqk7eU7G2T?= =?utf-8?q?VpYy0JaEbVVvdatTmmCNmCZqt9sSIIkK9nJtZiICMC2PJT3v4qm9HSbcGZj0HWF1c?= =?utf-8?q?2g41MB4InQ5zn1QKZ/26p3jJ0rCXWnrALljve7gOEAYoKWtDoDR8cvafqkuO+p4nM?= =?utf-8?q?+B2H5mRH/PdBichHMDrzK9k5zI4biEKEvdNwolx9o8qggL/rZ65xOijq00b6kfg4Y?= =?utf-8?q?13WSkg+fik/sglP0k5fo/QCj1aB1JuOc/vSNb7MeTgQRzY+Z35HA7M0kMG5YNpdiU?= =?utf-8?q?GWR+niZal5DOqzXLktyXxE/jI7fMa9kHZT+GOGAJ5RxWHrLj53rpmPEIYe72P3Bbt?= =?utf-8?q?37pZtY8PKWFQz7W975VDl+WRRrOaTPDHyp3MezwASXNJkEFX5yc4ZGnC189OYH6v/?= =?utf-8?q?tVSPOoyL9kiwCHDuZRjNklUpvp6rh0CIXe6HaUwHWQzM4dJFNDTkTlpII1HIcwWAm?= =?utf-8?q?26tdOx7ggPAHhQ6QfnEOczG5DAFG7Ko7OCYEkCXxSMwxWGShT/sUHrz9+WwoUli7N?= =?utf-8?q?rkejQFkRbe6QPPygWZir48G0f8kkcRumiw08hpuWF+bNEHbOMUcL6YVmlChmBeAhh?= =?utf-8?q?DrU0Y+jutcs8G4xh/6a20rEzmB9s88Bj6Z0iTBUGsEe/b0PiXbFSiYS8FTpRR4yVz?= =?utf-8?q?a+Uxzr0h2X5s2Lip+jHzQywSK5SExKdpuJ9uXKkH9Gc7uccPD88BiASi8JC9HejJS?= =?utf-8?q?kO3Pme3fjjEzYhX12M28I/H0r1LMi4W4BvNOznR7OzrU3ogQu2p6sN0ua5nE0fgtw?= =?utf-8?q?N+zmx7XuL6nNqtarqkWcLxS4d2+dzwcsPM5ppd4jgeIFeV8lAlLgYqcP7Zj5SW6s+?= =?utf-8?q?kA6BAqSKPfqDN0n8vrOWiqdMluVkJyIJ3M5lKUfxrcAjAnnX45hyASI8HdI8s8ZwY?= =?utf-8?q?/igztwl173dCdJ0W/XFaN4lfIIlv+0+LT1Ca2cwxKTg2ivBEv3xkpcIa7gj7qxznf?= =?utf-8?q?xCkTwJZ1N/6KFknGkzJ2CSOUqIhZctFiQ6DLUX7U88lFPs6U2F33ZE7UOCE9ycLSB?= =?utf-8?q?lxJwuNTgEkC9/Mw6lqZx4mUmRKXKsMvxTEcE5gwsEj9mZLpdZ0dIkBAAKP5XWF9jN?= =?utf-8?q?8cdGgWrAdGyPZUjZILQAdapIXEjAahVD2JgAgZvFeIgA4hoew8EOtaRG7h2p+p9NL?= =?utf-8?q?NIS57TjylgPKeuKvFomaldGK2i4cNTf814bAR5PzNkQa7/L7IwMEB3NQBp5xwLG1m?= =?utf-8?q?KNsTjegdVUozi+hqobihAQUzLm/+SkQQTiHsbxehzWz//XIAV2nnCZ4kgqgc6j95J?= =?utf-8?q?psX9qHHIeCbnZdroX9Pu6nSxJvjCOX5GoT7fW1KwyRhuZbHFWuuvQGbesGXqkrIKW?= =?utf-8?q?PBVc3wzJCMl3?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ec12cd0-bce4-4dd3-fc1c-08db34da5184 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:47.9831 (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: Jdb4QalVO0BXj1kyTmwygtiluJWorvci+5J9cPoo+6iu8ExuN1XfDf6KxZN0Jx6RwYursHUMxMQcOupJJ2RUng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8609 X-Spam-Status: No, score=-3028.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228126713788848?= X-GMAIL-MSGID: =?utf-8?q?1762228126713788848?= Make them return boolean and convert FETCH_DATA() uses to fetch_code(). With this no further users of FETCH_DATA() remain, so the macro and its backing function are dropped as well. Leave value types as they were for the helper functions, even if I don't think that beyond get64() use of bfd_{,signed_}vma is really necessary. With type change of "disp" in OP_E_memory(), change the 2nd parameter of print_displacement() to a signed type as well, though (eliminating the need for a local variable of signed type). This also eliminates the need for custom printing of '-' in Intel syntax displacement expressions. While there drop forward declarations which aren't really needed. --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -48,10 +48,8 @@ static void oappend_with_style (instr_in enum disassembler_style); static void oappend (instr_info *, const char *); static void append_seg (instr_info *); -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 bool get32s (instr_info *, bfd_signed_vma *); +static bool get16 (instr_info *, int *); static void set_op (instr_info *, bfd_vma, bool); static bool OP_E (instr_info *, int, int); @@ -295,41 +293,8 @@ struct instr_info #define PREFIX_FWAIT 0x800 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive) - to ADDR (exclusive) are valid. Returns 1 for success, longjmps + to ADDR (exclusive) are valid. Returns true for success, false on error. */ -#define FETCH_DATA(info, addr) \ - ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \ - ? 1 : fetch_data ((info), (addr))) - -static int -fetch_data (struct disassemble_info *info, bfd_byte *addr) -{ - int status; - struct dis_private *priv = (struct dis_private *) info->private_data; - bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer); - - if (addr <= priv->the_buffer + MAX_MNEM_SIZE) - status = (*info->read_memory_func) (start, - priv->max_fetched, - addr - priv->max_fetched, - info); - else - status = -1; - if (status != 0) - { - /* If we did manage to read at least one byte, then - print_insn_i386 will do something sensible. Otherwise, print - an error. We do that here because this is where we know - STATUS. */ - if (priv->max_fetched == priv->the_buffer) - (*info->memory_error_func) (status, start, info); - OPCODES_SIGLONGJMP (priv->bailout, 1); - } - else - priv->max_fetched = addr; - return 1; -} - static bool fetch_code (struct disassemble_info *info, bfd_byte *until) { @@ -11412,15 +11377,14 @@ oappend_immediate (instr_info *ins, bfd_ /* Put DISP in BUF as signed hex number. */ static void -print_displacement (instr_info *ins, bfd_vma disp) +print_displacement (instr_info *ins, bfd_signed_vma val) { - bfd_signed_vma val = disp; char tmp[30]; if (val < 0) { oappend_char_with_style (ins, '-', dis_style_address_offset); - val = -disp; + val = (bfd_vma) 0 - val; /* Check for possible overflow. */ if (val < 0) @@ -11830,7 +11794,6 @@ print_register (instr_info *ins, unsigne static bool OP_E_memory (instr_info *ins, int bytemode, int sizeflag) { - bfd_vma disp = 0; int add = (ins->rex & REX_B) ? 8 : 0; int riprel = 0; int shift; @@ -11939,6 +11902,7 @@ OP_E_memory (instr_info *ins, int bytemo if ((sizeflag & AFLAG) || ins->address_mode == mode_64bit) { /* 32/64 bit address mode */ + bfd_signed_vma disp = 0; int havedisp; int havebase; int needindex; @@ -12030,7 +11994,8 @@ OP_E_memory (instr_info *ins, int bytemo havebase = 0; if (ins->address_mode == mode_64bit && !ins->has_sib) riprel = 1; - disp = get32s (ins); + if (!get32s (ins, &disp)) + return false; if (riprel && bytemode == v_bndmk_mode) { oappend (ins, "(bad)"); @@ -12048,7 +12013,8 @@ OP_E_memory (instr_info *ins, int bytemo disp <<= shift; break; case 2: - disp = get32s (ins); + if (!get32s (ins, &disp)) + return false; break; } @@ -12154,14 +12120,8 @@ OP_E_memory (instr_info *ins, int bytemo if (ins->intel_syntax && (disp || ins->modrm.mod != 0 || base == 5)) { - if (!havedisp || (bfd_signed_vma) disp >= 0) + if (!havedisp || disp >= 0) oappend_char (ins, '+'); - else if (ins->modrm.mod != 1 && disp != -disp) - { - oappend_char (ins, '-'); - disp = -disp; - } - if (havedisp) print_displacement (ins, disp); else @@ -12209,13 +12169,17 @@ OP_E_memory (instr_info *ins, int bytemo else { /* 16 bit address mode */ + int disp = 0; + ins->used_prefixes |= ins->prefixes & PREFIX_ADDR; switch (ins->modrm.mod) { case 0: if (ins->modrm.rm == 6) { - disp = get16 (ins); + case 2: + if (!get16 (ins, &disp)) + return false; if ((disp & 0x8000) != 0) disp -= 0x10000; } @@ -12229,11 +12193,6 @@ OP_E_memory (instr_info *ins, int bytemo if (ins->vex.evex && shift > 0) disp <<= shift; break; - case 2: - disp = get16 (ins); - if ((disp & 0x8000) != 0) - disp -= 0x10000; - break; } if (!ins->intel_syntax) @@ -12248,14 +12207,8 @@ OP_E_memory (instr_info *ins, int bytemo if (ins->intel_syntax && (disp || ins->modrm.mod != 0 || ins->modrm.rm == 6)) { - if ((bfd_signed_vma) disp >= 0) + if (disp >= 0) oappend_char (ins, '+'); - else if (ins->modrm.mod != 1) - { - oappend_char (ins, '-'); - disp = -disp; - } - print_displacement (ins, disp); } @@ -12382,14 +12335,14 @@ OP_G (instr_info *ins, int bytemode, int } #ifdef BFD64 -static bfd_vma -get64 (instr_info *ins) +static bool +get64 (instr_info *ins, bfd_vma *res) { - bfd_vma x; unsigned int a; unsigned int b; - FETCH_DATA (ins->info, ins->codep + 8); + if (!fetch_code (ins->info, ins->codep + 8)) + return false; a = *ins->codep++ & 0xff; a |= (*ins->codep++ & 0xff) << 8; a |= (*ins->codep++ & 0xff) << 16; @@ -12398,56 +12351,49 @@ get64 (instr_info *ins) b |= (*ins->codep++ & 0xff) << 8; b |= (*ins->codep++ & 0xff) << 16; b |= (*ins->codep++ & 0xffu) << 24; - x = a + ((bfd_vma) b << 32); - return x; + *res = a + ((bfd_vma) b << 32); + return true; } #else -static bfd_vma -get64 (instr_info *ins ATTRIBUTE_UNUSED) +static bool +get64 (instr_info *ins ATTRIBUTE_UNUSED, bfd_vma *res ATTRIBUTE_UNUSED) { abort (); - return 0; + return false; } #endif -static bfd_signed_vma -get32 (instr_info *ins) +static bool +get32 (instr_info *ins, bfd_signed_vma *res) { - bfd_vma x = 0; - - FETCH_DATA (ins->info, ins->codep + 4); - x = *ins->codep++ & (bfd_vma) 0xff; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 8; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 16; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 24; - return x; + if (!fetch_code (ins->info, ins->codep + 4)) + return false; + *res = *ins->codep++ & (bfd_vma) 0xff; + *res |= (*ins->codep++ & (bfd_vma) 0xff) << 8; + *res |= (*ins->codep++ & (bfd_vma) 0xff) << 16; + *res |= (*ins->codep++ & (bfd_vma) 0xff) << 24; + return true; } -static bfd_signed_vma -get32s (instr_info *ins) +static bool +get32s (instr_info *ins, bfd_signed_vma *res) { - bfd_vma x = 0; - - FETCH_DATA (ins->info, ins->codep + 4); - x = *ins->codep++ & (bfd_vma) 0xff; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 8; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 16; - x |= (*ins->codep++ & (bfd_vma) 0xff) << 24; + if (!get32 (ins, res)) + return false; - x = (x ^ ((bfd_vma) 1 << 31)) - ((bfd_vma) 1 << 31); + *res = (*res ^ ((bfd_vma) 1 << 31)) - ((bfd_vma) 1 << 31); - return x; + return true; } -static int -get16 (instr_info *ins) +static bool +get16 (instr_info *ins, int *res) { - int x = 0; - - FETCH_DATA (ins->info, ins->codep + 2); - x = *ins->codep++ & 0xff; - x |= (*ins->codep++ & 0xff) << 8; - return x; + if (!fetch_code (ins->info, ins->codep + 2)) + return false; + *res = *ins->codep++ & 0xff; + *res |= (*ins->codep++ & 0xff) << 8; + return true; } static void @@ -12587,30 +12533,32 @@ OP_I (instr_info *ins, int bytemode, int case v_mode: USED_REX (REX_W); if (ins->rex & REX_W) - op = get32s (ins); + { + if (!get32s (ins, &op)) + return false; + } else { + ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); if (sizeflag & DFLAG) { - op = get32 (ins); + case d_mode: + if (!get32 (ins, &op)) + return false; mask = 0xffffffff; } else { - op = get16 (ins); + int num; + + case w_mode: + if (!get16 (ins, &num)) + return false; + op = num; mask = 0xfffff; } - ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); } break; - case d_mode: - mask = 0xffffffff; - op = get32 (ins); - break; - case w_mode: - mask = 0xfffff; - op = get16 (ins); - break; case const_1_mode: if (ins->intel_syntax) oappend (ins, "1"); @@ -12628,13 +12576,18 @@ OP_I (instr_info *ins, int bytemode, int static bool OP_I64 (instr_info *ins, int bytemode, int sizeflag) { + bfd_vma op; + if (bytemode != v_mode || ins->address_mode != mode_64bit || !(ins->rex & REX_W)) return OP_I (ins, bytemode, sizeflag); USED_REX (REX_W); - oappend_immediate (ins, get64 (ins)); + if (!get64 (ins, &op)) + return false; + + oappend_immediate (ins, op); return true; } @@ -12677,10 +12630,16 @@ OP_sI (instr_info *ins, int bytemode, in break; case v_mode: /* The operand-size prefix is overridden by a REX prefix. */ - if ((sizeflag & DFLAG) || (ins->rex & REX_W)) - op = get32s (ins); - else - op = get16 (ins); + if (!(sizeflag & DFLAG) && !(ins->rex & REX_W)) + { + int val; + + if (!get16 (ins, &val)) + return false; + op = val; + } + else if (!get32s (ins, &op)) + return false; break; default: oappend (ins, INTERNAL_DISASSEMBLER_ERROR); @@ -12713,12 +12672,19 @@ OP_J (instr_info *ins, int bytemode, int || (ins->address_mode == mode_64bit && ((ins->isa64 == intel64 && bytemode != dqw_mode) || (ins->rex & REX_W)))) - disp = get32s (ins); + { + bfd_signed_vma val; + + if (!get32s (ins, &val)) + return false; + disp = val; + } else { - disp = get16 (ins); - if ((disp & 0x8000) != 0) - disp -= 0x10000; + int val; + + get16 (ins, &val); + disp = val & 0x8000 ? val - 0x10000 : val; /* In 16bit mode, address is wrapped around at 64k within the same segment. Otherwise, a data16 prefix on a jump instruction means that the pc is masked to 16 bits after @@ -12762,14 +12728,16 @@ OP_DIR (instr_info *ins, int dummy ATTRI if (sizeflag & DFLAG) { - offset = get32 (ins); - seg = get16 (ins); - } - else - { - offset = get16 (ins); - seg = get16 (ins); + bfd_signed_vma val; + + if (!get32 (ins, &val)) + return false;; + offset = val; } + else if (!get16 (ins, &offset)) + return false; + if (!get16 (ins, &seg)) + return false;; ins->used_prefixes |= (ins->prefixes & PREFIX_DATA); res = snprintf (scratch, ARRAY_SIZE (scratch), @@ -12791,9 +12759,21 @@ OP_OFF (instr_info *ins, int bytemode, i append_seg (ins); if ((sizeflag & AFLAG) || ins->address_mode == mode_64bit) - off = get32 (ins); + { + bfd_signed_vma val; + + if (!get32 (ins, &val)) + return false; + off = val; + } else - off = get16 (ins); + { + int val; + + if (!get16 (ins, &val)) + return false; + off = val; + } if (ins->intel_syntax) { @@ -12820,7 +12800,8 @@ OP_OFF64 (instr_info *ins, int bytemode, intel_operand_size (ins, bytemode, sizeflag); append_seg (ins); - off = get64 (ins); + if (!get64 (ins, &off)) + return false; if (ins->intel_syntax) { From patchwork Tue Apr 4 07:01:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2824573vqo; Tue, 4 Apr 2023 00:02:54 -0700 (PDT) X-Google-Smtp-Source: AKy350ZRfZEeOPeXb3JO0khPwfBk15qljbRCdlBXLN2WMO6vSeS+BRPiqfkZkx9mTBhAICYEi6gT X-Received: by 2002:a17:906:694d:b0:948:eed:b4e0 with SMTP id c13-20020a170906694d00b009480eedb4e0mr1135447ejs.61.1680591774468; Tue, 04 Apr 2023 00:02:54 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n12-20020a1709065e0c00b0093b064e5934si2376981eju.464.2023.04.04.00.02.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 00:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=a5juEX3J; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 571F03858428 for ; Tue, 4 Apr 2023 07:01:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 571F03858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591705; bh=dpVMGXSR2ipOx3PZZxY0GsZG+YRNz5py2XFbFg2D3sQ=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=a5juEX3JYfTTm0Vu/4GJgSGWnuKz4WqbVhbt2kpx70hNqAADmoArGyK6nHRU/R56n gm7N1/uoIsopqeh8DI4oGXaC/6Uks2MWZ2oeUDDpSk3FWGqu4ad9Lyh1s00+7Q9/jT Oq8ijWXlqFXVX8hAOWsmubcDaA65vHkHVR1PFSJQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2046.outbound.protection.outlook.com [40.107.241.46]) by sourceware.org (Postfix) with ESMTPS id D06EE3853D30 for ; Tue, 4 Apr 2023 07:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D06EE3853D30 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X3XvyUcHs+fgOqovV8Z/Jg5mM/OjLoX/68vvERjS9U8SLhUYJXpFmx1b6+1VrLnJ0+udmGjchEJjo7KOWbc6UoqwaukFeKPX4gkrbOXgT5epGubznmqHFlBo1zaxyF6uH29M4wJRU/8FT9xo3i64P5agJ+nVVaijwi+u8xh7yfkigN6n80FHS00ku4iGOQsLK+WzU/y6ZWU4Ijyqc8EyvkFLP0B6u2CcYb+Ymem01TMGG/q5cY7gJpRcXnokGrKqGXunFNEXnFhvXaRZ07Q1zEv/eRquUakPReWAQ2hL7eYaPKihzigCd7CRAe8Ei+9gvOvB46pn8rXWiw2A3Ht8kg== 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=dpVMGXSR2ipOx3PZZxY0GsZG+YRNz5py2XFbFg2D3sQ=; b=FaLHJQOrXq84suX3cbpSl/4DqKDaEgCJ7PRxInvPnw99iAGalnbdT/32zfH+/BX14jvPvXiwvyVsmeKSf25OTP0nIydoYU2WJbcpM8mwld9rMZ6wm6ozn5kWrsVkhMd1G+lskQn7+B2Jvxx3BaMrYhh0aby7NyR+3Dy4XFTc2QzjxVXArLt6NcB18emmYeXp1R5Xr62HPixFDO5pybPzSvamh2gH6Co8Zgitirbjwy6W807izMole/IbfHZZJtDB032Y7SHookTR7EtY15gGMpRkVTtQSAvxxLJVI/EymwXUsUJtS3uor2vYLV1AUp55UzWagmQGpG6cCrcVkvUj5Q== 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 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8609.eurprd04.prod.outlook.com (2603:10a6:20b:424::9) 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:01:05 +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:01:05 +0000 Message-ID: <9375ae85-ac76-2081-547d-55803c97aadf@suse.com> Date: Tue, 4 Apr 2023 09:01:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 7/8] x86: drop use of setjmp() from disassembler Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR2P281CA0135.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::19) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8609:EE_ X-MS-Office365-Filtering-Correlation-Id: 99328554-2e83-4c94-cf61-08db34da5c03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nFgh6GeKlIDcuhQoG/V6ipzb4QqRnliynYy7KfClSvLWG3pGJg87esXYagtYRpOa6InUw6IBE+fEGFpESW8kuZZBscqlc4+AEKZbTUvTqH37zNc6AARjD1Yhykpxp3N7QcwzWTDQ/8uD81Ok5JOpdQWFp12t0OtoI38uO0TY1SWcTuMGRTHOSTYHToP/FL7xiAfGScyP4UTgGk4+z43I29EKOdt/CSObyJUHIhT969ePYW7qNALseRDaNwVTUw+sGU2ULPro23toF+JD6V2ppuZaHfc17vtaUUdr3x78efg30JbFyd8Xd+Keo31hO+hx4yRBO69YzEADdBiumBNkYGwb88RjLHRK9cxVyy87xQZNv9o0DDZtWtO4/MIZU0ESzznL1VTHv3aZEDwlY19TSrZ99TVLADXcuJfETcGvqrBIsDj3kwCnvp57JI8rWRUOrnOCtuC3EBhLaf1mJsd8eKMHDFnraBuQpWVepoxOPQb9UaZtCfo7NHCw5C8dU2tWtX1BQuzpR4esm88nIHmgV/hHycAlli/EPwK93N2EcuuuM5RoPnDMna5FEEjQAb9q+DteKf7hAjc7li2pmsNygGlJH4VYUCfzKb9R2WOXON0ZetQCRo87sbcSppkkZv+LesroaJAv9QklXvICIAKZQw== 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)(39860400002)(136003)(376002)(366004)(346002)(396003)(451199021)(31686004)(6486002)(54906003)(66476007)(66556008)(66946007)(8676002)(41300700001)(6916009)(4326008)(31696002)(36756003)(478600001)(316002)(86362001)(38100700002)(6506007)(6512007)(186003)(2616005)(8936002)(2906002)(5660300002)(26005)(4744005)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xhyq09WnHsDqU+RJhLBPctyKKfzN?= =?utf-8?q?o2HHF13G1oyUMHm6t3DSDlX4A1FIwfoSH4v0U/ehqdcWJH7j6SCFpARyVNCOVUqM7?= =?utf-8?q?LBvSc9BtyGMH16ECrTT8QB2XXtrpd6ifiSxdOD5d14jImgQGn4SvMuIOuTOl2R/GY?= =?utf-8?q?Rk5tC3OnDnpezTR2bP5wJi0+oYD2l1tPLr1m16yxeTw6ESaHKSMZz6m55dt51onfN?= =?utf-8?q?WPfHAwjJRt29TugSvmNWyU73cR4cW7t5z7Pc3uXiGtVablviI3Cv01l8ZI/MQgRVq?= =?utf-8?q?viUYQz1jnWCKHBs5SaOkHuSDz95OZl65FjvBPgvmcvF+pS7/G12h8l4EBJxw54hsJ?= =?utf-8?q?piv0ZidXwEgotPzKaPVKPzv2XiTIeLyuYubKu1Tg0WjYERoegNaYN9WURyQEBPD0w?= =?utf-8?q?KFPkBFyQAx71xPg1isf48/4NTXIWjVUJm7XslRplI+MOUNTfRuyAmCVud1qQXri/w?= =?utf-8?q?MghUrNm7iGGBVBDvTlHVbPv/Y9gjDcRz71cu5cGEPD0vqg3HvCF3wIaZhOA+4fDdV?= =?utf-8?q?PfzgTprg85vVsZ+XaGaBkuqLcA3snO1XYS2tfcKTbL+f+g3zG6KCgrsVro59u2P9n?= =?utf-8?q?UkzdU92A+6fZr7cCIimKUlG7DRL0DrTrfx9eRKrkLB7aKb3zSBnO7fRpVkARshQuT?= =?utf-8?q?2X9Mz3NAIS/GBex0tmkIZAnXAC0fBmchXwB1yb6Ed0DTV/IS1BcGFCdmst3zj65MQ?= =?utf-8?q?lJHimBqwLM/YvHQH+tN2FmLf8qFvDFednYNFZH8FVzIaXti3awA56l5b24cXTtPG7?= =?utf-8?q?QXpXfZSzkeovJVkkn7DfEHoQuxTN9BnA0U44rS2WTycvZ2M0D1relofPlTLJlAfy0?= =?utf-8?q?tfX6qjtY+EfAweg5S/Iid58XEbokyv+kt5lkrg93Y1bPfT3AnZ0PWcnwoJRo/uNkb?= =?utf-8?q?JYkK5GiR3MIqk4u1G7yH5x8/EoqzbCpM18KAbnbKuoGb0ASOKXQ4S3d6VrnG9gjcP?= =?utf-8?q?VVwigIa6U7W+0RmJLD3sUAaWIJKR8UpX+GIC6UFWBo/PRtOpw2fxWxPhgOiPDNj7K?= =?utf-8?q?PUxtkk4RkpYAlE5+MIDHgY6JspUn4ZxX3PE2o/1OOSoM97cbeOJLnnla23MB5MyQ4?= =?utf-8?q?Cwg6pvaX4Lc3VYtOQ/aJIz9yxqNCfOVnjxn7pnDJSYUsTkefhgf29UezA/yypZWaI?= =?utf-8?q?9FTMvtH/f3j9tsJrruVzxuLBz5EY/H6k+wfVeNzDqSlGNho1m4yauFn3kfEfe3Q0J?= =?utf-8?q?MVzX8YCgv51IR49vo0L3gadP7EdkTi82/XhFByEdUB4/zQ7SZstP66tF0UXzYO6mQ?= =?utf-8?q?mUrLAr4/Qv0oJRUtx+7N3xfre6XhnPR0W06nUVOmrGrCf3tKfdhj6I9v74ahmDfLb?= =?utf-8?q?+oYf9rxhHB1JC1mT3EiwGee6V7c/U1C3gigDROC7KhbPrXoIksoNM6CD6l9xfOvY0?= =?utf-8?q?7rE1dkbN+oObdD/hfL2sJAxwXhZ9xq01/vK8ATOqm76c+JBNrj0Q9YtjbhE8pIX0O?= =?utf-8?q?E7sQrCBq8fbUitYEQa3LedOhNLQtOMHtXk59FAlKBqrhV1AR+D1PPKaQCMjuCdN7d?= =?utf-8?q?Ir/tj87bfP60?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99328554-2e83-4c94-cf61-08db34da5c03 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:01:05.5869 (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: 73hGhZuZcMYMBavxFyoWrdKZVkK2IqmDAUEU+U0OjTiJ2i4dzLVOnKfAeqDAvBmmnRAUf3kbzFE8dbc6S7Uc/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8609 X-Spam-Status: No, score=-3028.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228200285499826?= X-GMAIL-MSGID: =?utf-8?q?1762228200285499826?= With the longjmp() uses all gone, the setjmp() isn't necessary anymore either. --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -39,7 +39,6 @@ #include "libiberty.h" #include "safe-ctype.h" -#include typedef struct instr_info instr_info; static bool dofloat (instr_info *, int); @@ -133,7 +132,6 @@ struct dis_private { bfd_byte the_buffer[MAX_MNEM_SIZE]; bfd_vma insn_start; int orig_sizeflag; - OPCODES_SIGJMP_BUF bailout; }; enum address_mode @@ -9842,9 +9840,6 @@ print_insn (bfd_vma pc, disassemble_info ins.op_out[i] = op_out[i]; } - if (OPCODES_SIGSETJMP (priv.bailout) != 0) - return fetch_error (&ins); - sizeflag = priv.orig_sizeflag; switch (ckprefix (&ins)) From patchwork Tue Apr 4 07:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 78875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2824976vqo; Tue, 4 Apr 2023 00:03:31 -0700 (PDT) X-Google-Smtp-Source: AKy350ZhohDaoCCr3/bLFen4WxiCGHs+qrjCt4WQtomFP60xlJZ23ORt4Ivk/HFiBMIZ8NTIjHtj X-Received: by 2002:a05:6402:558:b0:500:50f6:dd33 with SMTP id i24-20020a056402055800b0050050f6dd33mr1606884edx.2.1680591811750; Tue, 04 Apr 2023 00:03:31 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u25-20020aa7d999000000b004fb3426ea95si10005329eds.322.2023.04.04.00.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 00:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZJN3kVGu; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2A99387689F for ; Tue, 4 Apr 2023 07:02:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2A99387689F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680591723; bh=xkfqYloa/PDiwlCbb1vyR9GZmXPsT1zKijns1eXwzQs=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ZJN3kVGuOn+VqaIYMatdquY4/RUg8QJL9A72A95Lx5REnfkrsVyOFm00Yqm7yORVq Frtg1Mtx/oGJi9NzeDSyTQby/gIqpzAeqjnfT917zuwLwikssgKVdH2lGRYJvRZalm 8X3FZYyY8J5YiH2KeTYqyTLcb0IW4FCiBvmkhmsc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2041.outbound.protection.outlook.com [40.107.241.41]) by sourceware.org (Postfix) with ESMTPS id 023E9387089E for ; Tue, 4 Apr 2023 07:01:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 023E9387089E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+WNI3VBJSBF7ivtG9sb+At5zyiyXmYRTZty6h7b+FOyQBx5UuzwMAW1kSdgoTXPjE36V42/A7m56tLk6mpmP1vkXbbSEIEost66avaxroK1MbYDq0/ttQGk9KTCS0ozsO5+maGW90SkV1RkzWc2iapVMXpGeBv76U+oGpaTSIQ683abxPy9fYcdtWHqpYqaeOqRkpwQnKZOBQWY3+s+ksYA0JjXnKCxyxNB+84poOd8nd7m5rIe+nngqnjKyoeeGNTJsGw6zgso9rpx1znkYmInEwq0hfSRD5B+WkbDHK9nM95tk4pNRyUTGkCY53NJ5c2z5DRWvhqpGkNdlnGicw== 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=xkfqYloa/PDiwlCbb1vyR9GZmXPsT1zKijns1eXwzQs=; b=Zlue9a3PI/o/wp85cV52hSEDXEuAx4+NfcORVlE/noH8w1bcqmqDiu6C59EzmjgaihLAfXaSiHRZSTSOnvTsYiT4WpfyJSDmeAIfenbhAOfdwmbmj1mSRJHb/aVJPu3bR9YuW/SGt4hYSbi6068hHd6ren/dbYaUxTTYetHUSxOuXSWv4XkmPGRGrYPTLSOKXnUlbyflQ7AMqNNuU+7TnlLk8cVCq908tCCnqChN+9//7sbjuCSVCi9PAUEuieYiY1Y7WROz4YN1jp6kJh1+ctx9onhehfQ5fq9m/M1TVxDNly82dBNvuSr84EQo2r6OXlxm4WWXIOc7gOSmOMv8Uw== 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 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8609.eurprd04.prod.outlook.com (2603:10a6:20b:424::9) 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:01:33 +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:01:33 +0000 Message-ID: <4eed4c72-002f-268e-b5cd-0929bc57d6d2@suse.com> Date: Tue, 4 Apr 2023 09:01:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: [PATCH 8/8] x86: drop (explicit) BFD64 dependency from disassembler Content-Language: en-US To: Binutils Cc: "H.J. Lu" , Alan Modra References: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> In-Reply-To: <5dac45a8-cd5f-ee4d-52fc-7d283fc29ec4@suse.com> X-ClientProxiedBy: FR2P281CA0040.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:92::7) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8609:EE_ X-MS-Office365-Filtering-Correlation-Id: 88bc02e5-45d0-43bc-f7c6-08db34da6c62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXhv1G5cbivlM9B+UjogR6rCii/idR0ARCX5fxQ46r+4QJHpt7PFLyO8V9rzNJ5c1FppQEjCEkl5H/ZYDLnpyc5CPksZoLtAdmu9IBzRBnNEJVn9nDT3mwHuYdLmBI1rvmbAitFrMdSREdBDipw5abqEDXjs2SE+JeaIZxB8bWG1+EzPcWhrw65mgOEu+N1ZiREgzAkjTAQTaxS4wVe7crQYe3H4ifiJRzR7yqVhIPsj9hRL11gZdpUYKhAHijoarwC/jcZt4SusGC5GN2zitdlqYAigVZnC0L2XKzDEgi5CuzA//lS/znbC2W9nPqzc5Ngl81tC/aaNix3Xc6fVhCXlGN9NPS4TEX6y2tIDBwkFvJzo32YW87CET6ol4o7k1NjVtfZCXecWlU4Rtqu/6GEPo7/RahPrk3KHI/FaTUIUWmmJsHp5tFtuC/lEM31fa1Pu7hBT9nHHOST00DIgkjKtf9aQGSjhvDmb1vycJXsGoJwaHgdaAIJBPQKTo+qejM2dk3bGD4SvXY10oU8gEue+jpHtmcoqk7EmbKPbOQIqTWpiL3CmTmxChWKfhwVA00umRjIxuV3tFEz+C8eOr9haxtvSGakX8hoU9rLiJJvDjdTu1hEaJ5G1C+LNzpzvAwqjXM+Vzfvd890b0GU0Kw== 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)(39860400002)(136003)(376002)(366004)(346002)(396003)(451199021)(31686004)(6486002)(54906003)(66476007)(66556008)(66946007)(8676002)(41300700001)(6916009)(4326008)(31696002)(36756003)(478600001)(316002)(86362001)(38100700002)(6506007)(6512007)(186003)(2616005)(8936002)(2906002)(5660300002)(26005)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/U+6aLJr59/wXGAHLhR9AeAx4PjX?= =?utf-8?q?OsnCziPCpPRAc9GLilGJHTuWL/lyB8kv/OIu+3vIUBWiOUGTom32hVwQgHsFFfX2V?= =?utf-8?q?1v2fYFK5bb7rR6rtMYWmbBqlN2x3xsY91og7P3p1ccMOX/NkV5tNvs6jjI2eRZFg2?= =?utf-8?q?eMCaTJ/pqP9rc8CgCcFXGNbtvNGBRA9RmOID0XR1igwDxJyLr+rvKBd0/g2DCYTm6?= =?utf-8?q?C6tS4f++P9aePMJhYDZJgTAjEfvbIfYcmCDaI1exkAbtX90o7NQ8KWpoHpyjGeq8L?= =?utf-8?q?aL62d48byCb4B6iojbv2UZoX2r2+iupC9P6X/vyM6qhST9OUar53gKfWAg28NUX68?= =?utf-8?q?spQZTyN5RQleqEL/YHQqynvLgpZ6/7Aykbg84Wp+Ox7X0285ilbeYTih95BX10AJn?= =?utf-8?q?QJu5iWaOsoSqRwsXllNs/nSP5ruICy/rJB09c5rDpvp5BASFXdlZbcolu+m+ajHqf?= =?utf-8?q?gtVhvWPcG/yX+2Koov4Li63+6ApMJVaEeww9aGtU8daJ3qITZzvsVaHO9IDT9LYsw?= =?utf-8?q?FnLDRzspe2XXa8omSl1Qtf6L1TCNeLXMrAbBob7Ljoa0zO838gt0BoISes7a6jc4a?= =?utf-8?q?hry2w0vY3ocS+BVW4e5uJmPaXGIEJlN/mdaKYjTBcmRz7pVl/JN9z2DTkRw2xR3QY?= =?utf-8?q?8my6R5kyohUlre8GQXXubBIto302fyvX7ZtddZWqBf7GVWpU4qQ1E95cQNFepUhHb?= =?utf-8?q?pOrT+gh2Wy/BwJzq9UntC96wqiEwwx4zkPxN7T6bqmP0WQLdFKD5Ier4NScd7Vtlt?= =?utf-8?q?TaUvCyncSlbvYwMVnCUZy2JAxvg+aZ0PVM6gIs9o8+aYp+6VSYkXvYFGjesdfT5jx?= =?utf-8?q?0YJHXp/CngfKeB1OxtZDgc6+SCCCjHQ9Mn4y+hG+oUGcQzb6zQhZR1i9JvzrikLGV?= =?utf-8?q?0k4jcVuzFgI6uPlFfatCDFQ/mvsy1l1g5rClUfk2OkDjg7zh0ezvSoY5BOtyRG9gG?= =?utf-8?q?xPoiLCKAsWSEVK2PD28qE5p5hM+WjQxdcl8huz2P9mapyy89QpXgiXXDRLI9DoO5Z?= =?utf-8?q?gTgRhdUomyZ9KvvTUJ1Adoezernypvr3EzZaCiWsesnGEgeSkZU/8z4h1N2CWCXES?= =?utf-8?q?fEEKRPaz/6HCBTVJ5iavHtQNV5kiMqGGOhJyUZW8zOw3dO/1e3Wa1ft/H2ymlKt8j?= =?utf-8?q?vppokQ71zSvLfd9RnSY1hhVn5v6pYMhtcqHWbs1INAL8vWiClGVamW1MWnk516xrs?= =?utf-8?q?vx7nUWuPmK2VlDbsY5sFRZgAPnajlLR++8qXhJpjU1KJHyfp0HEt8bSEn9OeABNQK?= =?utf-8?q?pF6pqUQpa7nBuvwuky3tqzPMZIvAmeGA3wo0CvrGG9hK6ZysyBVZjZuHpNXmHV7e9?= =?utf-8?q?y+ADQSRbwNZXTJgKpPhcnqUeaaO4/8fsS+lN6baSAQgJLKLgM8BqQdmD3LC7v2AX4?= =?utf-8?q?cuJuk2lQcM+sOakpRjeXTPEi8LYagGw3GWDl8p+YHOOBVp22lWahQ+iYYLKBqVd5y?= =?utf-8?q?w/zRoii/2Tb00osoXOCy+sovRCbiF1pNEEdzgHaHMPAcZmlc0DDw+GjwW5J3w2fQ1?= =?utf-8?q?Pfl8SGKrWQGH?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88bc02e5-45d0-43bc-f7c6-08db34da6c62 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:01:33.1319 (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: P0eOX82Mb+lFtZ+2dw2huVRciBLCwIVyizFO+3r5TsNkKkt2RG/qe0V5DgjtmNHrkiE+nMoMcjudqP6S8L3Yfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8609 X-Spam-Status: No, score=-3027.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762228239833062523?= X-GMAIL-MSGID: =?utf-8?q?1762228239833062523?= x86: drop (explicit) BFD64 dependency from disassembler get64() is unreachable when !BFD64 (due to a check relatively early in print_insn()). Let's avoid the associated #ifdef-ary (or else we should extend it to remove more dead code). --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -12329,9 +12329,8 @@ OP_G (instr_info *ins, int bytemode, int return true; } -#ifdef BFD64 static bool -get64 (instr_info *ins, bfd_vma *res) +get64 (instr_info *ins, uint64_t *res) { unsigned int a; unsigned int b; @@ -12346,17 +12345,9 @@ get64 (instr_info *ins, bfd_vma *res) b |= (*ins->codep++ & 0xff) << 8; b |= (*ins->codep++ & 0xff) << 16; b |= (*ins->codep++ & 0xffu) << 24; - *res = a + ((bfd_vma) b << 32); + *res = a + ((uint64_t) b << 32); return true; } -#else -static bool -get64 (instr_info *ins ATTRIBUTE_UNUSED, bfd_vma *res ATTRIBUTE_UNUSED) -{ - abort (); - return false; -} -#endif static bool get32 (instr_info *ins, bfd_signed_vma *res) @@ -12571,7 +12562,7 @@ OP_I (instr_info *ins, int bytemode, int static bool OP_I64 (instr_info *ins, int bytemode, int sizeflag) { - bfd_vma op; + uint64_t op; if (bytemode != v_mode || ins->address_mode != mode_64bit || !(ins->rex & REX_W)) @@ -12785,7 +12776,7 @@ OP_OFF (instr_info *ins, int bytemode, i static bool OP_OFF64 (instr_info *ins, int bytemode, int sizeflag) { - bfd_vma off; + uint64_t off; if (ins->address_mode != mode_64bit || (ins->prefixes & PREFIX_ADDR))