From 5962a71ecf450001a44ead7ab8bc1f5a7a27d4f5 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 3 Dec 2018 19:55:55 +0000 Subject: [PATCH] Provide naive but self-contained implementations of memset(3) and bzero(3) for rtld. This again reduces rtld dependency on libc, and in future, avoid ifunc relocations when the functions are converted to ifuncs in libc. Reported by: mjg Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18400 --- libexec/rtld-elf/rtld.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index fce99383f74e..5d0a182bcf40 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -5618,3 +5618,25 @@ rtld_strerror(int errnum) return ("Unknown error"); return (sys_errlist[errnum]); } + +/* + * No ifunc relocations. + */ +void * +memset(void *dest, int c, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + ((char *)dest)[i] = c; + return (dest); +} + +void +bzero(void *dest, size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + ((char *)dest)[i] = 0; +}