xref: /linux-6.15/arch/xtensa/kernel/Makefile (revision f615136c)
15a0015d6SChris Zankel#
25a0015d6SChris Zankel# Makefile for the Linux/Xtensa kernel.
35a0015d6SChris Zankel#
45a0015d6SChris Zankel
55a0015d6SChris Zankelextra-y := head.o vmlinux.lds
65a0015d6SChris Zankel
73e4196a5SMax Filippovobj-y := align.o coprocessor.o entry.o irq.o pci-dma.o platform.o process.o \
83e4196a5SMax Filippov	 ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \
93e4196a5SMax Filippov	 vectors.o
105a0015d6SChris Zankel
115a0015d6SChris Zankelobj-$(CONFIG_KGDB) += xtensa-stub.o
125a0015d6SChris Zankelobj-$(CONFIG_PCI) += pci.o
135a0015d6SChris Zankelobj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o
14478ba61aSMax Filippovobj-$(CONFIG_FUNCTION_TRACER) += mcount.o
15*f615136cSMax Filippovobj-$(CONFIG_SMP) += smp.o mxhead.o
165a0015d6SChris Zankel
17e85e335fSMax FilippovAFLAGS_head.o += -mtext-section-literals
18e85e335fSMax Filippov
1978f3cdfaSChris Zankel# In the Xtensa architecture, assembly generates literals which must always
2078f3cdfaSChris Zankel# precede the L32R instruction with a relative offset less than 256 kB.
2178f3cdfaSChris Zankel# Therefore, the .text and .literal section must be combined in parenthesis
2278f3cdfaSChris Zankel# in the linker script, such as: *(.literal .text).
2378f3cdfaSChris Zankel#
2478f3cdfaSChris Zankel# We need to post-process the generated vmlinux.lds scripts to convert
2578f3cdfaSChris Zankel# *(xxx.text) to  *(xxx.literal xxx.text) for the following text sections:
2678f3cdfaSChris Zankel#   .text .ref.text .*init.text .*exit.text .text.*
2778f3cdfaSChris Zankel#
2878f3cdfaSChris Zankel# Replicate rules in scripts/Makefile.build
295a0015d6SChris Zankel
30ed5010eaSChris Zankelsed-y = -e 's/\*(\(\.[a-z]*it\|\.ref\|\)\.text)/*(\1.literal \1.text)/g' \
31f6a03a12SMax Filippov	-e 's/\.text\.unlikely/.literal.unlikely .text.unlikely/g'	 \
32ed5010eaSChris Zankel	-e 's/\*(\(\.text\.[a-z]*\))/*(\1.literal \1)/g'
3378f3cdfaSChris Zankel
3478f3cdfaSChris Zankelquiet_cmd__cpp_lds_S = LDS     $@
3551b563fcSSam Ravnborgcmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ $<    \
3651b563fcSSam Ravnborg                 | sed $(sed-y) >$@
3778f3cdfaSChris Zankel
3878f3cdfaSChris Zankel$(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE
3978f3cdfaSChris Zankel	$(call if_changed_dep,_cpp_lds_S)
40