xref: /linux/arch/xtensa/kernel/Makefile (revision 0f665b9e2a6d4cc963e6cd349d40320ed5281f95)
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
8*0f665b9eSChristoph Hellwigobj-y := align.o coprocessor.o entry.o irq.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
12*0f665b9eSChristoph Hellwigobj-$(CONFIG_MMU) += pci-dma.o
135a0015d6SChris Zankelobj-$(CONFIG_PCI) += pci.o
145a0015d6SChris Zankelobj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o
15478ba61aSMax Filippovobj-$(CONFIG_FUNCTION_TRACER) += mcount.o
16f615136cSMax Filippovobj-$(CONFIG_SMP) += smp.o mxhead.o
179bd46da4SMax Filippovobj-$(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) += perf_event.o
18c91e02bdSMax Filippovobj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
193863c58cSMax Filippovobj-$(CONFIG_S32C1I_SELFTEST) += s32c1i_selftest.o
2064711f9aSMax Filippovobj-$(CONFIG_JUMP_LABEL) += jump_label.o
215a0015d6SChris Zankel
2278f3cdfaSChris Zankel# In the Xtensa architecture, assembly generates literals which must always
2378f3cdfaSChris Zankel# precede the L32R instruction with a relative offset less than 256 kB.
2478f3cdfaSChris Zankel# Therefore, the .text and .literal section must be combined in parenthesis
2578f3cdfaSChris Zankel# in the linker script, such as: *(.literal .text).
2678f3cdfaSChris Zankel#
2778f3cdfaSChris Zankel# We need to post-process the generated vmlinux.lds scripts to convert
2878f3cdfaSChris Zankel# *(xxx.text) to  *(xxx.literal xxx.text) for the following text sections:
2978f3cdfaSChris Zankel#   .text .ref.text .*init.text .*exit.text .text.*
3078f3cdfaSChris Zankel#
3178f3cdfaSChris Zankel# Replicate rules in scripts/Makefile.build
325a0015d6SChris Zankel
33895fb315SMax Filippovsed-y = -e ':a; s/\*(\([^)]*\)\.text\.unlikely/*(\1.literal.unlikely .{text}.unlikely/; ta; ' \
34895fb315SMax Filippov	-e ':b; s/\*(\([^)]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal .{text}\2/; tb; ' \
35895fb315SMax Filippov	-e ':c; s/\*(\([^)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal \2.{text}/; tc; ' \
36895fb315SMax Filippov	-e ':d; s/\*(\([^)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
37895fb315SMax Filippov	-e 's/\.{text}/.text/g'
3878f3cdfaSChris Zankel
3978f3cdfaSChris Zankelquiet_cmd__cpp_lds_S = LDS     $@
4035e76b99SNadav Amitcmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ \
4135e76b99SNadav Amit		 -DLINKER_SCRIPT $< | sed $(sed-y) >$@
4278f3cdfaSChris Zankel
4378f3cdfaSChris Zankel$(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE
4478f3cdfaSChris Zankel	$(call if_changed_dep,_cpp_lds_S)
45