From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 642A13858C83 for ; Tue, 15 Feb 2022 17:04:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 642A13858C83 Received: by mail-pj1-x1030.google.com with SMTP id t4-20020a17090a510400b001b8c4a6cd5dso2659757pjh.5 for ; Tue, 15 Feb 2022 09:04:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XybjrVj2vjlOwMt5wS5ZfA0sIGlw82mq0kDE7cHdxns=; b=1LcaD9fa6tzUmqay5bt1dIh4B4XkGGpatubRN/7ziPpo81FpG8iNTb+s7YDSfAmt+o CYIdHSnM3CW6muymATn1d3lkoDL+/+5NXAgtannXTxoEmaP921oj3tEl72BvQGQO5YUC goxg2siAEBTn3yST3WjGWyNKfz5onKUX/lAE1jIbFoniis4IJmocrUdYjfTBMC7R/5+d lLbsdnvfgVTorQ/Q+N+t9BhVw/l+CZMmDP4PrmwUmOgrtaWMuFYBgBUmGNAqB9MYxprF SNNeipbt+QVHq/AawZzvmB1Bxdp+Uo3fxv5acjvyFD+AHjl4s+s7+SWi3xyfXQA7yo8s VEBw== X-Gm-Message-State: AOAM531wnflw6TYHQPxCISw2MUXu4XUoFVfBINIknBW2UK6q1rf1iTYB q719kEFEIAHo6rX7ZNHCnamcmy5Siug= X-Google-Smtp-Source: ABdhPJxK38YfhIyS9oi12XgEQ1oUmgorrW0lBEF7WQno9XsrHA2vad7X7w6L77uOjnX0V+ukM2NIYg== X-Received: by 2002:a17:90b:157:: with SMTP id em23mr5397872pjb.239.1644944683210; Tue, 15 Feb 2022 09:04:43 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id e13sm8963951pfv.190.2022.02.15.09.04.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 09:04:42 -0800 (PST) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id EF749C02EA for ; Tue, 15 Feb 2022 09:04:40 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] x86: Add has_sib to struct instr_info Date: Tue, 15 Feb 2022 09:04:40 -0800 Message-Id: <20220215170440.3599833-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3029.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 17:04:46 -0000 Add has_sib to struct instr_info and use SIB info only if ins->has_sib is true. PR binutils/28892 * i386-dis.c (instr_info): Add has_sib. (get_sib): Set has_sib. (OP_E_memory): Replace havesib with ins->has_sib. (OP_VEX): Use ins->sib.index only if ins->has_sib is true. --- opcodes/i386-dis.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 862bd80b1bc..a30bda0633b 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -153,6 +153,7 @@ struct instr_info bool need_modrm; bool need_vex; + bool has_sib; /* Flags for ins->prefixes which we somehow handled when printing the current instruction. */ @@ -9291,7 +9292,10 @@ get_sib (instr_info *ins, int sizeflag) ins->sib.index = (ins->codep[1] >> 3) & 7; ins->sib.scale = (ins->codep[1] >> 6) & 3; ins->sib.base = ins->codep[1] & 7; + ins->has_sib = true; } + else + ins->has_sib = false; } /* Like oappend (below), but S is a string starting with '%'. @@ -11396,7 +11400,6 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) { /* 32/64 bit address mode */ int havedisp; - int havesib; int havebase; int needindex; int needaddr32; @@ -11411,13 +11414,11 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) bool check_gather = false; const char *const *indexes = NULL; - havesib = 0; havebase = 1; base = ins->modrm.rm; if (base == 4) { - havesib = 1; vindex = ins->sib.index; USED_REX (REX_X); if (ins->rex & REX_X) @@ -11487,7 +11488,7 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) if (base == 5) { havebase = 0; - if (ins->address_mode == mode_64bit && !havesib) + if (ins->address_mode == mode_64bit && !ins->has_sib) riprel = 1; disp = get32s (ins); if (riprel && bytemode == v_bndmk_mode) @@ -11512,7 +11513,7 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) needindex = 0; needaddr32 = 0; - if (havesib + if (ins->has_sib && !havebase && !indexes && ins->address_mode != mode_16bit) @@ -11538,7 +11539,7 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) havedisp = (havebase || needindex - || (havesib && (indexes || scale != 0))); + || (ins->has_sib && (indexes || scale != 0))); if (!ins->intel_syntax) if (ins->modrm.mod != 0 || base == 5) @@ -11576,7 +11577,7 @@ OP_E_memory (instr_info *ins, int bytemode, int sizeflag) oappend_maybe_intel (ins, (ins->address_mode == mode_64bit && !addr32flag ? att_names64 : att_names32)[rbase]); - if (havesib) + if (ins->has_sib) { /* ESP/RSP won't allow index. If base isn't ESP/RSP, print index to tell base + index from base. */ @@ -13190,7 +13191,7 @@ OP_VEX (instr_info *ins, int bytemode, int sizeflag ATTRIBUTE_UNUSED) if (ins->rex & REX_R) modrm_reg += 8; - if (ins->modrm.rm == 4) + if (ins->has_sib && ins->modrm.rm == 4) { sib_index = ins->sib.index; if (ins->rex & REX_X) -- 2.35.1