https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113284
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Ilya Leoshkevich from comment #4)
> Thanks, I can repro this on cfarm203 now. Apparently I missed
>
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index 94fbf46f2b6..fd9bb807957 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -21334,7 +21334,7 @@ rs6000_elf_declare_function_name (FILE *file, const
> char *name, tree decl)
> if (TARGET_64BIT && DEFAULT_ABI != ABI_ELFv2)
> {
> fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", file);
> - ASM_OUTPUT_LABEL (file, name);
> + ASM_OUTPUT_FUNCTION_LABEL (file, name, decl);
Is that correct?
The function label is emitted in the .opd section on powerpc big endian,
but I think we want the .LASAN label to be in the text section instead,
e.g. after the rs6000_output_function_entry (file, name); label emitted a few
lines later.
> fputs (DOUBLE_INT_ASM_OP, file);
> rs6000_output_function_entry (file, name);
> fputs (",.TOC.@tocbase,0\n\t.previous\n", file);
>
> in commit c659dd8bfb55 ("Implement ASM_DECLARE_FUNCTION_NAME using
> ASM_OUTPUT_FUNCTION_LABEL"). I will start a full regtest and send a patch
> shortly.
Before your changes, we used to emit something like
.section ".opd","aw"
.align 3
foo:
.quad .L.foo,.TOC.@tocbase,0
.previous
.type foo, @function
.L.foo:
.LASANPC0:
.LFB0:
.cfi_startproc
The above patch would emit the .LASANPC0: label after foo:, which is clearly
incorrect,
it really should go where it was emitted before.
Completely untested:
--- gcc/config/rs6000/rs6000.cc.jj 2024-01-05 15:22:21.915684074 +0100
+++ gcc/config/rs6000/rs6000.cc 2024-01-09 12:03:09.295509894 +0100
@@ -21357,6 +21357,10 @@ rs6000_elf_declare_function_name (FILE *
ASM_DECLARE_RESULT (file, DECL_RESULT (decl));
rs6000_output_function_entry (file, name);
fputs (":\n", file);
+ if ((flag_sanitize & SANITIZE_ADDRESS)
+ && (in_cold_section_p == first_function_block_is_cold)
+ && cfun)
+ asan_function_start ();
return;
}