From 29e1fceb733d3c7986b4286bf99f44b8d0b0821e Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Fri, 4 Sep 2020 21:46:10 +0000 Subject: [PATCH] Maintain a stack alignment of 16-bytes. This violated the RISC-V 64-bit ABI. On CheriBSD this manifested as a trap when attempting to store 16-byte aligned types while zeroing the stack. Reported by: CHERI, jrtc27 Reviewed by: mhorne, br Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26327 --- libexec/rtld-elf/riscv/rtld_start.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/riscv/rtld_start.S b/libexec/rtld-elf/riscv/rtld_start.S index c37cd62e49e..71806123deb 100644 --- a/libexec/rtld-elf/riscv/rtld_start.S +++ b/libexec/rtld-elf/riscv/rtld_start.S @@ -64,7 +64,8 @@ END(.rtld_start) */ ENTRY(_rtld_bind_start) /* Save the arguments and ra */ - addi sp, sp, -(8 * 17) + /* We require 17 dwords, but the stack must be aligned to 16-bytes */ + addi sp, sp, -(8 * 18) sd a0, (8 * 0)(sp) sd a1, (8 * 1)(sp) sd a2, (8 * 2)(sp) @@ -122,7 +123,7 @@ ENTRY(_rtld_bind_start) fld fa6, (8 * 15)(sp) fld fa7, (8 * 16)(sp) #endif - addi sp, sp, (8 * 17) + addi sp, sp, (8 * 18) /* Call into the correct function */ jr t0 -- 2.45.0