This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATH] nios2: Fix parsing of pseudo-instructions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]