Messages in this thread | | | Date | Thu, 3 Feb 2022 12:45:36 -0800 | From | Kees Cook <> | Subject | Re: [PATCH] lib/test_string.c: Add test for strlen() |
| |
On Thu, Feb 03, 2022 at 11:50:34AM -0800, Nick Desaulniers wrote: > The kernel does not link against a libc; but it does provide many > symbols that libc would provide, with the same or similar enough > semantics that I would strongly recommend we _don't_ use > -ffreestanding in order to get such libcall optimizations (there are a > lot; see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp > for some examples) and simply use -fno-builtin-* when necessary, or > fix the kernel implementations individually.
Right, we really don't want -ffreestanding. Rather, we want to not link against libgcc. This is mostly true already, though some of the smaller architectures still do:
$ git grep print-libgcc arch/arc/Makefile:LIBGCC = $(shell $(CC) $(cflags-y) --print-libgcc-file-name) arch/csky/Makefile: $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) arch/h8300/boot/compressed/Makefile:LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null) arch/nios2/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name) arch/openrisc/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) arch/parisc/Makefile:LIBGCC := $(shell $(CC) -print-libgcc-file-name) arch/xtensa/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) arch/xtensa/boot/boot-redboot/Makefile:LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
-- Kees Cook
| |