This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATH] nios2: Fix parsing of pseudo-instructions
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: Henry Wong <henry at stuffedcow dot net>, <binutils at sourceware dot org>
- Date: Mon, 2 Oct 2017 17:24:23 -0600
- Subject: Re: [PATH] nios2: Fix parsing of pseudo-instructions
- Authentication-results: sourceware.org; auth=none
- References: <ae0deb04-186c-3e63-b045-32692e1c2f95@stuffedcow.net>
On 09/27/2017 05:18 PM, Henry Wong wrote:
The Nios II assembler handles pseudo-instructions by "suitable fiddling
with the operands". When a malformed pseudo-instruction is used (too few
operands), nios2_modify_arg/nios2_negate_arg blindly modifies operands
that may not exist, causing a segfault. This patch checks that a
pseudo-instruction has enough operands before trying to modify them, for
cases where it matters.
Thank you for reporting this bug.
Changes:
* config/tc-nios2.c (nios2_modify_arg, nios2_negate_arg): Fix segfault
when parsing Nios II pseudo-instructions that have missing arguments
* testsuite/gas/nios2/illegal_pseudoinst.s: New test for illegal Nios II
pseudo-instructions
* testsuite/gas/nios2/illegal_pseudoinst.l: stderr output
* testsuite/gas/nios2/nios2.exp: Changed so the above new test is run.
Hmmm. I think it would be better to put a more general check for the
right number of arguments in nios2_translate_pseudo_insn; add a field to
nios2_ps_insn_infoS to hold the expected number of arguments for the
pseudo-op, and check it before dispatching to arg_modifier_func.
Also, your patch doesn't follow GNU coding standards with regards to
whitespace and indentation.
Do you want to submit a revised patch, or have me handle the fix?
-Sandra