public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org>
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
Date: Tue, 21 Sep 2021 09:13:09 +0000 (GMT)	[thread overview]
Message-ID: <20210921091309.8B7A23858436@sourceware.org> (raw)

https://gcc.gnu.org/g:3d93394b6134556de82bb8ae9e7b9e10faa6d93d

commit 3d93394b6134556de82bb8ae9e7b9e10faa6d93d
Author: Matthew Malcomson <matthew.malcomson@arm.com>
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"
 	;;


                 reply	other threads:[~2021-09-21  9:13 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=20210921091309.8B7A23858436@sourceware.org \
    --to=matmal01@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).