]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Fix ASAN linker errors for Power ELF V1 ABI [PR113284]
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 9 Jan 2024 10:40:14 +0000 (11:40 +0100)
committerIlya Leoshkevich <iii@linux.ibm.com>
Fri, 12 Jan 2024 09:51:53 +0000 (10:51 +0100)
rs6000_elf_declare_function_name () outputs Power ELF V1 ABI function
entry labels without using ASM_OUTPUT_FUNCTION_LABEL ().  As a result,
.LASANPC labels are not emitted, causing linker errors.

In theory, it is possible to reuse ASM_OUTPUT_FUNCTION_LABEL () by
changing rs6000_output_function_entry () to generate label names
without outputting them, but this would be quite a large change.

Instead, factor out the .LASANPC emitting code from
ASM_OUTPUT_FUNCTION_LABEL () and call it manually.

Fixes: c659dd8bfb55 ("Implement ASM_DECLARE_FUNCTION_NAME using ASM_OUTPUT_FUNCTION_LABEL")
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
gcc/ChangeLog:

PR sanitizer/113284
* config/rs6000/rs6000.cc (rs6000_elf_declare_function_name):
Use assemble_function_label_final () for Power ELF V1 ABI.
* output.h (assemble_function_label_final): New function.
* varasm.cc (assemble_function_label_raw): Use
assemble_function_label_final ().
(assemble_function_label_final): New function.

gcc/config/rs6000/rs6000.cc
gcc/output.h
gcc/varasm.cc

index 94fbf46f2b6453aa48e296e349434caaee190c3b..5d975dab9216b55ce5b6a2d6aff1ae3f2bf0a1e0 100644 (file)
@@ -21357,6 +21357,7 @@ rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl)
       ASM_DECLARE_RESULT (file, DECL_RESULT (decl));
       rs6000_output_function_entry (file, name);
       fputs (":\n", file);
+      assemble_function_label_final ();
       return;
     }
 
index c8fe1d2643d9067656b2638acbd147fd01dbaa57..46b0033b221052fe9ea656181cecc6b1ae61009f 100644 (file)
@@ -182,6 +182,10 @@ extern const char *get_fnname_from_decl (tree);
    code or data is output after the label.  */
 extern void assemble_function_label_raw (FILE *, const char *);
 
+/* Finish outputting function label.  Needs to be called when outputting
+   function label without using assemble_function_label_raw ().  */
+extern void assemble_function_label_final (void);
+
 /* Output assembler code for the constant pool of a function and associated
    with defining the name of the function.  DECL describes the function.
    NAME is the function's name.  For the constant pool, we use the current
index 1a869ae458a65bb28b067d871325cc5c705efee3..2b633822434e08018b96290825e49c6a016557eb 100644 (file)
@@ -1843,6 +1843,15 @@ void
 assemble_function_label_raw (FILE *file, const char *name)
 {
   ASM_OUTPUT_LABEL (file, name);
+  assemble_function_label_final ();
+}
+
+/* Finish outputting function label.  Needs to be called when outputting
+   function label without using assemble_function_label_raw ().  */
+
+void
+assemble_function_label_final (void)
+{
   if ((flag_sanitize & SANITIZE_ADDRESS)
       /* Notify ASAN only about the first function label.  */
       && (in_cold_section_p == first_function_block_is_cold)