Bug 21118 - As silently converts registers to immediates
Summary: As silently converts registers to immediates
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.25
: P2 enhancement
Target Milestone: 2.29
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-09 08:25 UTC by nikita
Modified: 2017-12-12 00:47 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc*-*-*
Build:
Last reconfirmed: 2017-02-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nikita 2017-02-09 08:25:31 UTC
Tested on 32-bit PowerPC Debian in QEMU: when compiled with -mregnames, addi r30,r30,r5 becomes addi r30,r30,5 when disassembled. Yes, the instruction expects an immediate as the third argument and add works as expected, but I'd like to get at least a warning. Nothing is printed with -Wall -Werror.
Comment 1 Alan Modra 2017-02-11 07:42:17 UTC
True for current master too.
Comment 2 Sourceware Commits 2017-02-14 10:43:07 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=606a935e3a9066ab11308b8c934c9bdec7f128d3

commit 606a935e3a9066ab11308b8c934c9bdec7f128d3
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Feb 14 20:30:27 2017 +1030

    Fix powerpc testsuite source errors
    
    PR 21118 work exposed these errors in the testsuite.
    
    	* testsuite/gas/ppc/cell.s: Correct invalid registers.
    	* testsuite/gas/ppc/vle-simple-1.s: Likewise.
    	* testsuite/gas/ppc/vle-simple-2.s: Likewise.
Comment 3 Sourceware Commits 2017-02-14 10:43:13 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e0de605cbacbbbb2531bb70506c0843aea13111

commit 7e0de605cbacbbbb2531bb70506c0843aea13111
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Feb 14 20:38:21 2017 +1030

    PowerPC register expression checks
    
    This stops powerpc gas blithely accepting such nonsense as
    "addi %f4,%cr3,%r31".
    
    	PR 21118
    gas/
    	* NEWS: Mention powerpc register checks.
    	* config/tc-ppc.c (struct pd_reg): Make value a short.  Add flags.
    	(pre_defined_registers): Delete fpscr and pmr entries.  Set
    	register type in flags.
    	(cr_names): Set type in flags.
    	(reg_name_search): Return pointer to struct pd_reg rather than value.
    	(register_name): Adjust to suit.  Set X_md from flags.
    	(ppc_parse_name): Likewise.
    	(ppc_optimize_expr): New function.
    	(md_assemble): Verify expresion reg flags match operand.
    	* config/tc-ppc.h (md_optimize_expr): Define.
    	(ppc_optimize_expr): Declare.
    include/
    	* opcode/ppc.h (PPC_OPERAND_*): Reassign values, regs first.
    	(PPC_OPERAND_SPR, PPC_OPERAND_GQR): Define.
    opcodes/
    	* ppc-opc.c (powerpc_operands): Flag SPR, SPRG and TBR entries
    	with PPC_OPERAND_SPR.  Flag PSQ and PSQM with PPC_OPERAND_GQR.
Comment 4 Sourceware Commits 2017-02-14 10:46:10 UTC
The binutils-2_28-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ce45602b476d30f2ca354691374a092886b64951

commit ce45602b476d30f2ca354691374a092886b64951
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Feb 14 20:30:27 2017 +1030

    Fix powerpc testsuite source errors
    
    PR 21118 work exposed these errors in the testsuite.
    
    	* testsuite/gas/ppc/cell.s: Correct invalid registers.
    	* testsuite/gas/ppc/vle-simple-1.s: Likewise.
    	* testsuite/gas/ppc/vle-simple-2.s: Likewise.
Comment 5 Alan Modra 2017-02-14 11:47:37 UTC
Fixed.
Comment 6 Sourceware Commits 2017-02-20 10:32:34 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ece5dcc1c00a48ecf63eae71983d04270cef4280

commit ece5dcc1c00a48ecf63eae71983d04270cef4280
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 20 12:06:52 2017 +1030

    Downgrade powerpc register error to warning
    
    	PR 21118
    	* NEWS: Revise powerpc register check.
    	* config/tc-ppc.c (ppc_optimize_expr, md_assemble): Make "invalid
    	register expression" a warning.
Comment 7 Sourceware Commits 2017-12-12 00:36:35 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4b1c0f7e85f2aec3df3498d04b5beaf45813dea8

commit 4b1c0f7e85f2aec3df3498d04b5beaf45813dea8
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Dec 12 10:56:23 2017 +1030

    Don't mask X_add_number containing a register number
    
    It's obviously wrong to mask SPRs to 8 bits.
    
    	PR 21118
    	* config/tc-ppc.c (md_assemble): Don't mask register number.
Comment 8 Sourceware Commits 2017-12-12 00:47:03 UTC
The binutils-2_29-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b2bcbfb760e747cf811e4756ce396e973e7094ae

commit b2bcbfb760e747cf811e4756ce396e973e7094ae
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Dec 12 10:56:23 2017 +1030

    Don't mask X_add_number containing a register number
    
    It's obviously wrong to mask SPRs to 8 bits.
    
    	PR 21118
    	* config/tc-ppc.c (md_assemble): Don't mask register number.
    
    (cherry picked from commit 4b1c0f7e85f2aec3df3498d04b5beaf45813dea8)