18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci# ===========================================================================
38c2ecf20Sopenharmony_ci# Post-link LoongArch pass
48c2ecf20Sopenharmony_ci# ===========================================================================
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci# 1. Insert relocations into vmlinux
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciPHONY := __archpost
98c2ecf20Sopenharmony_ci__archpost:
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci-include include/config/auto.conf
128c2ecf20Sopenharmony_ciinclude scripts/Kbuild.include
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciCMD_RELOCS = arch/loongarch/boot/tools/relocs --keep
158c2ecf20Sopenharmony_ciquiet_cmd_relocs = RELOCS  $@
168c2ecf20Sopenharmony_ci      cmd_relocs = $(CMD_RELOCS) $@
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciquiet_cmd_strip_relocs = RSTRIP  $@
198c2ecf20Sopenharmony_ci      cmd_strip_relocs = \
208c2ecf20Sopenharmony_ci	$(OBJCOPY) --remove-section='.rel.*' --remove-section='.rel__*' \
218c2ecf20Sopenharmony_ci		   --remove-section='.rela.*' --remove-section='.rela__*' $@
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci# `@true` prevents complaint when there is nothing to be done
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_civmlinux: FORCE
268c2ecf20Sopenharmony_ci	@true
278c2ecf20Sopenharmony_ciifeq ($(CONFIG_RELOCATABLE),y)
288c2ecf20Sopenharmony_ci	$(call cmd,relocs)
298c2ecf20Sopenharmony_ci	$(call cmd,strip_relocs)
308c2ecf20Sopenharmony_ciendif
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci%.ko: FORCE
338c2ecf20Sopenharmony_ci	@true
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciclean:
368c2ecf20Sopenharmony_ci	@true
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciPHONY += FORCE clean
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciFORCE:
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci.PHONY: $(PHONY)
43