1*9d9173e9SPetr Pavlu# SPDX-License-Identifier: GPL-2.0 2*9d9173e9SPetr Pavlu# =========================================================================== 3*9d9173e9SPetr Pavlu# Post-link x86 pass 4*9d9173e9SPetr Pavlu# =========================================================================== 5*9d9173e9SPetr Pavlu# 6*9d9173e9SPetr Pavlu# 1. Separate relocations from vmlinux into vmlinux.relocs. 7*9d9173e9SPetr Pavlu# 2. Strip relocations from vmlinux. 8*9d9173e9SPetr Pavlu 9*9d9173e9SPetr PavluPHONY := __archpost 10*9d9173e9SPetr Pavlu__archpost: 11*9d9173e9SPetr Pavlu 12*9d9173e9SPetr Pavlu-include include/config/auto.conf 13*9d9173e9SPetr Pavluinclude $(srctree)/scripts/Kbuild.include 14*9d9173e9SPetr Pavlu 15*9d9173e9SPetr PavluCMD_RELOCS = arch/x86/tools/relocs 16*9d9173e9SPetr PavluOUT_RELOCS = arch/x86/boot/compressed 17*9d9173e9SPetr Pavluquiet_cmd_relocs = RELOCS $(OUT_RELOCS)/$@.relocs 18*9d9173e9SPetr Pavlu cmd_relocs = \ 19*9d9173e9SPetr Pavlu mkdir -p $(OUT_RELOCS); \ 20*9d9173e9SPetr Pavlu $(CMD_RELOCS) $@ > $(OUT_RELOCS)/$@.relocs; \ 21*9d9173e9SPetr Pavlu $(CMD_RELOCS) --abs-relocs $@ 22*9d9173e9SPetr Pavlu 23*9d9173e9SPetr Pavluquiet_cmd_strip_relocs = RSTRIP $@ 24*9d9173e9SPetr Pavlu cmd_strip_relocs = \ 25*9d9173e9SPetr Pavlu $(OBJCOPY) --remove-section='.rel.*' --remove-section='.rel__*' \ 26*9d9173e9SPetr Pavlu --remove-section='.rela.*' --remove-section='.rela__*' $@ 27*9d9173e9SPetr Pavlu 28*9d9173e9SPetr Pavlu# `@true` prevents complaint when there is nothing to be done 29*9d9173e9SPetr Pavlu 30*9d9173e9SPetr Pavluvmlinux: FORCE 31*9d9173e9SPetr Pavlu @true 32*9d9173e9SPetr Pavluifeq ($(CONFIG_X86_NEED_RELOCS),y) 33*9d9173e9SPetr Pavlu $(call cmd,relocs) 34*9d9173e9SPetr Pavlu $(call cmd,strip_relocs) 35*9d9173e9SPetr Pavluendif 36*9d9173e9SPetr Pavlu 37*9d9173e9SPetr Pavlu%.ko: FORCE 38*9d9173e9SPetr Pavlu @true 39*9d9173e9SPetr Pavlu 40*9d9173e9SPetr Pavluclean: 41*9d9173e9SPetr Pavlu @rm -f $(OUT_RELOCS)/vmlinux.relocs 42*9d9173e9SPetr Pavlu 43*9d9173e9SPetr PavluPHONY += FORCE clean 44*9d9173e9SPetr Pavlu 45*9d9173e9SPetr PavluFORCE: 46*9d9173e9SPetr Pavlu 47*9d9173e9SPetr Pavlu.PHONY: $(PHONY) 48