blob: ae2d261daec9a5ecbf416ee1cd6d715685c7acef [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001# SPDX-License-Identifier: GPL-2.0
2#
3# Makefile for some libs needed in the kernel.
4#
5
6ifdef CONFIG_FUNCTION_TRACER
7ORIG_CFLAGS := $(KBUILD_CFLAGS)
8KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
9endif
10
11# These files are disabled because they produce lots of non-interesting and/or
12# flaky coverage that is not a function of syscall inputs. For example,
13# rbtree can be global and individual rotations don't correlate with inputs.
14KCOV_INSTRUMENT_string.o := n
15KCOV_INSTRUMENT_rbtree.o := n
16KCOV_INSTRUMENT_list_debug.o := n
17KCOV_INSTRUMENT_debugobjects.o := n
18KCOV_INSTRUMENT_dynamic_debug.o := n
19
20# Early boot use of cmdline, don't instrument it
21ifdef CONFIG_AMD_MEM_ENCRYPT
22KASAN_SANITIZE_string.o := n
23
24ifdef CONFIG_FUNCTION_TRACER
25CFLAGS_REMOVE_string.o = -pg
26endif
27
28CFLAGS_string.o := $(call cc-option, -fno-stack-protector)
29endif
30
31lib-y := ctype.o string.o vsprintf.o cmdline.o \
32 rbtree.o radix-tree.o dump_stack.o timerqueue.o\
33 idr.o int_sqrt.o extable.o \
34 sha1.o chacha20.o irq_regs.o argv_split.o \
35 flex_proportions.o ratelimit.o show_mem.o \
36 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
37 earlycpio.o seq_buf.o siphash.o \
38 nmi_backtrace.o nodemask.o win_minmax.o
39
40lib-$(CONFIG_MMU) += ioremap.o
41lib-$(CONFIG_SMP) += cpumask.o
42lib-$(CONFIG_DMA_NOOP_OPS) += dma-noop.o
43lib-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o
44
45lib-y += kobject.o klist.o
46obj-y += lockref.o
47
48obj-y += bcd.o div64.o sort.o parser.o debug_locks.o random32.o \
49 bust_spinlocks.o kasprintf.o bitmap.o scatterlist.o \
50 gcd.o lcm.o list_sort.o uuid.o flex_array.o iov_iter.o clz_ctz.o \
51 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
52 percpu-refcount.o percpu_ida.o rhashtable.o reciprocal_div.o \
53 once.o refcount.o usercopy.o errseq.o
54obj-y += string_helpers.o
55obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
56obj-y += hexdump.o
57obj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o
58obj-y += kstrtox.o
59obj-$(CONFIG_TEST_BPF) += test_bpf.o
60obj-$(CONFIG_TEST_FIRMWARE) += test_firmware.o
61obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o
62obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o
63obj-$(CONFIG_TEST_KASAN) += test_kasan.o
64CFLAGS_test_kasan.o += -fno-builtin
65obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
66obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o
67obj-$(CONFIG_TEST_LKM) += test_module.o
68obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o
69obj-$(CONFIG_TEST_SORT) += test_sort.o
70obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
71obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
72obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
73obj-$(CONFIG_TEST_PRINTF) += test_printf.o
74obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
75obj-$(CONFIG_TEST_UUID) += test_uuid.o
76obj-$(CONFIG_TEST_PARMAN) += test_parman.o
77obj-$(CONFIG_TEST_KMOD) += test_kmod.o
78obj-$(CONFIG_TEST_DEBUG_VIRTUAL) += test_debug_virtual.o
79
80ifeq ($(CONFIG_DEBUG_KOBJECT),y)
81CFLAGS_kobject.o += -DDEBUG
82CFLAGS_kobject_uevent.o += -DDEBUG
83endif
84
85obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
86CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
87
88obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
89obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
90obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
91obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
92obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
93
94obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
95
96obj-$(CONFIG_BTREE) += btree.o
97obj-$(CONFIG_INTERVAL_TREE) += interval_tree.o
98obj-$(CONFIG_ASSOCIATIVE_ARRAY) += assoc_array.o
99obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
100obj-$(CONFIG_DEBUG_LIST) += list_debug.o
101obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
102
103ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
104 lib-y += dec_and_lock.o
105endif
106
107obj-$(CONFIG_BITREVERSE) += bitrev.o
108obj-$(CONFIG_RATIONAL) += rational.o
109obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
110obj-$(CONFIG_CRC16) += crc16.o
111obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
112obj-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
113obj-$(CONFIG_CRC32) += crc32.o
114obj-$(CONFIG_CRC32_SELFTEST) += crc32test.o
115obj-$(CONFIG_CRC4) += crc4.o
116obj-$(CONFIG_CRC7) += crc7.o
117obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
118obj-$(CONFIG_CRC8) += crc8.o
119obj-$(CONFIG_XXHASH) += xxhash.o
120obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
121
122obj-$(CONFIG_842_COMPRESS) += 842/
123obj-$(CONFIG_842_DECOMPRESS) += 842/
124obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
125obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
126obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
127obj-$(CONFIG_BCH) += bch.o
128obj-$(CONFIG_LZO_COMPRESS) += lzo/
129obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
130obj-$(CONFIG_LZ4_COMPRESS) += lz4/
131obj-$(CONFIG_LZ4HC_COMPRESS) += lz4/
132obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/
133obj-$(CONFIG_ZSTD_COMPRESS) += zstd/
134obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd/
135obj-$(CONFIG_XZ_DEC) += xz/
136obj-$(CONFIG_RAID6_PQ) += raid6/
137
138lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
139lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
140lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
141lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
142lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
143lib-$(CONFIG_DECOMPRESS_LZ4) += decompress_unlz4.o
144
145obj-$(CONFIG_TEXTSEARCH) += textsearch.o
146obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
147obj-$(CONFIG_TEXTSEARCH_BM) += ts_bm.o
148obj-$(CONFIG_TEXTSEARCH_FSM) += ts_fsm.o
149obj-$(CONFIG_SMP) += percpu_counter.o
150obj-$(CONFIG_AUDIT_GENERIC) += audit.o
151obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o
152
153obj-$(CONFIG_SWIOTLB) += swiotlb.o
154obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o iommu-common.o
155obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
156obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
157obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o
158obj-$(CONFIG_NETDEV_NOTIFIER_ERROR_INJECT) += netdev-notifier-error-inject.o
159obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o
160obj-$(CONFIG_OF_RECONFIG_NOTIFIER_ERROR_INJECT) += \
161 of-reconfig-notifier-error-inject.o
162
163lib-$(CONFIG_GENERIC_BUG) += bug.o
164
165obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
166
167obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o
168
169obj-$(CONFIG_NLATTR) += nlattr.o
170
171obj-$(CONFIG_LRU_CACHE) += lru_cache.o
172
173obj-$(CONFIG_DMA_API_DEBUG) += dma-debug.o
174
175obj-$(CONFIG_GENERIC_CSUM) += checksum.o
176
177obj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o
178
179obj-$(CONFIG_ATOMIC64_SELFTEST) += atomic64_test.o
180
181obj-$(CONFIG_CPU_RMAP) += cpu_rmap.o
182
183obj-$(CONFIG_CORDIC) += cordic.o
184
185obj-$(CONFIG_DQL) += dynamic_queue_limits.o
186
187obj-$(CONFIG_GLOB) += glob.o
188obj-$(CONFIG_GLOB_SELFTEST) += globtest.o
189
190obj-$(CONFIG_MPILIB) += mpi/
191obj-$(CONFIG_SIGNATURE) += digsig.o
192
193lib-$(CONFIG_CLZ_TAB) += clz_tab.o
194
195obj-$(CONFIG_DDR) += jedec_ddr_data.o
196
197obj-$(CONFIG_GENERIC_STRNCPY_FROM_USER) += strncpy_from_user.o
198obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
199
200obj-$(CONFIG_GENERIC_NET_UTILS) += net_utils.o
201
202obj-$(CONFIG_SG_SPLIT) += sg_split.o
203obj-$(CONFIG_SG_POOL) += sg_pool.o
204obj-$(CONFIG_STMP_DEVICE) += stmp_device.o
205obj-$(CONFIG_IRQ_POLL) += irq_poll.o
206
207obj-$(CONFIG_STACKDEPOT) += stackdepot.o
208KASAN_SANITIZE_stackdepot.o := n
209KCOV_INSTRUMENT_stackdepot.o := n
210
211libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
212 fdt_empty_tree.o
213$(foreach file, $(libfdt_files), \
214 $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
215lib-$(CONFIG_LIBFDT) += $(libfdt_files)
216
217obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o
218obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
219
220obj-$(CONFIG_PERCPU_TEST) += percpu_test.o
221
222obj-$(CONFIG_ASN1) += asn1_decoder.o
223
224obj-$(CONFIG_FONT_SUPPORT) += fonts/
225
226obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o
227
228hostprogs-y := gen_crc32table
229clean-files := crc32table.h
230
231$(obj)/crc32.o: $(obj)/crc32table.h
232
233quiet_cmd_crc32 = GEN $@
234 cmd_crc32 = $< > $@
235
236$(obj)/crc32table.h: $(obj)/gen_crc32table
237 $(call cmd,crc32)
238
239#
240# Build a fast OID lookip registry from include/linux/oid_registry.h
241#
242obj-$(CONFIG_OID_REGISTRY) += oid_registry.o
243
244$(obj)/oid_registry.o: $(obj)/oid_registry_data.c
245
246$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
247 $(src)/build_OID_registry
248 $(call cmd,build_OID_registry)
249
250quiet_cmd_build_OID_registry = GEN $@
251 cmd_build_OID_registry = perl $(srctree)/$(src)/build_OID_registry $< $@
252
253clean-files += oid_registry_data.c
254
255obj-$(CONFIG_UCS2_STRING) += ucs2_string.o
256obj-$(CONFIG_UBSAN) += ubsan.o
257
258UBSAN_SANITIZE_ubsan.o := n
259KASAN_SANITIZE_ubsan.o := n
260CFLAGS_ubsan.o := $(call cc-option, -fno-stack-protector) $(DISABLE_STACKLEAK_PLUGIN)
261
262obj-$(CONFIG_SBITMAP) += sbitmap.o
263
264obj-$(CONFIG_PARMAN) += parman.o