Bug 5712 - gas can't parse ARM .save directives for FPA registers
Summary: gas can't parse ARM .save directives for FPA registers
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
Depends on:
Reported: 2008-02-01 23:18 UTC by Dimitry Andric
Modified: 2008-02-14 16:37 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: arm-omap2-linux-gnueabi
Build: i686-pc-linux-gnu
Last reconfirmed:

Test case for .save of an FPA register (41 bytes, text/plain)
2008-02-01 23:21 UTC, Dimitry Andric
Fix for properly parsing .save directives with an FPA register (721 bytes, patch)
2008-02-01 23:22 UTC, Dimitry Andric
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric 2008-02-01 23:18:35 UTC
According to the docs here:


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.


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