xref: /linux-6.15/arch/xtensa/kernel/Makefile (revision e85e335f)
15a0015d6SChris Zankel#
25a0015d6SChris Zankel# Makefile for the Linux/Xtensa kernel.
35a0015d6SChris Zankel#
45a0015d6SChris Zankel
55a0015d6SChris Zankelextra-y := head.o vmlinux.lds
65a0015d6SChris Zankel
764ac24e7SMatthew Wilcoxobj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o \
81c0350bdSChris Zankel	 setup.o signal.o syscall.o time.o traps.o vectors.o platform.o  \
9d38efc1fSMax Filippov	 pci-dma.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
145a0015d6SChris Zankel
15*e85e335fSMax FilippovAFLAGS_head.o += -mtext-section-literals
16*e85e335fSMax Filippov
1778f3cdfaSChris Zankel# In the Xtensa architecture, assembly generates literals which must always
1878f3cdfaSChris Zankel# precede the L32R instruction with a relative offset less than 256 kB.
1978f3cdfaSChris Zankel# Therefore, the .text and .literal section must be combined in parenthesis
2078f3cdfaSChris Zankel# in the linker script, such as: *(.literal .text).
2178f3cdfaSChris Zankel#
2278f3cdfaSChris Zankel# We need to post-process the generated vmlinux.lds scripts to convert
2378f3cdfaSChris Zankel# *(xxx.text) to  *(xxx.literal xxx.text) for the following text sections:
2478f3cdfaSChris Zankel#   .text .ref.text .*init.text .*exit.text .text.*
2578f3cdfaSChris Zankel#
2678f3cdfaSChris Zankel# Replicate rules in scripts/Makefile.build
275a0015d6SChris Zankel
28ed5010eaSChris Zankelsed-y = -e 's/\*(\(\.[a-z]*it\|\.ref\|\)\.text)/*(\1.literal \1.text)/g' \
29f6a03a12SMax Filippov	-e 's/\.text\.unlikely/.literal.unlikely .text.unlikely/g'	 \
30ed5010eaSChris Zankel	-e 's/\*(\(\.text\.[a-z]*\))/*(\1.literal \1)/g'
3178f3cdfaSChris Zankel
3278f3cdfaSChris Zankelquiet_cmd__cpp_lds_S = LDS     $@
3351b563fcSSam Ravnborgcmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ $<    \
3451b563fcSSam Ravnborg                 | sed $(sed-y) >$@
3578f3cdfaSChris Zankel
3678f3cdfaSChris Zankel$(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE
3778f3cdfaSChris Zankel	$(call if_changed_dep,_cpp_lds_S)
38