# SPDX-License-Identifier: GPL-2.0
#
# Makefile for some libs needed in the kernel.
#
ifdef [31mCONFIG_FUNCTION_TRACER[0m
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
endif
# These files are disabled because they produce lots of non-interesting and/or
# flaky coverage that is not a function of syscall inputs. For example,
# rbtree can be global and individual rotations don't correlate with inputs.
KCOV_INSTRUMENT_string.o := n
KCOV_INSTRUMENT_rbtree.o := n
KCOV_INSTRUMENT_list_debug.o := n
KCOV_INSTRUMENT_debugobjects.o := n
KCOV_INSTRUMENT_dynamic_debug.o := n
# Early boot use of cmdline, don't instrument it
ifdef [31mCONFIG_AMD_MEM_ENCRYPT[0m
KASAN_SANITIZE_string.o := n
CFLAGS_string.o := $(call cc-option, -fno-stack-protector)
endif
lib-y := ctype.o string.o vsprintf.o cmdline.o \
rbtree.o radix-tree.o timerqueue.o xarray.o \
idr.o extable.o \
sha1.o chacha.o irq_regs.o argv_split.o \
flex_proportions.o ratelimit.o show_mem.o \
is_single_threaded.o plist.o decompress.o kobject_uevent.o \
earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o
lib-$([31mCONFIG_PRINTK[0m) += dump_stack.o
lib-$([31mCONFIG_MMU[0m) += ioremap.o
lib-$([31mCONFIG_SMP[0m) += cpumask.o
lib-y += kobject.o klist.o
obj-y += lockref.o
obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
bust_spinlocks.o kasprintf.o bitmap.o scatterlist.o \
list_sort.o uuid.o iov_iter.o clz_ctz.o \
bsearch.o find_bit.o llist.o memweight.o kfifo.o \
percpu-refcount.o rhashtable.o \
once.o refcount.o usercopy.o errseq.o bucket_locks.o \
generic-radix-tree.o
obj-$([31mCONFIG_STRING_SELFTEST[0m) += test_string.o
obj-y += string_helpers.o
obj-$([31mCONFIG_TEST_STRING_HELPERS[0m) += test-string_helpers.o
obj-y += hexdump.o
obj-$([31mCONFIG_TEST_HEXDUMP[0m) += test_hexdump.o
obj-y += kstrtox.o
obj-$([31mCONFIG_FIND_BIT_BENCHMARK[0m) += find_bit_benchmark.o
obj-$([31mCONFIG_TEST_BPF[0m) += test_bpf.o
obj-$([31mCONFIG_TEST_FIRMWARE[0m) += test_firmware.o
obj-$([31mCONFIG_TEST_SYSCTL[0m) += test_sysctl.o
obj-$([31mCONFIG_TEST_HASH[0m) += test_hash.o test_siphash.o
obj-$([31mCONFIG_TEST_IDA[0m) += test_ida.o
obj-$([31mCONFIG_TEST_KASAN[0m) += test_kasan.o
CFLAGS_test_kasan.o += -fno-builtin
CFLAGS_test_kasan.o += $(call cc-disable-warning, vla)
obj-$([31mCONFIG_TEST_UBSAN[0m) += test_ubsan.o
CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla)
UBSAN_SANITIZE_test_ubsan.o := y
obj-$([31mCONFIG_TEST_KSTRTOX[0m) += test-kstrtox.o
obj-$([31mCONFIG_TEST_LIST_SORT[0m) += test_list_sort.o
obj-$([31mCONFIG_TEST_LKM[0m) += test_module.o
obj-$([31mCONFIG_TEST_VMALLOC[0m) += test_vmalloc.o
obj-$([31mCONFIG_TEST_OVERFLOW[0m) += test_overflow.o
obj-$([31mCONFIG_TEST_RHASHTABLE[0m) += test_rhashtable.o
obj-$([31mCONFIG_TEST_SORT[0m) += test_sort.o
obj-$([31mCONFIG_TEST_USER_COPY[0m) += test_user_copy.o
obj-$([31mCONFIG_TEST_STATIC_KEYS[0m) += test_static_keys.o
obj-$([31mCONFIG_TEST_STATIC_KEYS[0m) += test_static_key_base.o
obj-$([31mCONFIG_TEST_PRINTF[0m) += test_printf.o
obj-$([31mCONFIG_TEST_BITMAP[0m) += test_bitmap.o
obj-$([31mCONFIG_TEST_STRSCPY[0m) += test_strscpy.o
obj-$([31mCONFIG_TEST_BITFIELD[0m) += test_bitfield.o
obj-$([31mCONFIG_TEST_UUID[0m) += test_uuid.o
obj-$([31mCONFIG_TEST_XARRAY[0m) += test_xarray.o
obj-$([31mCONFIG_TEST_PARMAN[0m) += test_parman.o
obj-$([31mCONFIG_TEST_KMOD[0m) += test_kmod.o
obj-$([31mCONFIG_TEST_DEBUG_VIRTUAL[0m) += test_debug_virtual.o
obj-$([31mCONFIG_TEST_MEMCAT_P[0m) += test_memcat_p.o
obj-$([31mCONFIG_TEST_OBJAGG[0m) += test_objagg.o
obj-$([31mCONFIG_TEST_STACKINIT[0m) += test_stackinit.o
obj-$([31mCONFIG_TEST_BLACKHOLE_DEV[0m) += test_blackhole_dev.o
obj-$([31mCONFIG_TEST_MEMINIT[0m) += test_meminit.o
obj-$([31mCONFIG_TEST_LIVEPATCH[0m) += livepatch/
ifeq ($([31mCONFIG_DEBUG_KOBJECT[0m),y)
CFLAGS_kobject.o += -DDEBUG
CFLAGS_kobject_uevent.o += -DDEBUG
endif
obj-$([31mCONFIG_DEBUG_INFO_REDUCED[0m) += debug_info.o
CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
obj-y += math/ crypto/
obj-$([31mCONFIG_GENERIC_IOMAP[0m) += iomap.o
obj-$([31mCONFIG_GENERIC_PCI_IOMAP[0m) += pci_iomap.o
obj-$([31mCONFIG_HAS_IOMEM[0m) += iomap_copy.o devres.o
obj-$([31mCONFIG_CHECK_SIGNATURE[0m) += check_signature.o
obj-$([31mCONFIG_DEBUG_LOCKING_API_SELFTESTS[0m) += locking-selftest.o
obj-y += logic_pio.o
obj-$([31mCONFIG_GENERIC_HWEIGHT[0m) += hweight.o
obj-$([31mCONFIG_BTREE[0m) += btree.o
obj-$([31mCONFIG_INTERVAL_TREE[0m) += interval_tree.o
obj-$([31mCONFIG_ASSOCIATIVE_ARRAY[0m) += assoc_array.o
obj-$([31mCONFIG_DEBUG_PREEMPT[0m) += smp_processor_id.o
obj-$([31mCONFIG_DEBUG_LIST[0m) += list_debug.o
obj-$([31mCONFIG_DEBUG_OBJECTS[0m) += debugobjects.o
obj-$([31mCONFIG_BITREVERSE[0m) += bitrev.o
obj-$([31mCONFIG_PACKING[0m) += packing.o
obj-$([31mCONFIG_CRC_CCITT[0m) += crc-ccitt.o
obj-$([31mCONFIG_CRC16[0m) += crc16.o
obj-$([31mCONFIG_CRC_T10DIF[0m)+= crc-t10dif.o
obj-$([31mCONFIG_CRC_ITU_T[0m) += crc-itu-t.o
obj-$([31mCONFIG_CRC32[0m) += crc32.o
obj-$([31mCONFIG_CRC64[0m) += crc64.o
obj-$([31mCONFIG_CRC32_SELFTEST[0m) += crc32test.o
obj-$([31mCONFIG_CRC4[0m) += crc4.o
obj-$([31mCONFIG_CRC7[0m) += crc7.o
obj-$([31mCONFIG_LIBCRC32C[0m) += libcrc32c.o
obj-$([31mCONFIG_CRC8[0m) += crc8.o
obj-$([31mCONFIG_XXHASH[0m) += xxhash.o
obj-$([31mCONFIG_GENERIC_ALLOCATOR[0m) += genalloc.o
obj-$([31mCONFIG_842_COMPRESS[0m) += 842/
obj-$([31mCONFIG_842_DECOMPRESS[0m) += 842/
obj-$([31mCONFIG_ZLIB_INFLATE[0m) += zlib_inflate/
obj-$([31mCONFIG_ZLIB_DEFLATE[0m) += zlib_deflate/
obj-$([31mCONFIG_REED_SOLOMON[0m) += reed_solomon/
obj-$([31mCONFIG_BCH[0m) += bch.o
obj-$([31mCONFIG_LZO_COMPRESS[0m) += lzo/
obj-$([31mCONFIG_LZO_DECOMPRESS[0m) += lzo/
obj-$([31mCONFIG_LZ4_COMPRESS[0m) += lz4/
obj-$([31mCONFIG_LZ4HC_COMPRESS[0m) += lz4/
obj-$([31mCONFIG_LZ4_DECOMPRESS[0m) += lz4/
obj-$([31mCONFIG_ZSTD_COMPRESS[0m) += zstd/
obj-$([31mCONFIG_ZSTD_DECOMPRESS[0m) += zstd/
obj-$([31mCONFIG_XZ_DEC[0m) += xz/
obj-$([31mCONFIG_RAID6_PQ[0m) += raid6/
lib-$([31mCONFIG_DECOMPRESS_GZIP[0m) += decompress_inflate.o
lib-$([31mCONFIG_DECOMPRESS_BZIP2[0m) += decompress_bunzip2.o
lib-$([31mCONFIG_DECOMPRESS_LZMA[0m) += decompress_unlzma.o
lib-$([31mCONFIG_DECOMPRESS_XZ[0m) += decompress_unxz.o
lib-$([31mCONFIG_DECOMPRESS_LZO[0m) += decompress_unlzo.o
lib-$([31mCONFIG_DECOMPRESS_LZ4[0m) += decompress_unlz4.o
obj-$([31mCONFIG_TEXTSEARCH[0m) += textsearch.o
obj-$([31mCONFIG_TEXTSEARCH_KMP[0m) += ts_kmp.o
obj-$([31mCONFIG_TEXTSEARCH_BM[0m) += ts_bm.o
obj-$([31mCONFIG_TEXTSEARCH_FSM[0m) += ts_fsm.o
obj-$([31mCONFIG_SMP[0m) += percpu_counter.o
obj-$([31mCONFIG_AUDIT_GENERIC[0m) += audit.o
obj-$([31mCONFIG_AUDIT_COMPAT_GENERIC[0m) += compat_audit.o
obj-$([31mCONFIG_IOMMU_HELPER[0m) += iommu-helper.o
obj-$([31mCONFIG_FAULT_INJECTION[0m) += fault-inject.o
obj-$([31mCONFIG_NOTIFIER_ERROR_INJECTION[0m) += notifier-error-inject.o
obj-$([31mCONFIG_PM_NOTIFIER_ERROR_INJECT[0m) += pm-notifier-error-inject.o
obj-$([31mCONFIG_NETDEV_NOTIFIER_ERROR_INJECT[0m) += netdev-notifier-error-inject.o
obj-$([31mCONFIG_MEMORY_NOTIFIER_ERROR_INJECT[0m) += memory-notifier-error-inject.o
obj-$([31mCONFIG_OF_RECONFIG_NOTIFIER_ERROR_INJECT[0m) += \
of-reconfig-notifier-error-inject.o
obj-$([31mCONFIG_FUNCTION_ERROR_INJECTION[0m) += error-inject.o
lib-$([31mCONFIG_GENERIC_BUG[0m) += bug.o
obj-$([31mCONFIG_HAVE_ARCH_TRACEHOOK[0m) += syscall.o
obj-$([31mCONFIG_DYNAMIC_DEBUG[0m) += dynamic_debug.o
obj-$([31mCONFIG_NLATTR[0m) += nlattr.o
obj-$([31mCONFIG_LRU_CACHE[0m) += lru_cache.o
obj-$([31mCONFIG_GENERIC_CSUM[0m) += checksum.o
obj-$([31mCONFIG_GENERIC_ATOMIC64[0m) += atomic64.o
obj-$([31mCONFIG_ATOMIC64_SELFTEST[0m) += atomic64_test.o
obj-$([31mCONFIG_CPU_RMAP[0m) += cpu_rmap.o
obj-$([31mCONFIG_DQL[0m) += dynamic_queue_limits.o
obj-$([31mCONFIG_GLOB[0m) += glob.o
obj-$([31mCONFIG_GLOB_SELFTEST[0m) += globtest.o
obj-$([31mCONFIG_MPILIB[0m) += mpi/
obj-$([31mCONFIG_DIMLIB[0m) += dim/
obj-$([31mCONFIG_SIGNATURE[0m) += digsig.o
lib-$([31mCONFIG_CLZ_TAB[0m) += clz_tab.o
obj-$([31mCONFIG_GENERIC_STRNCPY_FROM_USER[0m) += strncpy_from_user.o
obj-$([31mCONFIG_GENERIC_STRNLEN_USER[0m) += strnlen_user.o
obj-$([31mCONFIG_GENERIC_NET_UTILS[0m) += net_utils.o
obj-$([31mCONFIG_SG_SPLIT[0m) += sg_split.o
obj-$([31mCONFIG_SG_POOL[0m) += sg_pool.o
obj-$([31mCONFIG_STMP_DEVICE[0m) += stmp_device.o
obj-$([31mCONFIG_IRQ_POLL[0m) += irq_poll.o
obj-$([31mCONFIG_STACKDEPOT[0m) += stackdepot.o
KASAN_SANITIZE_stackdepot.o := n
KCOV_INSTRUMENT_stackdepot.o := n
libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
fdt_empty_tree.o
$(foreach file, $(libfdt_files), \
$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
lib-$([31mCONFIG_LIBFDT[0m) += $(libfdt_files)
obj-$([31mCONFIG_RBTREE_TEST[0m) += rbtree_test.o
obj-$([31mCONFIG_INTERVAL_TREE_TEST[0m) += interval_tree_test.o
obj-$([31mCONFIG_PERCPU_TEST[0m) += percpu_test.o
obj-$([31mCONFIG_ASN1[0m) += asn1_decoder.o
obj-$([31mCONFIG_FONT_SUPPORT[0m) += fonts/
hostprogs-y := gen_crc32table
hostprogs-y += gen_crc64table
clean-files := crc32table.h
clean-files += crc64table.h
$(obj)/crc32.o: $(obj)/crc32table.h
quiet_cmd_crc32 = GEN $@
cmd_crc32 = $< > $@
$(obj)/crc32table.h: $(obj)/gen_crc32table
$(call cmd,crc32)
$(obj)/crc64.o: $(obj)/crc64table.h
quiet_cmd_crc64 = GEN $@
cmd_crc64 = $< > $@
$(obj)/crc64table.h: $(obj)/gen_crc64table
$(call cmd,crc64)
#
# Build a fast OID lookip registry from include/linux/oid_registry.h
#
obj-$([31mCONFIG_OID_REGISTRY[0m) += oid_registry.o
$(obj)/oid_registry.o: $(obj)/oid_registry_data.c
$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
$(src)/build_OID_registry
$(call cmd,build_OID_registry)
quiet_cmd_build_OID_registry = GEN $@
cmd_build_OID_registry = perl $(srctree)/$(src)/build_OID_registry $< $@
clean-files += oid_registry_data.c
obj-$([31mCONFIG_UCS2_STRING[0m) += ucs2_string.o
obj-$([31mCONFIG_UBSAN[0m) += ubsan.o
UBSAN_SANITIZE_ubsan.o := n
KASAN_SANITIZE_ubsan.o := n
CFLAGS_ubsan.o := $(call cc-option, -fno-stack-protector) $(DISABLE_STACKLEAK_PLUGIN)
obj-$([31mCONFIG_SBITMAP[0m) += sbitmap.o
obj-$([31mCONFIG_PARMAN[0m) += parman.o
# GCC library routines
obj-$([31mCONFIG_GENERIC_LIB_ASHLDI3[0m) += ashldi3.o
obj-$([31mCONFIG_GENERIC_LIB_ASHRDI3[0m) += ashrdi3.o
obj-$([31mCONFIG_GENERIC_LIB_LSHRDI3[0m) += lshrdi3.o
obj-$([31mCONFIG_GENERIC_LIB_MULDI3[0m) += muldi3.o
obj-$([31mCONFIG_GENERIC_LIB_CMPDI2[0m) += cmpdi2.o
obj-$([31mCONFIG_GENERIC_LIB_UCMPDI2[0m) += ucmpdi2.o
obj-$([31mCONFIG_OBJAGG[0m) += objagg.o