aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-01-22 10:22:16 +0100
committerJakub Jelinek <jakub@redhat.com>2020-01-22 10:22:16 +0100
commitc892d8f58f6fed46c343bdb6dd4d365f08f801b8 (patch)
tree7df87fd8d1fbe74174e8d7070de1811d9ac9945d /gcc/varasm.c
parent44a9d801a7080d39658754ad603536da6cff2cd0 (diff)
downloadgcc-c892d8f58f6fed46c343bdb6dd4d365f08f801b8.zip
gcc-c892d8f58f6fed46c343bdb6dd4d365f08f801b8.tar.gz
gcc-c892d8f58f6fed46c343bdb6dd4d365f08f801b8.tar.bz2
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.
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 498c5ff..dc6da6c 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2589,20 +2589,16 @@ assemble_name_raw (FILE *file, const char *name)
ASM_OUTPUT_LABELREF (file, name);
}
-/* Like assemble_name_raw, but should be used when NAME might refer to
- an entity that is also represented as a tree (like a function or
- variable). If NAME does refer to such an entity, that entity will
- be marked as referenced. */
-
-void
-assemble_name (FILE *file, const char *name)
+/* Return NAME that should actually be emitted, looking through
+ transparent aliases. If NAME refers to an entity that is also
+ represented as a tree (like a function or variable), mark the entity
+ as referenced. */
+const char *
+assemble_name_resolve (const char *name)
{
- const char *real_name;
- tree id;
+ const char *real_name = targetm.strip_name_encoding (name);
+ tree id = maybe_get_identifier (real_name);
- real_name = targetm.strip_name_encoding (name);
-
- id = maybe_get_identifier (real_name);
if (id)
{
tree id_orig = id;
@@ -2614,7 +2610,18 @@ assemble_name (FILE *file, const char *name)
gcc_assert (! TREE_CHAIN (id));
}
- assemble_name_raw (file, name);
+ return name;
+}
+
+/* Like assemble_name_raw, but should be used when NAME might refer to
+ an entity that is also represented as a tree (like a function or
+ variable). If NAME does refer to such an entity, that entity will
+ be marked as referenced. */
+
+void
+assemble_name (FILE *file, const char *name)
+{
+ assemble_name_raw (file, assemble_name_resolve (name));
}
/* Allocate SIZE bytes writable static space with a gensym name