[7/8] riscv: Fix the la_pltexit path of _dl_runtime_profile
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
The la_pltexit path stored the return values over the saved
_dl_audit_pltexit arguments instead of in La_riscv_retval, so
_dl_audit_pltexit was called with the return value as its link map.
It then returned through the lr_ra field, which was never set, and
stored fp instead of restoring it.
Set lr_ra and lr_sp at entry, use La_riscv_retval for the return
values, and restore fp.
The tst-audit-plt-flags XFAIL is removed.
Checked on riscv64-linux-gnu-rv64imafdc-lp64d.
---
sysdeps/riscv/Makefile | 2 --
sysdeps/riscv/dl-trampoline.S | 17 +++++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)
@@ -4,8 +4,6 @@ endif
ifeq ($(subdir),elf)
gen-as-const-headers += dl-link.sym
-
-test-xfail-tst-audit-plt-flags = yes
endif
# RISC-V's assembler also needs to know about PIC as it changes the definition
@@ -127,6 +127,11 @@ ENTRY (_dl_runtime_profile)
mv fp, sp
+ # The la_pltexit path returns through lr_ra.
+ REG_S ra, OFFSET_RG + DL_OFFSET_RG_RA(fp)
+ addi t2, fp, SF_SIZE
+ REG_S t2, OFFSET_RG + DL_OFFSET_RG_SP(fp)
+
REG_S a0, OFFSET_RG + DL_OFFSET_RG_A0 + 0*SZREG(fp)
REG_S a1, OFFSET_RG + DL_OFFSET_RG_A0 + 1*SZREG(fp)
REG_S a2, OFFSET_RG + DL_OFFSET_RG_A0 + 2*SZREG(fp)
@@ -231,12 +236,12 @@ ENTRY (_dl_runtime_profile)
#endif
jalr t4
- REG_S a0, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0(fp)
- REG_S a1, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_A0 + SZREG(fp)
+ REG_S a0, OFFSET_RV + DL_OFFSET_RV_A0(fp)
+ REG_S a1, OFFSET_RV + DL_OFFSET_RV_A0 + SZREG(fp)
#ifndef __riscv_float_abi_soft
- FREG_S fa0, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_FA0(fp)
- FREG_S fa1, OFFSET_SAVED_CALL_A0 + DL_OFFSET_RV_FA0 + SZFREG(fp)
+ FREG_S fa0, OFFSET_RV + DL_OFFSET_RV_FA0(fp)
+ FREG_S fa1, OFFSET_RV + DL_OFFSET_RV_FA0 + SZFREG(fp)
#endif
# Setup call to pltexit.
@@ -258,8 +263,8 @@ ENTRY (_dl_runtime_profile)
# RA from within La_riscv_reg.
REG_L ra, OFFSET_RG + DL_OFFSET_RG_RA(fp)
mv sp, fp
- ADDI sp, sp, SF_SIZE
- REG_S fp, SZREG(fp)
+ REG_L fp, SZREG(sp)
+ addi sp, sp, SF_SIZE
jr ra