[PATCH v3 13/13] aarch64: fix _mcount for pac-ret

Szabolcs Nagy szabolcs.nagy@arm.com
Fri May 15 14:40:57 GMT 2020


gcc -pg with -mbranch-protection=pac-ret passes signed return address
to _mcount, so _mcount now has to always strip pac from the frompc
since that's from user code that may be built with pac-ret.

This is a backward incompatible _mcount abi change introduced by
return address signing support in gcc-7.

TODO: fix -pg on the gcc side?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94791
---
 sysdeps/aarch64/machine-gmon.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/aarch64/machine-gmon.h b/sysdeps/aarch64/machine-gmon.h
index 730a23b781..328cbdda16 100644
--- a/sysdeps/aarch64/machine-gmon.h
+++ b/sysdeps/aarch64/machine-gmon.h
@@ -30,5 +30,5 @@ static inline void mcount_internal (u_long frompc, u_long selfpc)
 #define MCOUNT                                                    \
 void __mcount (void *frompc)                                      \
 {                                                                 \
-  mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \
+  mcount_internal ((u_long) strip_pac (frompc), (u_long) RETURN_ADDRESS (0)); \
 }
-- 
2.17.1



More information about the Libc-alpha mailing list