@@ -65,7 +65,8 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
6565# Final link of vmlinux with optional arch pass after final link
6666cmd_link_vmlinux = \
6767 $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
68- $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
68+ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true); \
69+ $(if $(CONFIG_HAVE_OBJTOOL_FTR_FIXUP), $(objtool) --ftr-fixup --link $@, true)
6970
7071targets += vmlinux.unstripped .vmlinux.export.o
7172vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o .vmlinux.export.o $(KBUILD_LDS) FORCE
@@ -81,11 +82,15 @@ endif
8182# vmlinux
8283# ---------------------------------------------------------------------------
8384
85+ # These configurations require vmlinux.unstripped to be linked with
86+ # '--emit-relocs', which need to be stripped from the final vmlinux.
87+ uses-emit-relocs := $(or $(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),$(CONFIG_HAVE_OBJTOOL_FTR_FIXUP))
88+
8489remove-section-y := .modinfo
85- remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*' '!.rel*.dyn'
90+ remove-section-$(uses-emit-relocs) += '.rel*' '!.rel*.dyn'
8691# for compatibility with binutils < 2.32
8792# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c12d9fa2afe7abcbe407a00e15719e1a1350c2a7
88- remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel.*'
93+ remove-section-$(uses-emit-relocs) += '.rel.*'
8994
9095remove-symbols := -w --strip-unneeded-symbol='__mod_device_table__*'
9196
0 commit comments