@@ -75,7 +75,11 @@ call_weak_fn:
.hidden _init
.type _init, %function
_init:
+#ifdef HAVE_AARCH64_PAC_RET
+ PACIASP
+#else
BTI_C
+#endif
stp x29, x30, [sp, -16]!
mov x29, sp
#if PREINIT_FUNCTION_WEAK
@@ -90,7 +94,11 @@ _init:
.hidden _fini
.type _fini, %function
_fini:
+#ifdef HAVE_AARCH64_PAC_RET
+ PACIASP
+#else
BTI_C
+#endif
stp x29, x30, [sp, -16]!
mov x29, sp
@@ -41,10 +41,16 @@
.section .init,"ax",%progbits
ldp x29, x30, [sp], 16
+#ifdef HAVE_AARCH64_PAC_RET
+ AUTIASP
+#endif
RET
.section .fini,"ax",%progbits
ldp x29, x30, [sp], 16
+#ifdef HAVE_AARCH64_PAC_RET
+ AUTIASP
+#endif
RET
END_FILE
@@ -183,6 +183,10 @@ _dl_tlsdesc_dynamic:
callee will trash. */
/* Save the remaining registers that we must treat as caller save. */
+# ifdef HAVE_AARCH64_PAC_RET
+ PACIASP
+ cfi_window_save
+# endif
# define NSAVEXREGPAIRS 8
stp x29, x30, [sp,#-16*NSAVEXREGPAIRS]!
cfi_adjust_cfa_offset (16*NSAVEXREGPAIRS)
@@ -233,6 +237,10 @@ _dl_tlsdesc_dynamic:
cfi_adjust_cfa_offset (-16*NSAVEXREGPAIRS)
cfi_restore (x29)
cfi_restore (x30)
+# ifdef HAVE_AARCH64_PAC_RET
+ AUTIASP
+ cfi_window_save
+# endif
b 1b
cfi_endproc
.size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
@@ -127,7 +127,12 @@ _dl_runtime_resolve:
cfi_startproc
.align 2
_dl_runtime_profile:
+# ifdef HAVE_AARCH64_PAC_RET
+ PACIASP
+ cfi_window_save
+# else
BTI_C
+# endif
/* AArch64 we get called with:
ip0 &PLTGOT[2]
ip1 temp(dl resolver entry point)
@@ -239,8 +244,17 @@ _dl_runtime_profile:
cfi_restore(x29)
cfi_restore(x30)
+# ifdef HAVE_AARCH64_PAC_RET
+ add sp, sp, SF_SIZE
+ cfi_adjust_cfa_offset (-SF_SIZE)
+ AUTIASP
+ cfi_window_save
+ add sp, sp, 16
+ cfi_adjust_cfa_offset (-16)
+# else
add sp, sp, SF_SIZE + 16
cfi_adjust_cfa_offset (- SF_SIZE - 16)
+# endif
/* Jump to the newly found address. */
br ip0
@@ -287,6 +301,10 @@ _dl_runtime_profile:
/* LR from within La_aarch64_reg */
ldr lr, [x29, #OFFSET_RG + DL_OFFSET_RG_LR]
cfi_restore(lr)
+# ifdef HAVE_AARCH64_PAC_RET
+ /* Note: LR restored from La_aarch64_reg has no PAC. */
+ cfi_window_save
+# endif
mov sp, x29
cfi_def_cfa_register (sp)
ldr x29, [x29, #0]
@@ -45,6 +45,10 @@
#define BTI_C hint 34
#define BTI_J hint 36
+/* Return address signing support (pac-ret). */
+#define PACIASP hint 25
+#define AUTIASP hint 29
+
#define FEATURE_1_BTI 1
#define FEATURE_1_PAC 2
@@ -62,7 +66,9 @@
.word 0;
/* GNU property note with the supported features. */
-#ifdef HAVE_AARCH64_BTI
+#if defined HAVE_AARCH64_BTI && defined HAVE_AARCH64_PAC_RET
+# define END_FILE GNU_PROPERTY (FEATURE_1_BTI|FEATURE_1_PAC)
+#elif defined HAVE_AARCH64_BTI
# define END_FILE GNU_PROPERTY (FEATURE_1_BTI)
#else
# define END_FILE