Hi Jakub,
> In AT&T syntax leading $ is special, so if we have identifiers that start
> with dollar, we usually fail to assemble it (or assemble incorrectly).
> As mentioned in the PR, what works is wrapping the identifiers inside of
> parens, like:
> movl $($a), %eax
> leaq ($a)(,%rdi,4), %rax
> movl ($a)(%rip), %eax
> movl ($a)+16(%rip), %eax
> .globl $a
> .type $a, @object
> .size $a, 72
> $a:
> .string "$a"
> .quad ($a)
> (this is x86_64 -fno-pic -O2). In some places ($a) is not accepted,
> like as .globl operand, in .type, .size, so the patch overrides
> ASM_OUTPUT_SYMBOL_REF rather than e.g. ASM_OUTPUT_LABELREF.
> I didn't want to duplicate what assemble_name is doing (following
> transparent aliases), so split assemble_name into two parts; just
> mere looking at the first character of a name before calling assemble_name
> wouldn't be good enough, a transparent alias could lead from a name
> not starting with $ to one starting with it and vice versa.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
the new testcases FAIL on Solaris/x86 with the native assembler:
+FAIL: gcc.target/i386/pr91298-1.c (test for excess errors)
Excess errors:
Assembler: pr91298-1.c
"/var/tmp//ccE6r3xb.s", line 5 : Syntax error
Near line: " .globl $quux"
"/var/tmp//ccE6r3xb.s", line 6 : Syntax error
Near line: " .type $quux, @function"
"/var/tmp//ccE6r3xb.s", line 7 : Syntax error
Near line: "$quux:"
"/var/tmp//ccE6r3xb.s", line 15 : Syntax error
Near line: " .size $quux, .-$quux"
"/var/tmp//ccE6r3xb.s", line 24 : Syntax error
Near line: " movl $($a), %eax"
"/var/tmp//ccE6r3xb.s", line 38 : Syntax error
Near line: " leal ($a)(,%eax,4), %eax"
"/var/tmp//ccE6r3xb.s", line 51 : Syntax error
Near line: " movl ($a), %eax"
"/var/tmp//ccE6r3xb.s", line 63 : Syntax error
Near line: " movl ($a)+16, %eax"
"/var/tmp//ccE6r3xb.s", line 97 : Syntax error
Near line: " movl $($quux), %eax"
"/var/tmp//ccE6r3xb.s", line 101 : Syntax error
Near line: " .globl $a"
"/var/tmp//ccE6r3xb.s", line 104 : Syntax error
Near line: " .type $a, @object"
"/var/tmp//ccE6r3xb.s", line 105 : Syntax error
Near line: " .size $a, 72"
"/var/tmp//ccE6r3xb.s", line 106 : Syntax error
Near line: "$a:"
"/var/tmp//ccE6r3xb.s", line 228 : Syntax error
Near line: " .long ($a)"
+FAIL: gcc.target/i386/pr91298-2.c (test for excess errors)
It only allows letters, digits, '_' and '.' in identifiers:
https://docs.oracle.com/cd/E37838_01/html/E61064/eqbsx.html#XALRMeoqjw
Right now, we don't have an effective-target keyword matching
-fdollars-in-identifiers. There are only 3 other tests using that
option:
gcc.dg/cpp/lexident.c preprocess only
gcc.dg/ucnid-5-utf8.c skipped on avr*-*, powerpc-ibm-aix* (no $)
skipped if ! ucn
gcc.dg/ucnid-5.c skipped on avr*-*, powerpc-ibm-aix* (no $)
So we might just xfail the new ones on *86*-*-solaris2* && !gas, I guess.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University