Skip to content

Commit 96701e9

Browse files
committed
riscv: Add support for riscv32
Because upstream strace dose not support riscv32 since v5.3 [1], this patch is added to support riscv32. [1] strace/strace@69ff62e * Makefile.am (EXTRA_DIST): Rename linux/riscv64 to linux/riscv. * configure.ac: Add riscv32. * linux/riscv64: Rename to linux/riscv. * riscv.c: Add RISCV32. Signed-off-by: Hui Min Mina Chou <[email protected]>
1 parent 1ffb70d commit 96701e9

19 files changed

+68
-20
lines changed

configure.ac

+5-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ powerpc*)
169169
esac
170170
fi
171171
;;
172+
riscv32*)
173+
arch=riscv
174+
AC_DEFINE([RISCV32], 1, [Define for the RISC-V 32-bit architecture])
175+
;;
172176
riscv64*)
173-
arch=riscv64
174-
karch=riscv
177+
arch=riscv
175178
AC_DEFINE([RISCV64], 1, [Define for the RISC-V 64-bit architecture])
176179
;;
177180
s390)

src/Makefile.am

+13-13
Original file line numberDiff line numberDiff line change
@@ -821,19 +821,19 @@ EXTRA_DIST = \
821821
linux/powerpc64le/set_scno.c \
822822
linux/powerpc64le/syscallent.h \
823823
linux/powerpc64le/userent.h \
824-
linux/riscv64/arch_defs_.h \
825-
linux/riscv64/arch_prstatus_regset.c \
826-
linux/riscv64/arch_prstatus_regset.h \
827-
linux/riscv64/arch_regs.c \
828-
linux/riscv64/get_error.c \
829-
linux/riscv64/get_scno.c \
830-
linux/riscv64/get_syscall_args.c \
831-
linux/riscv64/ioctls_arch0.h \
832-
linux/riscv64/ioctls_inc0.h \
833-
linux/riscv64/raw_syscall.h \
834-
linux/riscv64/set_error.c \
835-
linux/riscv64/set_scno.c \
836-
linux/riscv64/syscallent.h \
824+
linux/riscv/arch_defs_.h \
825+
linux/riscv/arch_prstatus_regset.c \
826+
linux/riscv/arch_prstatus_regset.h \
827+
linux/riscv/arch_regs.c \
828+
linux/riscv/get_error.c \
829+
linux/riscv/get_scno.c \
830+
linux/riscv/get_syscall_args.c \
831+
linux/riscv/ioctls_arch0.h \
832+
linux/riscv/ioctls_inc0.h \
833+
linux/riscv/raw_syscall.h \
834+
linux/riscv/set_error.c \
835+
linux/riscv/set_scno.c \
836+
linux/riscv/syscallent.h \
837837
linux/s390/arch_defs_.h \
838838
linux/s390/arch_prstatus_regset.c \
839839
linux/s390/arch_prstatus_regset.h \

src/linux/riscv/arch_defs_.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#if defined(RISCV32)
2+
# define ARCH_TIMESIZE 64
3+
# define HAVE_ARCH_TIME32_SYSCALLS 0
4+
# define HAVE_ARCH_OLD_TIME64_SYSCALLS 0
5+
# define PERSONALITY0_AUDIT_ARCH { AUDIT_ARCH_RISCV32, 0 }
6+
#else
7+
# define PERSONALITY0_AUDIT_ARCH { AUDIT_ARCH_RISCV64, 0 }
8+
#endif
File renamed without changes.

src/linux/riscv/asm_stat.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2020 The strace developers.
3+
* All rights reserved.
4+
*
5+
* SPDX-License-Identifier: LGPL-2.1-or-later
6+
*/
7+
8+
#ifndef STRACE_RISCV_ASM_STAT_H
9+
# define STRACE_RISCV_ASM_STAT_H
10+
11+
# include "linux/generic/asm_stat.h"
12+
13+
# if defined(RISCV32)
14+
# undef dev_t
15+
# undef ino_t
16+
# undef off64_t
17+
# undef off_t
18+
# undef time_t
19+
20+
# define dev_t __kernel_loff_t
21+
# define ino_t __kernel_loff_t
22+
# define off64_t __kernel_off64_t
23+
# define off_t __kernel_off64_t
24+
# define time_t __kernel_time64_t
25+
# endif /* defined(RISCV32) */
26+
#endif /* !STRACE_RISCV_ASM_STAT_H */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/linux/riscv/ioctls_inc0.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if defined(RISCV64)
2+
# include "../64/ioctls_inc.h"
3+
#elif defined(RISCV32)
4+
# include "../32/ioctls_inc.h"
5+
#else
6+
# error "Unsupported RISC-V xlen"
7+
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/linux/riscv64/syscallent.h src/linux/riscv/syscallent.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
* SPDX-License-Identifier: LGPL-2.1-or-later
66
*/
77

8-
#include "../64/syscallent.h"
8+
#if defined(RISCV64)
9+
# include "../64/syscallent.h"
10+
#elif defined(RISCV32)
11+
# include "../32/syscallent.h"
12+
#else
13+
# error "Unsupported RISC-V xlen"
14+
#endif
915

1016
/* #define __NR_riscv_flush_icache (__NR_arch_specific_syscall + 15) */
1117
[259] = { 3, TM, SEN(riscv_flush_icache), "riscv_flush_icache" },

src/linux/riscv64/arch_defs_.h

-1
This file was deleted.

src/linux/riscv64/ioctls_inc0.h

-1
This file was deleted.

src/riscv.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "defs.h"
1111

12-
#ifdef RISCV64
12+
#if defined(RISCV64) || defined(RISCV32)
1313

1414
# include "xlat/riscv_flush_icache_flags.h"
1515

@@ -30,4 +30,4 @@ SYS_FUNC(riscv_flush_icache)
3030
return RVAL_DECODED;
3131
}
3232

33-
#endif /* RISCV64 */
33+
#endif /* defined(RISCV64) || defined(RISCV32) */

0 commit comments

Comments
 (0)