[PATCH v1 1/1] riscv: Nop out memcpy_noalignment if !IS_IN(libc)
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Jan 19 12:28:12 GMT 2026
I think there is another possible issue here:
riscv64-linux-gnu-rv64imafdc-lp64d $ objdump -t string/rtld-memcpy.os | grep -w memcpy | grep -w g
0000000000000000 g F .text 00000000000000c4 .hidden memcpy
riscv64-linux-gnu-rv64imafdc-lp64d $ objdump -t string/rtld-memcpy-generic.os | grep -w memcpy | grep -w g
0000000000000000 g F .text 00000000000000c4 .hidden memcpy
There is no need to provide two memcpy implementation for ld.so and
it only complicates possible debug. So I think we should also disable
the memcpy-generic one:
diff --git a/sysdeps/riscv/multiarch/memcpy-generic.c b/sysdeps/riscv/multiarch/memcpy-generic.c
index 6af72f35dd..5a2dfed57b 100644
--- a/sysdeps/riscv/multiarch/memcpy-generic.c
+++ b/sysdeps/riscv/multiarch/memcpy-generic.c
@@ -22,5 +22,5 @@
# define MEMCPY __memcpy_generic
# undef libc_hidden_builtin_def
# define libc_hidden_builtin_def(x)
+# include <string/memcpy.c>
#endif
-#include <string/memcpy.c>
On 19/01/26 04:01, Yao Zihong wrote:
> This patch nop out memcpy_noalignment if !IS_IN(libc) since ld.so
> can only use the generic implmentation.
>
> Signed-off-by: Yao Zihong <zihong.plct@isrc.iscas.ac.cn>
> ---
> sysdeps/riscv/multiarch/memcpy_noalignment.S | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/riscv/multiarch/memcpy_noalignment.S b/sysdeps/riscv/multiarch/memcpy_noalignment.S
> index b912abe6d1..559e2b21e2 100644
> --- a/sysdeps/riscv/multiarch/memcpy_noalignment.S
> +++ b/sysdeps/riscv/multiarch/memcpy_noalignment.S
> @@ -19,6 +19,7 @@
> #include <sysdep.h>
> #include <sys/asm.h>
>
> +#if IS_IN(libc)
> /* memcpy optimization for CPUs with fast unaligned support
> (RISCV_HWPROBE_MISALIGNED_FAST).
>
> @@ -31,7 +32,7 @@
>
> The tail is handled with branchless copies. */
>
> -#define BLOCK_SIZE (16 * SZREG)
> +# define BLOCK_SIZE (16 * SZREG)
>
> .attribute unaligned_access, 1
> ENTRY (__memcpy_noalignment)
> @@ -156,3 +157,5 @@ L(word_copy_adjust):
> mv a3, a5
> j L(word_copy)
> END (__memcpy_noalignment)
> +
> +#endif
More information about the Libc-alpha
mailing list