From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id 8B7A23858436; Tue, 21 Sep 2021 09:13:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B7A23858436 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Add a capability version of the crti.S and crtn.S files X-Act-Checkin: gcc X-Git-Author: Matthew Malcomson X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: 15a49e9f285a69e4f233905c77bb163bfe237827 X-Git-Newrev: 3d93394b6134556de82bb8ae9e7b9e10faa6d93d Message-Id: <20210921091309.8B7A23858436@sourceware.org> Date: Tue, 21 Sep 2021 09:13:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2021 09:13:09 -0000 https://gcc.gnu.org/g:3d93394b6134556de82bb8ae9e7b9e10faa6d93d commit 3d93394b6134556de82bb8ae9e7b9e10faa6d93d Author: Matthew Malcomson Date: Mon Aug 9 10:51:00 2021 +0100 Add a capability version of the crti.S and crtn.S files These files define the FUNC_START and FUNC_END macros to implement the function prologues and epilogues for the .init and .fini sections. It seems the implementation in libgcc is just to save the callee-saved registers, so we simply do that for the pure capability version too. Diff: --- libgcc/config/aarch64/crti.S | 17 +++++++++++++++++ libgcc/config/aarch64/crtn.S | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libgcc/config/aarch64/crti.S b/libgcc/config/aarch64/crti.S index b105b93756c..bd4697f5b04 100644 --- a/libgcc/config/aarch64/crti.S +++ b/libgcc/config/aarch64/crti.S @@ -37,6 +37,22 @@ #define TYPE(x) #endif +#ifdef __CHERI_PURE_CAPABILITY__ + + # Note - this macro is complemented by the FUNC_END macro + # in crtn.S. If you change this macro you must also change + # that macro to match. +.macro FUNC_START + # Create a stack frame and save any call-preserved registers + stp c29, c30, [csp, #-32]! + stp c27, c28, [csp, #-32]! + stp c25, c26, [csp, #-32]! + stp c23, c24, [csp, #-32]! + stp c21, c22, [csp, #-32]! + stp c19, c20, [csp, #-32]! +.endm +#else + # Note - this macro is complemented by the FUNC_END macro # in crtn.S. If you change this macro you must also change # that macro match. @@ -50,6 +66,7 @@ stp x19, x20, [sp, #-16]! .endm +#endif .section ".init" .align 2 .global _init diff --git a/libgcc/config/aarch64/crtn.S b/libgcc/config/aarch64/crtn.S index 109c0cb449b..c23e37335c6 100644 --- a/libgcc/config/aarch64/crtn.S +++ b/libgcc/config/aarch64/crtn.S @@ -31,6 +31,24 @@ # fact return. Users may put any desired instructions in those sections. # This file is the last thing linked into any executable. + +#ifdef __CHERI_PURE_CAPABILITY__ + + # Note - this macro is complemented by the FUNC_START macro + # in crti.S. If you change this macro you must also change + # that macro to match. +.macro FUNC_END + # Restore all save registers including the link register, and then + # perform the correct function return instruction. + ldp c19, c20, [csp], #32 + ldp c21, c22, [csp], #32 + ldp c23, c24, [csp], #32 + ldp c25, c26, [csp], #32 + ldp c27, c28, [csp], #32 + ldp c29, c30, [csp], #32 + ret +.endm +#else # Note - this macro is complemented by the FUNC_START macro # in crti.S. If you change this macro you must also change # that macro match. @@ -49,6 +67,7 @@ ret .endm +#endif .section ".init" ;;