From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Jeff Law <jlaw@ventanamicro.com>, Jakub Jelinek <jakub@redhat.com>
Cc: seurer@gcc.gnu.org, Andreas Krebbel <krebbel@gcc.gnu.org>,
gcc-patches@gcc.gnu.org,
Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v2] rs6000: Fix ASAN linker errors for Power ELF V1 ABI [PR113284]
Date: Wed, 10 Jan 2024 00:47:39 +0100 [thread overview]
Message-ID: <20240109235210.605208-1-iii@linux.ibm.com> (raw)
v1: https://inbox.sourceware.org/gcc-patches/20240109105253.332676-1-iii@linux.ibm.com/
v1 -> v2: Move the .LASANPC label to the .text section (Jakub).
Jakub okay-ed this version in the GCC Bugzilla.
Bootstrap and regtest running on ppc64le-redhat-linux and
powerpc64-linux-gnu. Ok for trunk when successful?
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 | 1 +
gcc/output.h | 4 ++++
gcc/varasm.cc | 9 +++++++++
3 files changed, 14 insertions(+)
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 94fbf46f2b6..5d975dab921 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -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;
}
diff --git a/gcc/output.h b/gcc/output.h
index c8fe1d2643d..46b0033b221 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -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
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 1a869ae458a..2b633822434 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -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)
--
2.43.0
reply other threads:[~2024-01-09 23:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240109235210.605208-1-iii@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jlaw@ventanamicro.com \
--cc=krebbel@gcc.gnu.org \
--cc=seurer@gcc.gnu.org \
--cc=stefansf@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).