162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci# Makefile for some libs needed in the kernel.
462306a36Sopenharmony_ci#
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci# These files are disabled because they produce lots of non-interesting and/or
962306a36Sopenharmony_ci# flaky coverage that is not a function of syscall inputs. For example,
1062306a36Sopenharmony_ci# rbtree can be global and individual rotations don't correlate with inputs.
1162306a36Sopenharmony_ciKCOV_INSTRUMENT_string.o := n
1262306a36Sopenharmony_ciKCOV_INSTRUMENT_rbtree.o := n
1362306a36Sopenharmony_ciKCOV_INSTRUMENT_list_debug.o := n
1462306a36Sopenharmony_ciKCOV_INSTRUMENT_debugobjects.o := n
1562306a36Sopenharmony_ciKCOV_INSTRUMENT_dynamic_debug.o := n
1662306a36Sopenharmony_ciKCOV_INSTRUMENT_fault-inject.o := n
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci# string.o implements standard library functions like memset/memcpy etc.
1962306a36Sopenharmony_ci# Use -ffreestanding to ensure that the compiler does not try to "optimize"
2062306a36Sopenharmony_ci# them into calls to themselves.
2162306a36Sopenharmony_ciCFLAGS_string.o := -ffreestanding
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci# Early boot use of cmdline, don't instrument it
2462306a36Sopenharmony_ciifdef CONFIG_AMD_MEM_ENCRYPT
2562306a36Sopenharmony_ciKASAN_SANITIZE_string.o := n
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciCFLAGS_string.o += -fno-stack-protector
2862306a36Sopenharmony_ciendif
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_cilib-y := ctype.o string.o vsprintf.o cmdline.o \
3162306a36Sopenharmony_ci	 rbtree.o radix-tree.o timerqueue.o xarray.o \
3262306a36Sopenharmony_ci	 maple_tree.o idr.o extable.o irq_regs.o argv_split.o \
3362306a36Sopenharmony_ci	 flex_proportions.o ratelimit.o \
3462306a36Sopenharmony_ci	 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
3562306a36Sopenharmony_ci	 earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
3662306a36Sopenharmony_ci	 nmi_backtrace.o win_minmax.o memcat_p.o \
3762306a36Sopenharmony_ci	 buildid.o
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_cilib-$(CONFIG_PRINTK) += dump_stack.o
4062306a36Sopenharmony_cilib-$(CONFIG_SMP) += cpumask.o
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cilib-y	+= kobject.o klist.o
4362306a36Sopenharmony_ciobj-y	+= lockref.o
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciobj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
4662306a36Sopenharmony_ci	 bust_spinlocks.o kasprintf.o bitmap.o scatterlist.o \
4762306a36Sopenharmony_ci	 list_sort.o uuid.o iov_iter.o clz_ctz.o \
4862306a36Sopenharmony_ci	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
4962306a36Sopenharmony_ci	 percpu-refcount.o rhashtable.o base64.o \
5062306a36Sopenharmony_ci	 once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \
5162306a36Sopenharmony_ci	 generic-radix-tree.o
5262306a36Sopenharmony_ciobj-$(CONFIG_STRING_SELFTEST) += test_string.o
5362306a36Sopenharmony_ciobj-y += string_helpers.o
5462306a36Sopenharmony_ciobj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
5562306a36Sopenharmony_ciobj-y += hexdump.o
5662306a36Sopenharmony_ciobj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o
5762306a36Sopenharmony_ciobj-y += kstrtox.o
5862306a36Sopenharmony_ciobj-$(CONFIG_FIND_BIT_BENCHMARK) += find_bit_benchmark.o
5962306a36Sopenharmony_ciobj-$(CONFIG_TEST_BPF) += test_bpf.o
6062306a36Sopenharmony_citest_dhry-objs := dhry_1.o dhry_2.o dhry_run.o
6162306a36Sopenharmony_ciobj-$(CONFIG_TEST_DHRY) += test_dhry.o
6262306a36Sopenharmony_ciobj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
6362306a36Sopenharmony_ciobj-$(CONFIG_TEST_BITOPS) += test_bitops.o
6462306a36Sopenharmony_ciCFLAGS_test_bitops.o += -Werror
6562306a36Sopenharmony_ciobj-$(CONFIG_CPUMASK_KUNIT_TEST) += cpumask_kunit.o
6662306a36Sopenharmony_ciobj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o
6762306a36Sopenharmony_ciobj-$(CONFIG_TEST_IOV_ITER) += kunit_iov_iter.o
6862306a36Sopenharmony_ciobj-$(CONFIG_HASH_KUNIT_TEST) += test_hash.o
6962306a36Sopenharmony_ciobj-$(CONFIG_TEST_IDA) += test_ida.o
7062306a36Sopenharmony_ciobj-$(CONFIG_TEST_UBSAN) += test_ubsan.o
7162306a36Sopenharmony_ciCFLAGS_test_ubsan.o += $(call cc-disable-warning, vla)
7262306a36Sopenharmony_ciUBSAN_SANITIZE_test_ubsan.o := y
7362306a36Sopenharmony_ciobj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
7462306a36Sopenharmony_ciobj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o
7562306a36Sopenharmony_ciobj-$(CONFIG_TEST_MIN_HEAP) += test_min_heap.o
7662306a36Sopenharmony_ciobj-$(CONFIG_TEST_LKM) += test_module.o
7762306a36Sopenharmony_ciobj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o
7862306a36Sopenharmony_ciobj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o
7962306a36Sopenharmony_ciobj-$(CONFIG_TEST_SORT) += test_sort.o
8062306a36Sopenharmony_ciobj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
8162306a36Sopenharmony_ciobj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
8262306a36Sopenharmony_ciobj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
8362306a36Sopenharmony_ciobj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o
8462306a36Sopenharmony_ciobj-$(CONFIG_TEST_PRINTF) += test_printf.o
8562306a36Sopenharmony_ciobj-$(CONFIG_TEST_SCANF) += test_scanf.o
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciobj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
8862306a36Sopenharmony_ciifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy)
8962306a36Sopenharmony_ci# FIXME: Clang breaks test_bitmap_const_eval when KASAN and GCOV are enabled
9062306a36Sopenharmony_ciGCOV_PROFILE_test_bitmap.o := n
9162306a36Sopenharmony_ciendif
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciobj-$(CONFIG_TEST_UUID) += test_uuid.o
9462306a36Sopenharmony_ciobj-$(CONFIG_TEST_XARRAY) += test_xarray.o
9562306a36Sopenharmony_ciobj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
9662306a36Sopenharmony_ciobj-$(CONFIG_TEST_PARMAN) += test_parman.o
9762306a36Sopenharmony_ciobj-$(CONFIG_TEST_KMOD) += test_kmod.o
9862306a36Sopenharmony_ciobj-$(CONFIG_TEST_DEBUG_VIRTUAL) += test_debug_virtual.o
9962306a36Sopenharmony_ciobj-$(CONFIG_TEST_MEMCAT_P) += test_memcat_p.o
10062306a36Sopenharmony_ciobj-$(CONFIG_TEST_OBJAGG) += test_objagg.o
10162306a36Sopenharmony_ciobj-$(CONFIG_TEST_BLACKHOLE_DEV) += test_blackhole_dev.o
10262306a36Sopenharmony_ciobj-$(CONFIG_TEST_MEMINIT) += test_meminit.o
10362306a36Sopenharmony_ciobj-$(CONFIG_TEST_LOCKUP) += test_lockup.o
10462306a36Sopenharmony_ciobj-$(CONFIG_TEST_HMM) += test_hmm.o
10562306a36Sopenharmony_ciobj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o
10662306a36Sopenharmony_ciobj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
10762306a36Sopenharmony_ciobj-$(CONFIG_TEST_REF_TRACKER) += test_ref_tracker.o
10862306a36Sopenharmony_ciCFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE)
10962306a36Sopenharmony_ciobj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o
11062306a36Sopenharmony_ci#
11162306a36Sopenharmony_ci# CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns
11262306a36Sopenharmony_ci# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS
11362306a36Sopenharmony_ci# get appended last to CFLAGS and thus override those previous compiler options.
11462306a36Sopenharmony_ci#
11562306a36Sopenharmony_ciFPU_CFLAGS := -msse -msse2
11662306a36Sopenharmony_ciifdef CONFIG_CC_IS_GCC
11762306a36Sopenharmony_ci# Stack alignment mismatch, proceed with caution.
11862306a36Sopenharmony_ci# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
11962306a36Sopenharmony_ci# (8B stack alignment).
12062306a36Sopenharmony_ci# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
12162306a36Sopenharmony_ci#
12262306a36Sopenharmony_ci# The "-msse" in the first argument is there so that the
12362306a36Sopenharmony_ci# -mpreferred-stack-boundary=3 build error:
12462306a36Sopenharmony_ci#
12562306a36Sopenharmony_ci#  -mpreferred-stack-boundary=3 is not between 4 and 12
12662306a36Sopenharmony_ci#
12762306a36Sopenharmony_ci# can be triggered. Otherwise gcc doesn't complain.
12862306a36Sopenharmony_ciFPU_CFLAGS += -mhard-float
12962306a36Sopenharmony_ciFPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
13062306a36Sopenharmony_ciendif
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ciobj-$(CONFIG_TEST_FPU) += test_fpu.o
13362306a36Sopenharmony_ciCFLAGS_test_fpu.o += $(FPU_CFLAGS)
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciobj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci# Some KUnit files (hooks.o) need to be built-in even when KUnit is a module,
13862306a36Sopenharmony_ci# so we can't just use obj-$(CONFIG_KUNIT).
13962306a36Sopenharmony_ciifdef CONFIG_KUNIT
14062306a36Sopenharmony_ciobj-y += kunit/
14162306a36Sopenharmony_ciendif
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ciifeq ($(CONFIG_DEBUG_KOBJECT),y)
14462306a36Sopenharmony_ciCFLAGS_kobject.o += -DDEBUG
14562306a36Sopenharmony_ciCFLAGS_kobject_uevent.o += -DDEBUG
14662306a36Sopenharmony_ciendif
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ciobj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
14962306a36Sopenharmony_ciCFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciobj-y += math/ crypto/
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_IOMAP) += iomap.o
15462306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
15562306a36Sopenharmony_ciobj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
15662306a36Sopenharmony_ciobj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
15762306a36Sopenharmony_ciobj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_cilib-y += logic_pio.o
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_cilib-$(CONFIG_INDIRECT_IOMEM) += logic_iomem.o
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ciobj-$(CONFIG_TRACE_MMIO_ACCESS) += trace_readwrite.o
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ciobj-$(CONFIG_BTREE) += btree.o
16862306a36Sopenharmony_ciobj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
16962306a36Sopenharmony_ciobj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
17062306a36Sopenharmony_ciobj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
17162306a36Sopenharmony_ciobj-$(CONFIG_LIST_HARDENED) += list_debug.o
17262306a36Sopenharmony_ciobj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ciobj-$(CONFIG_BITREVERSE) += bitrev.o
17562306a36Sopenharmony_ciobj-$(CONFIG_LINEAR_RANGES) += linear_ranges.o
17662306a36Sopenharmony_ciobj-$(CONFIG_PACKING)	+= packing.o
17762306a36Sopenharmony_ciobj-$(CONFIG_CRC_CCITT)	+= crc-ccitt.o
17862306a36Sopenharmony_ciobj-$(CONFIG_CRC16)	+= crc16.o
17962306a36Sopenharmony_ciobj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
18062306a36Sopenharmony_ciobj-$(CONFIG_CRC_ITU_T)	+= crc-itu-t.o
18162306a36Sopenharmony_ciobj-$(CONFIG_CRC32)	+= crc32.o
18262306a36Sopenharmony_ciobj-$(CONFIG_CRC64)     += crc64.o
18362306a36Sopenharmony_ciobj-$(CONFIG_CRC32_SELFTEST)	+= crc32test.o
18462306a36Sopenharmony_ciobj-$(CONFIG_CRC4)	+= crc4.o
18562306a36Sopenharmony_ciobj-$(CONFIG_CRC7)	+= crc7.o
18662306a36Sopenharmony_ciobj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
18762306a36Sopenharmony_ciobj-$(CONFIG_CRC8)	+= crc8.o
18862306a36Sopenharmony_ciobj-$(CONFIG_CRC64_ROCKSOFT) += crc64-rocksoft.o
18962306a36Sopenharmony_ciobj-$(CONFIG_XXHASH)	+= xxhash.o
19062306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ciobj-$(CONFIG_842_COMPRESS) += 842/
19362306a36Sopenharmony_ciobj-$(CONFIG_842_DECOMPRESS) += 842/
19462306a36Sopenharmony_ciobj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
19562306a36Sopenharmony_ciobj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
19662306a36Sopenharmony_ciobj-$(CONFIG_ZLIB_DFLTCC) += zlib_dfltcc/
19762306a36Sopenharmony_ciobj-$(CONFIG_REED_SOLOMON) += reed_solomon/
19862306a36Sopenharmony_ciobj-$(CONFIG_BCH) += bch.o
19962306a36Sopenharmony_ciobj-$(CONFIG_LZO_COMPRESS) += lzo/
20062306a36Sopenharmony_ciobj-$(CONFIG_LZO_DECOMPRESS) += lzo/
20162306a36Sopenharmony_ciobj-$(CONFIG_LZ4_COMPRESS) += lz4/
20262306a36Sopenharmony_ciobj-$(CONFIG_LZ4HC_COMPRESS) += lz4/
20362306a36Sopenharmony_ciobj-$(CONFIG_LZ4_DECOMPRESS) += lz4/
20462306a36Sopenharmony_ciobj-$(CONFIG_ZSTD_COMPRESS) += zstd/
20562306a36Sopenharmony_ciobj-$(CONFIG_ZSTD_DECOMPRESS) += zstd/
20662306a36Sopenharmony_ciobj-$(CONFIG_XZ_DEC) += xz/
20762306a36Sopenharmony_ciobj-$(CONFIG_RAID6_PQ) += raid6/
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
21062306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
21162306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
21262306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
21362306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
21462306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_LZ4) += decompress_unlz4.o
21562306a36Sopenharmony_cilib-$(CONFIG_DECOMPRESS_ZSTD) += decompress_unzstd.o
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ciobj-$(CONFIG_TEXTSEARCH) += textsearch.o
21862306a36Sopenharmony_ciobj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
21962306a36Sopenharmony_ciobj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o
22062306a36Sopenharmony_ciobj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
22162306a36Sopenharmony_ciobj-$(CONFIG_SMP) += percpu_counter.o
22262306a36Sopenharmony_ciobj-$(CONFIG_AUDIT_GENERIC) += audit.o
22362306a36Sopenharmony_ciobj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ciobj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
22662306a36Sopenharmony_ciobj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
22762306a36Sopenharmony_ciobj-$(CONFIG_FAULT_INJECTION_USERCOPY) += fault-inject-usercopy.o
22862306a36Sopenharmony_ciobj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
22962306a36Sopenharmony_ciobj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o
23062306a36Sopenharmony_ciobj-$(CONFIG_NETDEV_NOTIFIER_ERROR_INJECT) += netdev-notifier-error-inject.o
23162306a36Sopenharmony_ciobj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o
23262306a36Sopenharmony_ciobj-$(CONFIG_OF_RECONFIG_NOTIFIER_ERROR_INJECT) += \
23362306a36Sopenharmony_ci	of-reconfig-notifier-error-inject.o
23462306a36Sopenharmony_ciobj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_cilib-$(CONFIG_GENERIC_BUG) += bug.o
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ciobj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ciobj-$(CONFIG_DYNAMIC_DEBUG_CORE) += dynamic_debug.o
24162306a36Sopenharmony_ci#ensure exported functions have prototypes
24262306a36Sopenharmony_ciCFLAGS_dynamic_debug.o := -DDYNAMIC_DEBUG_MODULE
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ciobj-$(CONFIG_SYMBOLIC_ERRNAME) += errname.o
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ciobj-$(CONFIG_NLATTR) += nlattr.o
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ciobj-$(CONFIG_LRU_CACHE) += lru_cache.o
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_CSUM) += checksum.o
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ciobj-$(CONFIG_ATOMIC64_SELFTEST) += atomic64_test.o
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ciobj-$(CONFIG_CPU_RMAP) += cpu_rmap.o
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ciobj-$(CONFIG_DQL) += dynamic_queue_limits.o
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ciobj-$(CONFIG_GLOB) += glob.o
26162306a36Sopenharmony_ciobj-$(CONFIG_GLOB_SELFTEST) += globtest.o
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ciobj-$(CONFIG_DIMLIB) += dim/
26462306a36Sopenharmony_ciobj-$(CONFIG_SIGNATURE) += digsig.o
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cilib-$(CONFIG_CLZ_TAB) += clz_tab.o
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
26962306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_NET_UTILS) += net_utils.o
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ciobj-$(CONFIG_SG_SPLIT) += sg_split.o
27462306a36Sopenharmony_ciobj-$(CONFIG_SG_POOL) += sg_pool.o
27562306a36Sopenharmony_ciobj-$(CONFIG_MEMREGION) += memregion.o
27662306a36Sopenharmony_ciobj-$(CONFIG_STMP_DEVICE) += stmp_device.o
27762306a36Sopenharmony_ciobj-$(CONFIG_IRQ_POLL) += irq_poll.o
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ciobj-$(CONFIG_POLYNOMIAL) += polynomial.o
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci# stackdepot.c should not be instrumented or call instrumented functions.
28262306a36Sopenharmony_ci# Prevent the compiler from calling builtins like memcmp() or bcmp() from this
28362306a36Sopenharmony_ci# file.
28462306a36Sopenharmony_ciCFLAGS_stackdepot.o += -fno-builtin
28562306a36Sopenharmony_ciobj-$(CONFIG_STACKDEPOT) += stackdepot.o
28662306a36Sopenharmony_ciKASAN_SANITIZE_stackdepot.o := n
28762306a36Sopenharmony_ci# In particular, instrumenting stackdepot.c with KMSAN will result in infinite
28862306a36Sopenharmony_ci# recursion.
28962306a36Sopenharmony_ciKMSAN_SANITIZE_stackdepot.o := n
29062306a36Sopenharmony_ciKCOV_INSTRUMENT_stackdepot.o := n
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ciobj-$(CONFIG_REF_TRACKER) += ref_tracker.o
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_cilibfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
29562306a36Sopenharmony_ci	       fdt_empty_tree.o fdt_addresses.o
29662306a36Sopenharmony_ci$(foreach file, $(libfdt_files), \
29762306a36Sopenharmony_ci	$(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt))
29862306a36Sopenharmony_cilib-$(CONFIG_LIBFDT) += $(libfdt_files)
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ciobj-$(CONFIG_BOOT_CONFIG) += bootconfig.o
30162306a36Sopenharmony_ciobj-$(CONFIG_BOOT_CONFIG_EMBED) += bootconfig-data.o
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci$(obj)/bootconfig-data.o: $(obj)/default.bconf
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_citargets += default.bconf
30662306a36Sopenharmony_cifilechk_defbconf = cat $(or $(real-prereqs), /dev/null)
30762306a36Sopenharmony_ci$(obj)/default.bconf: $(CONFIG_BOOT_CONFIG_EMBED_FILE) FORCE
30862306a36Sopenharmony_ci	$(call filechk,defbconf)
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ciobj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
31162306a36Sopenharmony_ciobj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ciobj-$(CONFIG_PERCPU_TEST) += percpu_test.o
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ciobj-$(CONFIG_ASN1) += asn1_decoder.o
31662306a36Sopenharmony_ciobj-$(CONFIG_ASN1_ENCODER) += asn1_encoder.o
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ciobj-$(CONFIG_FONT_SUPPORT) += fonts/
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_cihostprogs	:= gen_crc32table
32162306a36Sopenharmony_cihostprogs	+= gen_crc64table
32262306a36Sopenharmony_ciclean-files	:= crc32table.h
32362306a36Sopenharmony_ciclean-files	+= crc64table.h
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci$(obj)/crc32.o: $(obj)/crc32table.h
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ciquiet_cmd_crc32 = GEN     $@
32862306a36Sopenharmony_ci      cmd_crc32 = $< > $@
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci$(obj)/crc32table.h: $(obj)/gen_crc32table
33162306a36Sopenharmony_ci	$(call cmd,crc32)
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci$(obj)/crc64.o: $(obj)/crc64table.h
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ciquiet_cmd_crc64 = GEN     $@
33662306a36Sopenharmony_ci      cmd_crc64 = $< > $@
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci$(obj)/crc64table.h: $(obj)/gen_crc64table
33962306a36Sopenharmony_ci	$(call cmd,crc64)
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci#
34262306a36Sopenharmony_ci# Build a fast OID lookip registry from include/linux/oid_registry.h
34362306a36Sopenharmony_ci#
34462306a36Sopenharmony_ciobj-$(CONFIG_OID_REGISTRY) += oid_registry.o
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci$(obj)/oid_registry.o: $(obj)/oid_registry_data.c
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
34962306a36Sopenharmony_ci			    $(src)/build_OID_registry
35062306a36Sopenharmony_ci	$(call cmd,build_OID_registry)
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ciquiet_cmd_build_OID_registry = GEN     $@
35362306a36Sopenharmony_ci      cmd_build_OID_registry = perl $(srctree)/$(src)/build_OID_registry $< $@
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ciclean-files	+= oid_registry_data.c
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ciobj-$(CONFIG_UCS2_STRING) += ucs2_string.o
35862306a36Sopenharmony_ciobj-$(CONFIG_UBSAN) += ubsan.o
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciUBSAN_SANITIZE_ubsan.o := n
36162306a36Sopenharmony_ciKASAN_SANITIZE_ubsan.o := n
36262306a36Sopenharmony_ciKCSAN_SANITIZE_ubsan.o := n
36362306a36Sopenharmony_ciCFLAGS_ubsan.o := -fno-stack-protector $(DISABLE_STACKLEAK_PLUGIN)
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_ciobj-$(CONFIG_SBITMAP) += sbitmap.o
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ciobj-$(CONFIG_PARMAN) += parman.o
36862306a36Sopenharmony_ci
36962306a36Sopenharmony_ciobj-y += group_cpus.o
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci# GCC library routines
37262306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o
37362306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_ASHRDI3) += ashrdi3.o
37462306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_LSHRDI3) += lshrdi3.o
37562306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o
37662306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o
37762306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
37862306a36Sopenharmony_ciobj-$(CONFIG_OBJAGG) += objagg.o
37962306a36Sopenharmony_ci
38062306a36Sopenharmony_ci# pldmfw library
38162306a36Sopenharmony_ciobj-$(CONFIG_PLDMFW) += pldmfw/
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_ci# KUnit tests
38462306a36Sopenharmony_ciCFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN)
38562306a36Sopenharmony_ciobj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
38662306a36Sopenharmony_ciobj-$(CONFIG_CHECKSUM_KUNIT) += checksum_kunit.o
38762306a36Sopenharmony_ciobj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
38862306a36Sopenharmony_ciobj-$(CONFIG_HASHTABLE_KUNIT_TEST) += hashtable_test.o
38962306a36Sopenharmony_ciobj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
39062306a36Sopenharmony_ciobj-$(CONFIG_BITS_TEST) += test_bits.o
39162306a36Sopenharmony_ciobj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o
39262306a36Sopenharmony_ciobj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o
39362306a36Sopenharmony_ciobj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o
39462306a36Sopenharmony_ciobj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) += is_signed_type_kunit.o
39562306a36Sopenharmony_ciCFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare)
39662306a36Sopenharmony_ciobj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
39762306a36Sopenharmony_ciCFLAGS_stackinit_kunit.o += $(call cc-disable-warning, switch-unreachable)
39862306a36Sopenharmony_ciobj-$(CONFIG_STACKINIT_KUNIT_TEST) += stackinit_kunit.o
39962306a36Sopenharmony_ciCFLAGS_fortify_kunit.o += $(call cc-disable-warning, unsequenced)
40062306a36Sopenharmony_ciCFLAGS_fortify_kunit.o += $(DISABLE_STRUCTLEAK_PLUGIN)
40162306a36Sopenharmony_ciobj-$(CONFIG_FORTIFY_KUNIT_TEST) += fortify_kunit.o
40262306a36Sopenharmony_ciobj-$(CONFIG_STRCAT_KUNIT_TEST) += strcat_kunit.o
40362306a36Sopenharmony_ciobj-$(CONFIG_STRSCPY_KUNIT_TEST) += strscpy_kunit.o
40462306a36Sopenharmony_ciobj-$(CONFIG_SIPHASH_KUNIT_TEST) += siphash_kunit.o
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED) += devmem_is_allowed.o
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci# FORTIFY_SOURCE compile-time behavior tests
40962306a36Sopenharmony_ciTEST_FORTIFY_SRCS = $(wildcard $(srctree)/$(src)/test_fortify/*-*.c)
41062306a36Sopenharmony_ciTEST_FORTIFY_LOGS = $(patsubst $(srctree)/$(src)/%.c, %.log, $(TEST_FORTIFY_SRCS))
41162306a36Sopenharmony_ciTEST_FORTIFY_LOG = test_fortify.log
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ciquiet_cmd_test_fortify = TEST    $@
41462306a36Sopenharmony_ci      cmd_test_fortify = $(CONFIG_SHELL) $(srctree)/scripts/test_fortify.sh \
41562306a36Sopenharmony_ci			$< $@ "$(NM)" $(CC) $(c_flags) \
41662306a36Sopenharmony_ci			$(call cc-disable-warning,fortify-source) \
41762306a36Sopenharmony_ci			-DKBUILD_EXTRA_WARN1
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_citargets += $(TEST_FORTIFY_LOGS)
42062306a36Sopenharmony_ciclean-files += $(TEST_FORTIFY_LOGS)
42162306a36Sopenharmony_ciclean-files += $(addsuffix .o, $(TEST_FORTIFY_LOGS))
42262306a36Sopenharmony_ci$(obj)/test_fortify/%.log: $(src)/test_fortify/%.c \
42362306a36Sopenharmony_ci			   $(src)/test_fortify/test_fortify.h \
42462306a36Sopenharmony_ci			   $(srctree)/include/linux/fortify-string.h \
42562306a36Sopenharmony_ci			   $(srctree)/scripts/test_fortify.sh \
42662306a36Sopenharmony_ci			   FORCE
42762306a36Sopenharmony_ci	$(call if_changed,test_fortify)
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_ciquiet_cmd_gen_fortify_log = GEN     $@
43062306a36Sopenharmony_ci      cmd_gen_fortify_log = cat </dev/null $(filter-out FORCE,$^) 2>/dev/null > $@ || true
43162306a36Sopenharmony_ci
43262306a36Sopenharmony_citargets += $(TEST_FORTIFY_LOG)
43362306a36Sopenharmony_ciclean-files += $(TEST_FORTIFY_LOG)
43462306a36Sopenharmony_ci$(obj)/$(TEST_FORTIFY_LOG): $(addprefix $(obj)/, $(TEST_FORTIFY_LOGS)) FORCE
43562306a36Sopenharmony_ci	$(call if_changed,gen_fortify_log)
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci# Fake dependency to trigger the fortify tests.
43862306a36Sopenharmony_ciifeq ($(CONFIG_FORTIFY_SOURCE),y)
43962306a36Sopenharmony_ci$(obj)/string.o: $(obj)/$(TEST_FORTIFY_LOG)
44062306a36Sopenharmony_ciendif
441