From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id AC0BC3858D32 for ; Sun, 29 Jan 2023 15:38:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC0BC3858D32 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:References:In-Reply-To: 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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BsrQTyXqFHU8eiuk3GfmCyJOb2+Gpru/joDt7T+f+eg=; b=EAM8qrAYVCfVkT0X53hlU7EWep JMxxIjuLBNrt4Za/L7YrN8+xkeroksX3JgW9Tg435qVHJsrYJxtmtfVEC9bri2W9be8l5Ee8AGbEH Yl7IByruFvDI+VQjSjg0VfZcxQxV42bnvg/71VS2e2XhHfrXOVdSrb+r+HQk3xgkFSYyeZ5gsgA+n IGBIXNGOkz24ERf7UVTXKrNU2FVenet+foHlrY5T+R4czPD1teGZJOW+K4zQH3FS2kpqwWkLhXCNO 7MEosxsWPNSHhCQoqRdq3UIiTlT1AILxdV+3Xx9nf6IfkZkZY9/NHldmSVPyJe2to1tVRwe8kZrHt LyIiYlhA==; Received: from [95.42.20.142] (port=36452 helo=kendros.lan) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pM9lF-0004gt-2I; Sun, 29 Jan 2023 17:38:31 +0200 From: Dimitar Dimitrov To: binutils@sourceware.org Cc: Dimitar Dimitrov Subject: [PATCH 2/2] ld: pru: Add optional section alignments Date: Sun, 29 Jan 2023 17:38:20 +0200 Message-Id: <20230129153820.944711-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129153207.944175-1-dimitar@dinux.eu> References: <20230129153207.944175-1-dimitar@dinux.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 - sourceware.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=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The Texas Instruments SoCs with AARCH64 host processors have stricter alignment requirements than ones with ARM32 host processors. It's not only the requirement for resource_table to be aligned to 8. But also any loadable segment size must be a multiple of 4 [1]. The current PRU default linker script may output a segment size not aligned to 4, which would cause firmware load failure on AARCH64 hosts. Fix this by using COMMONPAGESIZE and MAXPAGESIZE to signify respectively the section memory size requirement and the resource table section's start address alignment. This would avoid penalizing the ARM32 hosts, for which the default values (1 and 1) are sufficient. For AARCH64 hosts, the alignments would be overwritten from GCC spec files using the linker command line, e.g.: -z common-page-size=4 -z max-page-size=8 Ok for master? [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/pru_rproc.c?h=v6.1#n555 ld/ChangeLog: * scripttempl/pru.sc (_data_end): Remove the alignment. (.data): Align output section size to COMMONPAGESIZE. (.resource_table): Ditto. Signed-off-by: Dimitar Dimitrov --- ld/scripttempl/pru.sc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ld/scripttempl/pru.sc b/ld/scripttempl/pru.sc index 7cb80694641..4229bed99bb 100644 --- a/ld/scripttempl/pru.sc +++ b/ld/scripttempl/pru.sc @@ -147,7 +147,6 @@ SECTIONS ${RELOCATING+ *(.rodata:*)} ${RELOCATING+*(.gnu.linkonce.d*)} ${RELOCATING+*(.gnu.linkonce.r*)} - ${RELOCATING+. = ALIGN(4);} ${RELOCATING+ PROVIDE (_data_end = .) ; } ${RELOCATING+/* Merge the bss input sections into the output @@ -164,13 +163,22 @@ SECTIONS ${RELOCATING+*(COMMON)} ${RELOCATING+ PROVIDE (_bss_end = .) ; } + ${RELOCATING+/* In case this is the last input section, align to + keep the loadable segment size a multiple of the common page size. + Some SoCs have stricter memory size requirements than others. */ + . = ALIGN (CONSTANT (COMMONPAGESIZE));} } ${RELOCATING+ > dmem} /* Linux remoteproc loader requires the resource_table section - start address to be aligned to 8 bytes. */ - .resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN (8)} : + start address to be aligned to 8 bytes for SoCs with AARCH64 + host processors. */ + .resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN (CONSTANT (MAXPAGESIZE))} : { KEEP (*(.resource_table)) + ${RELOCATING+/* In case this is the last input section, align to + keep the loadable segment size a multiple of the common page size. + Some SoCs have stricter memory size requirements than others. */ + . = ALIGN (CONSTANT (COMMONPAGESIZE));} } ${RELOCATING+ > dmem} /* Global data not cleared after reset. */ -- 2.39.1