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.

Reply via email to