xref: /linux/arch/xtensa/kernel/Makefile (revision 8630c59e99363c4b655788fd01134aef9bcd9264)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
25a0015d6SChris Zankel#
35a0015d6SChris Zankel# Makefile for the Linux/Xtensa kernel.
45a0015d6SChris Zankel#
55a0015d6SChris Zankel
6*e21efe83SMasahiro Yamadaalways-$(KBUILD_BUILTIN) := vmlinux.lds
75a0015d6SChris Zankel
832164845SMasahiro Yamadaobj-y := head.o 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
120f665b9eSChristoph 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
1689b184f9SMax Filippovobj-$(CONFIG_SMP) += smp.o
1789b184f9SMax Filippovobj-$(CONFIG_SECONDARY_RESET_VECTOR) += mxhead.o
189bd46da4SMax Filippovobj-$(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) += perf_event.o
19c91e02bdSMax Filippovobj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
203863c58cSMax Filippovobj-$(CONFIG_S32C1I_SELFTEST) += s32c1i_selftest.o
2164711f9aSMax Filippovobj-$(CONFIG_JUMP_LABEL) += jump_label.o
22733f5c28SMax Filippovobj-$(CONFIG_HIBERNATION) += hibernate.o
235a0015d6SChris Zankel
2478f3cdfaSChris Zankel# In the Xtensa architecture, assembly generates literals which must always
2578f3cdfaSChris Zankel# precede the L32R instruction with a relative offset less than 256 kB.
2678f3cdfaSChris Zankel# Therefore, the .text and .literal section must be combined in parenthesis
2778f3cdfaSChris Zankel# in the linker script, such as: *(.literal .text).
2878f3cdfaSChris Zankel#
2978f3cdfaSChris Zankel# We need to post-process the generated vmlinux.lds scripts to convert
3078f3cdfaSChris Zankel# *(xxx.text) to  *(xxx.literal xxx.text) for the following text sections:
3178f3cdfaSChris Zankel#   .text .ref.text .*init.text .*exit.text .text.*
3278f3cdfaSChris Zankel#
3378f3cdfaSChris Zankel# Replicate rules in scripts/Makefile.build
345a0015d6SChris Zankel
35895fb315SMax Filippovsed-y = -e ':a; s/\*(\([^)]*\)\.text\.unlikely/*(\1.literal.unlikely .{text}.unlikely/; ta; ' \
36895fb315SMax Filippov	-e ':b; s/\*(\([^)]*\)\.text\(\.[a-z]*\)/*(\1.{text}\2.literal .{text}\2/; tb; ' \
37895fb315SMax Filippov	-e ':c; s/\*(\([^)]*\)\(\.[a-z]*it\|\.ref\)\.text/*(\1\2.literal \2.{text}/; tc; ' \
38895fb315SMax Filippov	-e ':d; s/\*(\([^)]\+ \|\)\.text/*(\1.literal .{text}/; td; ' \
39895fb315SMax Filippov	-e 's/\.{text}/.text/g'
4078f3cdfaSChris Zankel
4178f3cdfaSChris Zankelquiet_cmd__cpp_lds_S = LDS     $@
4235e76b99SNadav Amitcmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ \
4335e76b99SNadav Amit		 -DLINKER_SCRIPT $< | sed $(sed-y) >$@
4478f3cdfaSChris Zankel
4578f3cdfaSChris Zankel$(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE
4678f3cdfaSChris Zankel	$(call if_changed_dep,_cpp_lds_S)
47