I want to add KASAN to my kernel, the compiling command line is
Code: Select all
clang -DC_FILE -std=c11 -c -Ikernel_new -Ikernel_new/arch_x86_64 -ffunction-sections -fdata-sections -target x86_64-pc-none-elf -flto -Wall -Wextra -Wshadow -Werror=implicit -g -gdwarf-5 -DDEBUG -fstack-protector -fno-omit-frame-pointer -fsanitize=undefined -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-3dnow -mno-fma -fsanitize=kernel-address -mllvm -asan-mapping-offset=0xdfffe00000000000 -mllvm -asan-globals=false -ffreestanding -fno-builtin -MT build/kernel_new/arch_x86_64/apic/apic_init.c.ko -MMD -MP -MF build/kernel_new/arch_x86_64/apic/apic_init.c.ko.d -o build/kernel_new/arch_x86_64/apic/apic_init.c.ko kernel_new/arch_x86_64/apic/apic_init.c
Code: Select all
clang: error: unsupported option '-fsanitize=kernel-address' for target 'x86_64-pc-none-elf'
Is it safe to remove target triplet? What if I want to cross compile my kernel for another arch?
My kernel is 64-bit, the compiler clang is built from source using default settings.
Code: Select all
cmake ../llvm-project/llvm \
-DCMAKE_INSTALL_PREFIX=/opt/llvm \
-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DCMAKE_BUILD_TYPE=Release