Bug 5712

Summary: gas can't parse ARM .save directives for FPA registers
Product: binutils Reporter: Dimitry Andric <dimitry>
Component: gasAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils
Priority: P2    
Version: 2.19   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: arm-omap2-linux-gnueabi
Build: i686-pc-linux-gnu Last reconfirmed:
Attachments: Test case for .save of an FPA register
Fix for properly parsing .save directives with an FPA register

Description Dimitry Andric 2008-02-01 23:18:35 UTC
According to the docs here:

http://sourceware.org/binutils/docs-2.18/as/ARM-Directives.html#index-g_t_0040code_007b_002esave_007d-directive_002c-ARM-609

you should be able to specify an FPA register in ARM .save directives,
like the following:

        sfmfd   f4, 1, [sp]!
        .save f4, 1

These directives are usually generated by g++.  However, if you attempt
to assemble this, using "gas -mfpu=fpa", you'll get:

test.s: Assembler messages:
test.s:2: Error: expected , <constant>

This is because gas apparently doesn't skip the register name when
looking for the following comma.

The function s_arm_unwind_save(), in gas/config/tc-arm.c, peeks ahead
to parse the type of register that follows a .save directive, using
arm_reg_parse_mult().  When it finds a known register, it uses its
type to call the appropriate handler for that type.

Unfortunately, for FPA registers, it calls s_arm_unwind_save_fpa()
*without* advancing the input_line_pointer to just afer the register
name.  Since the first thing s_arm_unwind_save_fpa() expects to find
is a comma, it will always fail, with: "expected , <constant>".

Since arm_reg_parse_multi() already advanced the peek pointer to just
after the register name, just setting input_line_pointer to peek is a
nice, one-line fix.
Comment 1 Dimitry Andric 2008-02-01 23:21:24 UTC
Created attachment 2225 [details]
Test case for .save of an FPA register
Comment 2 Dimitry Andric 2008-02-01 23:22:45 UTC
Created attachment 2226 [details]
Fix for properly parsing .save directives with an FPA register
Comment 3 Nick Clifton 2008-02-14 16:37:08 UTC
Hi Dimitry,

  Thanks for reporting this problem and providing the patch to fix it.  I have
checked your patch in, along with the changelog entry below and I have also
added a testcase to the ARM specific section of the gas tests to make sure that
this problem does not resurface.

Cheers
  Nick

gas/ChangeLog
2008-02-14  Dimitry Andric  <dimitry@andric.com>

	PR gas/5712
	* config/tc-arm.c (s_arm_unwind_save): Advance the input line
	pointer past the comma after parsing a floating point register
	name.