[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |8.5 Known to work||10.1.0, 8.4.0, 8.5.0, 9.3.0 Known to fail||7.1.0, 7.5.0, 8.3.0, 9.1.0, ||9.2.0
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 Andrew Pinski changed: What|Removed |Added CC||harald at gigawatt dot nl --- Comment #15 from Andrew Pinski --- *** Bug 31782 has been marked as a duplicate of this bug. ***
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #14 from CVS Commits --- The releases/gcc-8 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:93266871ac794243e9785d92a0cec09b2fa5648b commit r8-10010-g93266871ac794243e9785d92a0cec09b2fa5648b Author: Jakub Jelinek Date: Fri Feb 14 15:43:47 2020 +0100 i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att [PR91298] In AT 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 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.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 Jakub Jelinek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #13 from Jakub Jelinek --- I guess we can.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 Martin Liška changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2020-01-28 CC||marxin at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #12 from Martin Liška --- @Jakub: Can we close this issue?
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #11 from CVS Commits --- The releases/gcc-9 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:d1c29dc8a3b9c776919e7d1489d45060d2c24f2a commit r9-8168-gd1c29dc8a3b9c776919e7d1489d45060d2c24f2a Author: Jakub Jelinek Date: Wed Jan 22 18:07:54 2020 +0100 i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att [PR91298] In AT 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 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.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #10 from claudio daffra --- Thanks, I'll check it out. Il giorno mer 22 gen 2020 alle ore 11:47 jakub at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> ha scritto: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 > > --- Comment #9 from Jakub Jelinek --- > (In reply to claudio daffra from comment #8) > > it may not work with the double dollar , > > XSTR (x, 0) [0] == '$' > > I can't verify '$$ id', "$$$ ... id" ad so on , at the moment > > ??? The only problem was with leading $, $ in other positions were ok in > the > past already. $$var should be treated like $var, in instructions wrapped in > ()s, so ($$var) instead of $$var. > > -- > You are receiving this mail because: > You reported the bug.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #9 from Jakub Jelinek --- (In reply to claudio daffra from comment #8) > it may not work with the double dollar , > XSTR (x, 0) [0] == '$' > I can't verify '$$ id', "$$$ ... id" ad so on , at the moment ??? The only problem was with leading $, $ in other positions were ok in the past already. $$var should be treated like $var, in instructions wrapped in ()s, so ($$var) instead of $$var.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #8 from claudio daffra --- it may not work with the double dollar , XSTR (x, 0) [0] == '$' I can't verify '$$ id', "$$$ ... id" ad so on , at the moment Il giorno mer 22 gen 2020 alle ore 11:24 pskocik at gmail dot com < gcc-bugzi...@gcc.gnu.org> ha scritto: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 > > --- Comment #7 from pskocik at gmail dot com --- > (In reply to CVS Commits from comment #6) > > The master branch has been updated by Jakub Jelinek : > > Thank you for the fix! > > -- > You are receiving this mail because: > You reported the bug.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #7 from pskocik at gmail dot com --- (In reply to CVS Commits from comment #6) > The master branch has been updated by Jakub Jelinek : Thank you for the fix!
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #6 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:c892d8f58f6fed46c343bdb6dd4d365f08f801b8 commit r10-6137-gc892d8f58f6fed46c343bdb6dd4d365f08f801b8 Author: Jakub Jelinek Date: Wed Jan 22 10:22:16 2020 +0100 i386: Fix up -fdollars-in-identifiers with identifiers starting with $ in -masm=att [PR91298] In AT 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 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.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 --- Comment #5 from Jakub Jelinek --- Created attachment 47668 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47668=edit gcc10-pr91298.patch Untested patch.
[Bug target/91298] $ at the beginging causing Error: junk `(%rip)' after expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91298 pskocik at gmail dot com changed: What|Removed |Added CC||pskocik at gmail dot com --- Comment #4 from pskocik at gmail dot com --- Related https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45591 . I've played with it and this simple patch diff --git a/gcc/final.c b/gcc/final.c index fefc4874b24a..ba7425afa667 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4087,11 +4087,20 @@ output_addr_const (FILE *file, rtx x) case SYMBOL_REF: if (SYMBOL_REF_DECL (x)) assemble_external (SYMBOL_REF_DECL (x)); -#ifdef ASM_OUTPUT_SYMBOL_REF - ASM_OUTPUT_SYMBOL_REF (file, x); -#else - assemble_name (file, XSTR (x, 0)); -#endif + + { + bool dollar_eh = XSTR(x,0)[0] == '$'; + if (dollar_eh) fputc('(',file); + + #ifdef ASM_OUTPUT_SYMBOL_REF + ASM_OUTPUT_SYMBOL_REF (file, x); + #else + assemble_name (file, XSTR (x, 0)); + #endif + + if (dollar_eh) fputc(')',file); + } + break; case LABEL_REF: seems to fix it, at least for x86-64. Basically you need parentheses around names of globals (at least those that start with `$`) when they're used as operands. The parentheses is what clang does. Both clang and tinycc have no problem with this. It would be great if gcc could catch up.