Commit c9049984 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull nolibc updates from Paul McKenney:

 - Add stdarg.h header and a few additional system-call upgrades

 - Add support for constructors and destructors

 - Add tests to verify the ability to link multiple .o files against
   nolibc

 - Numerous string-function optimizations and improvements

 - Prevent redundant kernel relinks by avoiding embedding of initramfs
   into the kernel image

 - Allow building i386 with multiarch compiler and make ppc64le use
   qemu-system-ppc64

 - Miscellaneous fixups, including addition of -nostdinc for
   nolibc-test, avoiding -Wstringop-overflow warnings, and avoiding
   unused parameter warnings for ENOSYS fallbacks

* tag 'nolibc.2023.10.23a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu:
  selftests/nolibc: add tests for multi-object linkage
  selftests/nolibc: use qemu-system-ppc64 for ppc64le
  tools/nolibc: add support for constructors and destructors
  tools/nolibc: drop test for getauxval(AT_PAGESZ)
  tools/nolibc: automatically detect necessity to use pselect6
  tools/nolibc: don't define new syscall number
  tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks
  selftests/nolibc: allow building i386 with multiarch compiler
  selftests/nolibc: don't embed initramfs into kernel image
  selftests/nolibc: libc-test: avoid -Wstringop-overflow warnings
  tools/nolibc: string: Remove the `_nolibc_memcpy_up()` function
  tools/nolibc: string: Remove the `_nolibc_memcpy_down()` function
  tools/nolibc: x86-64: Use `rep stosb` for `memset()`
  tools/nolibc: x86-64: Use `rep movsb` for `memcpy()` and `memmove()`
  selftests/nolibc: use -nostdinc for nolibc-test
  tools/nolibc: add stdarg.h header
parents eb55307e b8c60e8f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ all_files := \
		signal.h \
		stackprotector.h \
		std.h \
		stdarg.h \
		stdint.h \
		stdlib.h \
		string.h \
+0 −3
Original line number Diff line number Diff line
@@ -20,10 +20,7 @@
 *   - the arguments are cast to long and assigned into the target registers
 *     which are then simply passed as registers to the asm code, so that we
 *     don't have to experience issues with register constraints.
 *
 * On aarch64, select() is not implemented so we have to use pselect6().
 */
#define __ARCH_WANT_SYS_PSELECT6

#define my_syscall0(num)                                                      \
({                                                                            \
+1 −3
Original line number Diff line number Diff line
@@ -19,10 +19,8 @@
 *   - the arguments are cast to long and assigned into the target
 *     registers which are then simply passed as registers to the asm code,
 *     so that we don't have to experience issues with register constraints.
 *
 * On LoongArch, select() is not implemented so we have to use pselect6().
 */
#define __ARCH_WANT_SYS_PSELECT6

#define _NOLIBC_SYSCALL_CLOBBERLIST \
	"memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8"

+0 −3
Original line number Diff line number Diff line
@@ -19,10 +19,7 @@
 *   - the arguments are cast to long and assigned into the target
 *     registers which are then simply passed as registers to the asm code,
 *     so that we don't have to experience issues with register constraints.
 *
 * On riscv, select() is not implemented so we have to use pselect6().
 */
#define __ARCH_WANT_SYS_PSELECT6

#define my_syscall0(num)                                                      \
({                                                                            \
+42 −0
Original line number Diff line number Diff line
@@ -173,4 +173,46 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_
	__builtin_unreachable();
}

#define NOLIBC_ARCH_HAS_MEMMOVE
void *memmove(void *dst, const void *src, size_t len);

#define NOLIBC_ARCH_HAS_MEMCPY
void *memcpy(void *dst, const void *src, size_t len);

#define NOLIBC_ARCH_HAS_MEMSET
void *memset(void *dst, int c, size_t len);

__asm__ (
".section .text.nolibc_memmove_memcpy\n"
".weak memmove\n"
".weak memcpy\n"
"memmove:\n"
"memcpy:\n"
	"movq %rdx, %rcx\n\t"
	"movq %rdi, %rax\n\t"
	"movq %rdi, %rdx\n\t"
	"subq %rsi, %rdx\n\t"
	"cmpq %rcx, %rdx\n\t"
	"jb   .Lbackward_copy\n\t"
	"rep movsb\n\t"
	"retq\n"
".Lbackward_copy:"
	"leaq -1(%rdi, %rcx, 1), %rdi\n\t"
	"leaq -1(%rsi, %rcx, 1), %rsi\n\t"
	"std\n\t"
	"rep movsb\n\t"
	"cld\n\t"
	"retq\n"

".section .text.nolibc_memset\n"
".weak memset\n"
"memset:\n"
	"xchgl %eax, %esi\n\t"
	"movq  %rdx, %rcx\n\t"
	"pushq %rdi\n\t"
	"rep stosb\n\t"
	"popq  %rax\n\t"
	"retq\n"
);

#endif /* _NOLIBC_ARCH_X86_64_H */
Loading