From 94ffa4e95910efd870ef58e9e76331d77476447b Mon Sep 17 00:00:00 2001 From: drahn Date: Sun, 16 May 2021 16:00:50 +0000 Subject: [PATCH] Correct problem in riscv64 dtors execution load the function pointer correctly and do not overwrite it in csu. allows most ld.so regressions to pass confirmed by jsg@, ok kettenis --- lib/csu/riscv64/md_init.h | 3 +-- libexec/ld.so/riscv64/ldasm.S | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/csu/riscv64/md_init.h b/lib/csu/riscv64/md_init.h index 83d3b4502c3..8328b838112 100644 --- a/lib/csu/riscv64/md_init.h +++ b/lib/csu/riscv64/md_init.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md_init.h,v 1.1 2021/04/28 00:11:11 drahn Exp $ */ +/* $OpenBSD: md_init.h,v 1.2 2021/05/16 16:00:50 drahn Exp $ */ /* * Copyright (c) 2020 Dale Rahn * @@ -62,7 +62,6 @@ " .type __start, @function \n" \ "_start: \n" \ "__start: \n" \ - " mv a3, a2 # cleanup \n" \ "/* Get argc/argv/envp from stack */ \n" \ " ld a0, (sp) \n" \ " addi a1, sp, 0x8 \n" \ diff --git a/libexec/ld.so/riscv64/ldasm.S b/libexec/ld.so/riscv64/ldasm.S index d620c6cf9f2..d51e82c73cc 100644 --- a/libexec/ld.so/riscv64/ldasm.S +++ b/libexec/ld.so/riscv64/ldasm.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldasm.S,v 1.1 2021/04/28 15:16:26 drahn Exp $ */ +/* $OpenBSD: ldasm.S,v 1.2 2021/05/16 16:00:50 drahn Exp $ */ /* * Copyright (c) 2016,2021 Dale Rahn @@ -66,7 +66,7 @@ _dl_start: mv sp, fp // move stack back mv fp, zero // clear frame back pointer -2: auipc a3, %got_pcrel_hi(_dl_dtors) /* cleanup */ +2: auipc a3, %pcrel_hi(_dl_dtors) /* cleanup */ addi a3, a3, %pcrel_lo(2b) jr a0 -- 2.20.1