From: Luis Machado <luis.machado@linaro.org>
To: Simon Marchi <simon.marchi@polymtl.ca>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: -Wtautological-bitwise-compare error in arm-tdep.c
Date: Mon, 25 May 2020 10:08:11 -0300 [thread overview]
Message-ID: <98a9d90b-0452-5b53-b707-9441ebcad6b7@linaro.org> (raw)
In-Reply-To: <fa18d42b-0365-762a-76af-589223cc05d2@polymtl.ca>
[-- Attachment #1: Type: text/plain, Size: 897 bytes --]
Hi,
On 5/15/20 5:32 PM, Simon Marchi via Gdb-patches wrote:
> We get this error in arm-tdep.c when building with clang 11:
>
> CXX arm-tdep.o
> /home/smarchi/src/binutils-gdb/gdb/arm-tdep.c:934:29: error: bitwise comparison always evaluates to false [-Werror,-Wtautological-bitwise-compare]
> else if ((insn & 0xffb0) == 0xe950 /* ldrd Rt, Rt2,
> ~~~~~~~~~~~~~~~~^~~~~~~~~
>
> Indeed, this can never evaluate to true. I tried to look at what the condition
> should be, but it's a bit too deep into ARM instruction encoding for me. I am
> pretty sure that the corresponding section in the ARM Architecture Reference
> Manual [1] is F3.1.15, if somebody wants to take a stab at it.
>
> Simon
>
> [1] https://static.docs.arm.com/ddi0487/fb/DDI0487F_b_armv8_arm.pdf
>
The following patch should fix clang's error and make the code do the
right thing.
[-- Attachment #2: 0001-ARM-Fix-PR-26000-logical-bitwise-error-prologue-anal.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]
From dbaf5e7b1f35c7e97bf23aac846509b33eea491b Mon Sep 17 00:00:00 2001
From: Luis Machado <luis.machado@linaro.org>
Date: Fri, 15 May 2020 23:06:52 -0300
Subject: [PATCH] [ARM] Fix PR 26000, logical bitwise error / prologue analyzer
This fixes an instruction mask typo. We should be matching only
ldrd (immediate) and not any other of its variants. As is, it never matches
anything.
With the patch, the instruction mask also allows matching of ldrd (literal),
but the check for SP discards this particular instruction pattern, as it has
a hardcoded PC register.
gdb/ChangeLog:
2020-05-25 Luis Machado <luis.machado@linaro.org>
PR tdep/26000
* arm-tdep.c (thumb_analyze_prologue): Fix instruction matching
for ldrd (immediate).
---
gdb/arm-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 40bffbb2dd..9a73b85899 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -931,7 +931,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
parameters from memory. */
;
- else if ((insn & 0xffb0) == 0xe950 /* ldrd Rt, Rt2,
+ else if ((insn & 0xff70) == 0xe950 /* ldrd Rt, Rt2,
[Rn, #+/-imm] */
&& pv_is_register (regs[bits (insn, 0, 3)], ARM_SP_REGNUM))
/* Similarly ignore dual loads from the stack. */
--
2.17.1
next prev parent reply other threads:[~2020-05-25 13:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 20:32 Simon Marchi
2020-05-15 20:41 ` Luis Machado
2020-05-15 20:57 ` Simon Marchi
2020-05-25 13:08 ` Luis Machado [this message]
2020-05-25 13:49 ` Simon Marchi
2020-05-25 13:51 ` Luis Machado
2020-05-26 9:45 ` Alan Hayward
2020-05-26 12:17 ` Luis Machado
2020-05-26 16:10 ` Alan Hayward
2020-05-27 12:43 ` Luis Machado
2020-05-27 14:00 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98a9d90b-0452-5b53-b707-9441ebcad6b7@linaro.org \
--to=luis.machado@linaro.org \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).