From patchwork Fri Dec 3 21:33:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitar Dimitrov X-Patchwork-Id: 48482 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0C1B3858003 for ; Fri, 3 Dec 2021 21:36:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id A69733858417 for ; Fri, 3 Dec 2021 21:34:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A69733858417 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=T2ZJphUrIrUAR5PYIGCg9z1VICW73FbI40427RLCIeI=; b=DcSR9ld8IaKX3G9GK8Tza/kKZh ZUGqCyhERtmiL1XX8LeSEOUftZFqOG45fnadFoRwl8RQsw0dDaLWgf4llOJD2UolzEpwN18fKAgZ9 TAWbWK4OywYT5Sb4shEUJ68QkGXqAYStZmtRQ7FfxJMJ0/wDlSF0KBL+8TFUyPeELq6B+ULK0B+v+ VXz+O7NNWfU/sKBDmxki6W0jXpBUJiRuyPGQxe3OWloRkldMieDd1/gUvyv3A9vUe5VTQOQxfBj1f Tg7S5n6v2Z7J+ol1bslDXMRUbzgUPJsepIPOk8hNDW0n99WDow/lbt/hmSDgrVUR1xnbKSiamqZHI hbtX3HYw==; Received: from [95.87.234.74] (port=34362 helo=kendros.lan) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mtGBv-0006r1-Uf; Fri, 03 Dec 2021 23:34:06 +0200 From: Dimitar Dimitrov To: gcc-patches@gcc.gnu.org Subject: [PATCH] pru: Fixup flags for .pru_irq_map section Date: Fri, 3 Dec 2021 23:33:48 +0200 Message-Id: <20211203213348.406058-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HAS_X_OUTGOING_SPAM_STAT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" I intend to merge this patch next week, unless I hear objections. I consider it a bug fix which fits the Stage 3 criteria. It fixes the RPMSG firmware examples in the latest version 6.0 of TI's PRU Software Package. The .pru_irq_map section has been introduced by Linux kernel 5.10: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c75c9fdac66efd8b54773368254ef330c276171b This section must not be loaded into target memory. Binutils already includes the corresponding fix in the linker script: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=44b357eb9aefc77a8385e631d8e3035a664f2333 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 --- gcc/config/pru/pru.c | 19 +++++++++++++++++++ gcc/testsuite/gcc.target/pru/pru_irq_map.c | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.target/pru/pru_irq_map.c 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" } } */