xref: /linux-6.15/arch/xtensa/kernel/Makefile (revision 35e76b99)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
25a0015d6SChris Zankel#
35a0015d6SChris Zankel# Makefile for the Linux/Xtensa kernel.
45a0015d6SChris Zankel#
55a0015d6SChris Zankel
65a0015d6SChris Zankelextra-y := head.o vmlinux.lds
75a0015d6SChris Zankel
83e4196a5SMax Filippovobj-y := align.o coprocessor.o entry.o irq.o pci-dma.o platform.o process.o \
93e4196a5SMax Filippov	 ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \
103e4196a5SMax Filippov	 vectors.o
115a0015d6SChris Zankel
125a0015d6SChris Zankelobj-$(CONFIG_PCI) += pci.o
135a0015d6SChris Zankelobj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o
14478ba61aSMax Filippovobj-$(CONFIG_FUNCTION_TRACER) += mcount.o
15f615136cSMax Filippovobj-$(CONFIG_SMP) += smp.o mxhead.o
169bd46da4SMax Filippovobj-$(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) += perf_event.o
17c91e02bdSMax Filippovobj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
183863c58cSMax Filippovobj-$(CONFIG_S32C1I_SELFTEST) += s32c1i_selftest.o
195a0015d6SChris Zankel
2078f3cdfaSChris Zankel# In the Xtensa architecture, assembly generates literals which must always
2178f3cdfaSChris Zankel# precede the L32R instruction with a relative offset less than 256 kB.
2278f3cdfaSChris Zankel# Therefore, the .text and .literal section must be combined in parenthesis
2378f3cdfaSChris Zankel# in the linker script, such as: *(.literal .text).
2478f3cdfaSChris Zankel#
2578f3cdfaSChris Zankel# We need to post-process the generated vmlinux.lds scripts to convert
2678f3cdfaSChris Zankel# *(xxx.text) to  *(xxx.literal xxx.text) for the following text sections:
2778f3cdfaSChris Zankel#   .text .ref.text .*init.text .*exit.text .text.*
2878f3cdfaSChris Zankel#
2978f3cdfaSChris Zankel# Replicate rules in scripts/Makefile.build
305a0015d6SChris Zankel
31895fb315SMax Filippovsed-y = -e ':a; s/\*(\([^)]*\)\.text\.unlikely/*(\1.literal.unlikely .{text}.unlikely/; ta; ' \
32895fb315SMax Filippov	-e ':b; s/\*(\([^)]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal .{text}\2/; tb; ' \
33895fb315SMax Filippov	-e ':c; s/\*(\([^)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal \2.{text}/; tc; ' \
34895fb315SMax Filippov	-e ':d; s/\*(\([^)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
35895fb315SMax Filippov	-e 's/\.{text}/.text/g'
3678f3cdfaSChris Zankel
3778f3cdfaSChris Zankelquiet_cmd__cpp_lds_S = LDS     $@
38*35e76b99SNadav Amitcmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ \
39*35e76b99SNadav Amit		 -DLINKER_SCRIPT $< | sed $(sed-y) >$@
4078f3cdfaSChris Zankel
4178f3cdfaSChris Zankel$(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE
4278f3cdfaSChris Zankel	$(call if_changed_dep,_cpp_lds_S)
43