Bug 6926 - Macro number feature \@ conflicting with @ in line_separator_chars
Summary: Macro number feature \@ conflicting with @ in line_separator_chars
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-30 23:35 UTC by Hans-Peter Nilsson
Modified: 2008-10-06 08:18 UTC (History)
1 user (show)

See Also:
Host:
Target: cris-axis-linux-gnu
Build:
Last reconfirmed:


Attachments
Allow escaped end of line characters (1.32 KB, patch)
2008-10-02 16:58 UTC, Nick Clifton
Details | Diff
Revised patch to specially target macros (1.57 KB, patch)
2008-10-03 15:10 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2008-09-30 23:35:20 UTC
The CRIS port has const char line_separator_chars[] = "@";
Apparently this causes a conflict with the \@ macro invocation number counter,
as evident by building and checking for cris-axis-linux-gnu:
Running x/src/ld/testsuite/ld-elf/elf.exp ...
FAIL: ld-elf/multibss1

with ld.log saying:
x/src/ld/testsuite/ld-elf/multibss1.s: Assembler messages:
x/src/ld/testsuite/ld-elf/multibss1.s:2: Warning: stray `\'
x/src/ld/testsuite/ld-elf/multibss1.s: Assembler messages:
x/src/ld/testsuite/ld-elf/multibss1.s:2: Warning: stray `\'

I guess the simplest and most obvious route would be to make the \ escape any
special meaning of the following char (the line-separatorness of @ for this case
and perhaps similarly for comment_chars; haven't tested if there's a similar
FAIL for ARM where comment_chars contains @).  Note: DLX also has the same
line_separator_chars.
Comment 1 Hans-Peter Nilsson 2008-10-01 00:04:46 UTC
(In reply to comment #0)
> ...haven't tested if there's a similar
> FAIL for ARM where comment_chars contains @.

Nope, the test passes there.
Comment 2 Nick Clifton 2008-10-02 16:58:35 UTC
Created attachment 2978 [details]
Allow escaped end of line characters
Comment 3 Nick Clifton 2008-10-02 17:01:14 UTC
Hi Hans-Peter,

  The problem it seems to me is that we are not allowing escaped end-of-line
characters.

  Please could you try out the uploaded patch which I think will address the
problem.  I was not sure if we should change the default behaviour for other
ports (to allow escaped eol characters) so I left them alone.

Cheers
  Nick

PS.  The ARM port fixes the related problem with line_comment_chars in another
way - a horrible hack in do_scrub_chars().
Comment 4 Hans-Peter Nilsson 2008-10-03 00:04:08 UTC
While I do think tc_allow_escaped_end_of_line is overkill and being overcautious
that the canonical escape sequence won't fly, the patch certainly works for me.
 Thanks for fixing this so very promtly!
(I would have got to it sooner or later, probably later. ;)

Would you mind if I add a specific gas-testcase for \@ in a section directive
and elsewhere? Kinda odd that there wasn't any generic one. (Right, there are
target-specific ones: gas/cris/macroat and gas/arm/backslash-at.)
Comment 5 Hans-Peter Nilsson 2008-10-03 06:24:14 UTC
(In reply to comment #4)
> gas/cris/macroat
Come to think of it, that test shows that the \@ handling in .section is the
exception, as TRT already happens elsewhere.  Please reconsider doing it always
instead of having a tc_allow_escaped_end_of_line. Or rename it
tc_allow_escaped_end_of_line_in_pseudos_or_perhaps_just_dot_section. :)

BTW, I think @progbits and whatnot in .section is "correctly" handled, i.e. not
breaking the line.  Oddness galore.
Comment 6 Nick Clifton 2008-10-03 15:10:49 UTC
Created attachment 2980 [details]
Revised patch to specially target macros
Comment 7 Nick Clifton 2008-10-03 15:14:53 UTC
Hi Hans-Peter,

> Would you mind if I add a specific gas-testcase for \@ in a section directive
> and elsewhere?

Please do.

> Come to think of it, that test shows that the \@ handling in .section is the
> exception, as TRT already happens elsewhere.

Actually it was nothing to do with the .section directive.  It was all to do
with the expansion of the \@ sequence inside the body of a macro.

> Please reconsider doing it always

I have attached a revised patch which does this.  It has no target specific
features and it works for both the multibss.s and the macroat.s source files.
Please give it a try and let me know if you are happy with it.

Cheers
  Nick


Comment 8 Hans-Peter Nilsson 2008-10-04 16:46:04 UTC
(In reply to comment #7)
> Hi Hans-Peter,
> 
> > Would you mind if I add a specific gas-testcase for \@ in a section directive
> > and elsewhere?
> 
> Please do.
> 
> > Come to think of it, that test shows that the \@ handling in .section is the
> > exception, as TRT already happens elsewhere.
> 
> Actually it was nothing to do with the .section directive.  It was all to do
> with the expansion of the \@ sequence inside the body of a macro.

Of course, being the implied context of this PR, and no proof that enforcing
some quoting semantics elsewhere is desired or worthwhile.

> I have attached a revised patch
> Please give it a try and let me know if you are happy with it.

Happy, happy.  And so are cris-axis-elf, cris-axis-linux-gnu, arm-linux dlx-elf
and mmix-knuth-mmixware regression results FWIW.
Comment 9 Nick Clifton 2008-10-06 08:18:11 UTC
Patch checked in along with this changelog entry.

gas/ChangeLog
	PR 6926
	* read.c (get_line_sb): Renamed to get_non_macro_line_sb.
	(_find_end_of_line): Add extra parameter indicating if the line is
	inside a macro.  If it is then do not allow the @ character to be
	treated as a line separator character.
	(read_a_source): Update use of _find_end_of_line.
	(find_end_of_line): Likewise.
	(s_irp): Update use of get_line_sb.
	(s_macro): Likewise.
	(do_repeat): Likewise.
	(get_line_sb): New function.  Like the old version of get_line_sb
	except that it takes an extra parameter indicating whether the
	line is inside a macro.
	(get_macro_line_sb): New function.