]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att...
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 17:07:54 +0000 (18:07 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 19:12:57 +0000 (20:12 +0100)
commitd1c29dc8a3b9c776919e7d1489d45060d2c24f2a
tree1fcc618c9090f86838d25c0540a1a07119710d1e
parent18cfaa4217fabce8df0f2aac5367bf4952a13f51
i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att [PR91298]

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.

2020-01-22  Jakub Jelinek  <jakub@redhat.com>

PR target/91298
* output.h (assemble_name_resolve): Declare.
* varasm.c (assemble_name_resolve): New function.
(assemble_name): Use it.
* config/i386/i386.h (ASM_OUTPUT_SYMBOL_REF): Define.

* gcc.target/i386/pr91298-1.c: New test.
* gcc.target/i386/pr91298-2.c: New test.
gcc/ChangeLog
gcc/config/i386/i386.h
gcc/output.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr91298-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr91298-2.c [new file with mode: 0644]
gcc/varasm.c