44475f
commit eb4181e9f4a512de37dad4ba623c921671584dea
44475f
Author: Vladislav Khmelevsky <och95@yandex.ru>
44475f
Date:   Thu Nov 17 12:47:29 2022 +0400
44475f
44475f
    elf: Fix rtld-audit trampoline for aarch64
44475f
    
44475f
    This patch fixes two problems with audit:
44475f
    
44475f
      1. The DL_OFFSET_RV_VPCS offset was mixed up with DL_OFFSET_RG_VPCS,
44475f
         resulting in x2 register value nulling in RG structure.
44475f
    
44475f
      2. We need to preserve the x8 register before function call, but
44475f
         don't have to save it's new value and restore it before return.
44475f
    
44475f
    Anyway the final restore was using OFFSET_RV instead of OFFSET_RG value
44475f
    which is wrong (althoug doesn't affect anything).
44475f
    
44475f
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
44475f
44475f
diff --git a/sysdeps/aarch64/dl-trampoline.S b/sysdeps/aarch64/dl-trampoline.S
44475f
index a83e7fc5f97047e2..b4b9c86224785a2c 100644
44475f
--- a/sysdeps/aarch64/dl-trampoline.S
44475f
+++ b/sysdeps/aarch64/dl-trampoline.S
44475f
@@ -282,12 +282,11 @@ _dl_runtime_profile:
44475f
 	stp	x2, x3, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*1]
44475f
 	stp	x4, x5, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*2]
44475f
 	stp	x6, x7, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*3]
44475f
-	str	x8,     [x29, #OFFSET_RG + DL_OFFSET_RG_X0 + 16*4]
44475f
 	stp	q0, q1, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*0]
44475f
 	stp	q2, q3, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*1]
44475f
 	stp	q4, q5, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*2]
44475f
 	stp	q6, q7, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*3]
44475f
-	str	xzr,    [X29, #OFFSET_RV + DL_OFFSET_RG_VPCS]
44475f
+	str	xzr,    [X29, #OFFSET_RV + DL_OFFSET_RV_VPCS]
44475f
 
44475f
 	/* Setup call to pltexit  */
44475f
 	ldp	x0, x1, [x29, #OFFSET_SAVED_CALL_X0]
44475f
@@ -299,7 +298,6 @@ _dl_runtime_profile:
44475f
 	ldp	x2, x3, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*1]
44475f
 	ldp	x4, x5, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*2]
44475f
 	ldp	x6, x7, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*3]
44475f
-	ldr	x8,     [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*4]
44475f
 	ldp	q0, q1, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*0]
44475f
 	ldp	q2, q3, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*1]
44475f
 	ldp	q4, q5, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*2]