[PATCH gas/m68k] Fix a register range check

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH gas/m68k] Fix a register range check

Gunther Nikl-2
Hello!

Building an older binutils version with clang 10 produced an unexpected
warning message: "overlapping comparisons always evaluate to true". And
indeed, a register range check erroneously used a "logical or" instead
of an "and". This bug is still present in master.

Checking the history of tc-m68k.c shows that this particular bug is really
an ancient one. It was introduced with the creation of the bison grammar
for operand parsing in 1995!


Regards,
Gunther Nikl

2020-03-27  Gunther Nikl  <[hidden email]>

       * config/tc-m68k.c (m68k_ip): Fix range check for index register
       with a suppressed address register.

-- cut --
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index 5483f8e017..fef91706c1 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -2794,7 +2797,7 @@ m68k_ip (char *instring)
       && opP->index.reg <= ZDATA7)
     nextword |= (opP->index.reg - ZDATA0) << 12;
   else if (opP->index.reg >= ZADDR0
-   || opP->index.reg <= ZADDR7)
+   && opP->index.reg <= ZADDR7)
     nextword |= (opP->index.reg - ZADDR0 + 8) << 12;
  }
 
-- cut --
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH gas/m68k] Fix a register range check

Sourceware - binutils list mailing list
On Fri, Mar 27, 2020 at 08:25:26PM +0100, Gunther Nikl wrote:
>        * config/tc-m68k.c (m68k_ip): Fix range check for index register
>        with a suppressed address register.

OK.

--
Alan Modra
Australia Development Lab, IBM
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH gas/m68k] Fix a register range check

Gunther Nikl-2
On Tue, 31 Mar, 2020 18:01:52 +1030, Alan Modra wrote:
>
> On Fri, Mar 27, 2020 at 08:25:26PM +0100, Gunther Nikl wrote:
> >        * config/tc-m68k.c (m68k_ip): Fix range check for index
> > register with a suppressed address register.
>
> OK.

Please commit, I don't have write access.

Regards,
Gunther Nikl
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH gas/m68k] Fix a register range check

Sourceware - binutils list mailing list
Hi Gunther,

>> OK.
> Please commit, I don't have write access.

Done.

Cheers
  Nick


Reply | Threaded
Open this post in threaded view
|

[PATCH 2/4]: moxie: use generic pcrel support

Gunther Nikl-2
In reply to this post by Gunther Nikl-2
[resent with correct reference]

The moxie target header uses md_pcrel_from, thus the local prototype and
the macro definition for MD_PCREL_FROM_SECTION are not needed.


2020-XX-XX  Gunther Nikl  <[hidden email]>

        * config/tc-moxie.h (MD_PCREL_FROM_SECTION): Delete define.
        (md_pcrel_from): Remove prototytpe.

diff --git a/gas/config/tc-moxie.h b/gas/config/tc-moxie.h
index 80f7f6c402..a66b60affe 100644
--- a/gas/config/tc-moxie.h
+++ b/gas/config/tc-moxie.h
@@ -36,12 +36,4 @@
 #define md_estimate_size_before_relax(A, B) (as_fatal (_("estimate size\n")), 0)
 #define md_convert_frag(B, S, F)            as_fatal (_("convert_frag\n"))
 
-/* If you define this macro, it should return the offset between the
-   address of a PC relative fixup and the position from which the PC
-   relative adjustment should be made.  On many processors, the base
-   of a PC relative instruction is the next instruction, so this
-   macro would return the length of an instruction.  */
-#define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from (FIX)
-extern long md_pcrel_from (struct fix *);
-
 #define md_section_align(SEGMENT, SIZE)     (SIZE)