public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Dimitar Dimitrov <dimitar@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5844] pru: Fixup flags for .pru_irq_map section
Date: Wed,  8 Dec 2021 19:19:36 +0000 (GMT)	[thread overview]
Message-ID: <20211208191936.280F73858D3C@sourceware.org> (raw)

https://gcc.gnu.org/g:dda85bc274e1148a0c576a8cb085bffadd0e54ab

commit r12-5844-gdda85bc274e1148a0c576a8cb085bffadd0e54ab
Author: Dimitar Dimitrov <dimitar@dinux.eu>
Date:   Sun Nov 21 15:55:53 2021 +0200

    pru: Fixup flags for .pru_irq_map section
    
    Assign correct flags for the .pru_irq_map section, which the
    PRU remoteproc host loader introduced in Linux kernel 5.10:
      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c75c9fdac66efd8b54773368254ef330c276171b
    
    gcc/ChangeLog:
    
            * config/pru/pru.c (pru_section_type_flags): New function.
            (TARGET_SECTION_TYPE_FLAGS): Wire it.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/pru/pru_irq_map.c: New test.
    
    Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

Diff:
---
 gcc/config/pru/pru.c                       | 19 +++++++++++++++++++
 gcc/testsuite/gcc.target/pru/pru_irq_map.c |  8 ++++++++
 2 files changed, 27 insertions(+)

diff --git a/gcc/config/pru/pru.c b/gcc/config/pru/pru.c
index 9f264b4698d..01d283fd9e7 100644
--- a/gcc/config/pru/pru.c
+++ b/gcc/config/pru/pru.c
@@ -2022,6 +2022,23 @@ pru_assemble_integer (rtx x, unsigned int size, int aligned_p)
     }
 }
 
+/* Implement TARGET_SECTION_TYPE_FLAGS.  */
+
+static unsigned int
+pru_section_type_flags (tree decl, const char *name, int reloc)
+{
+  unsigned int flags = default_section_type_flags (decl, name, reloc);
+
+  /* The .pru_irq_map section is not meant to be loaded into the target
+     memory.  Instead its contents are read by the host remoteproc loader.
+     To prevent being marked as a loadable (allocated) section, the
+     .pru_irq_map section is intercepted and marked as a debug section.  */
+  if (!strcmp (name, ".pru_irq_map"))
+    flags = SECTION_DEBUG | SECTION_RETAIN;
+
+  return flags;
+}
+
 /* Implement TARGET_ASM_FILE_START.  */
 
 static void
@@ -3071,6 +3088,8 @@ pru_unwind_word_mode (void)
 #define TARGET_ASM_FUNCTION_PROLOGUE pru_asm_function_prologue
 #undef TARGET_ASM_INTEGER
 #define TARGET_ASM_INTEGER pru_assemble_integer
+#undef TARGET_SECTION_TYPE_FLAGS
+#define TARGET_SECTION_TYPE_FLAGS pru_section_type_flags
 
 #undef TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START pru_file_start
diff --git a/gcc/testsuite/gcc.target/pru/pru_irq_map.c b/gcc/testsuite/gcc.target/pru/pru_irq_map.c
new file mode 100644
index 00000000000..4f9a5e71b01
--- /dev/null
+++ b/gcc/testsuite/gcc.target/pru/pru_irq_map.c
@@ -0,0 +1,8 @@
+/* Test the special handling of .pru_irq_map section.  */
+
+/* { dg-do compile } */
+
+int my_int_map __attribute__((section(".pru_irq_map")));
+
+/* Section must not have the allocated flag.  */
+/* { dg-final { scan-assembler "\.section\[ \t\]+.pru_irq_map,\[ \]*\"\",[ ]*@progbits" } } */


                 reply	other threads:[~2021-12-08 19:19 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=20211208191936.280F73858D3C@sourceware.org \
    --to=dimitar@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).