@@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib
99
1010targets :=
1111
12- ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS
13- vmlinux-final := vmlinux.unstripped
14-
15- quiet_cmd_strip_relocs = RSTRIP $@
16- cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' --remove-section=!'.rel*.dyn' $< $@
17-
18- vmlinux: $(vmlinux-final) FORCE
19- $(call if_changed,strip_relocs)
20-
21- targets += vmlinux
22- else
23- vmlinux-final := vmlinux
24- endif
25-
2612%.o: %.c FORCE
2713 $(call if_changed_rule,cc_o_c)
2814
@@ -61,19 +47,19 @@ targets += .builtin-dtbs-list
6147
6248ifdef CONFIG_GENERIC_BUILTIN_DTB
6349targets += .builtin-dtbs.S .builtin-dtbs.o
64- $( vmlinux-final) : .builtin-dtbs.o
50+ vmlinux.unstripped : .builtin-dtbs.o
6551endif
6652
67- # vmlinux
53+ # vmlinux.unstripped
6854# ---------------------------------------------------------------------------
6955
7056ifdef CONFIG_MODULES
7157targets += .vmlinux.export.o
72- $( vmlinux-final) : .vmlinux.export.o
58+ vmlinux.unstripped : .vmlinux.export.o
7359endif
7460
7561ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX
76- $( vmlinux-final) : arch/$(SRCARCH)/tools/vmlinux.arch.o
62+ vmlinux.unstripped : arch/$(SRCARCH)/tools/vmlinux.arch.o
7763
7864arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE
7965 $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@
@@ -86,17 +72,30 @@ cmd_link_vmlinux = \
8672 $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
8773 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
8874
89- targets += $( vmlinux-final)
90- $( vmlinux-final) : scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
75+ targets += vmlinux.unstripped
76+ vmlinux.unstripped : scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
9177 +$(call if_changed_dep,link_vmlinux)
9278ifdef CONFIG_DEBUG_INFO_BTF
93- $( vmlinux-final) : $(RESOLVE_BTFIDS)
79+ vmlinux.unstripped : $(RESOLVE_BTFIDS)
9480endif
9581
9682ifdef CONFIG_BUILDTIME_TABLE_SORT
97- $( vmlinux-final) : scripts/sorttable
83+ vmlinux.unstripped : scripts/sorttable
9884endif
9985
86+ # vmlinux
87+ # ---------------------------------------------------------------------------
88+
89+ remove-section-y :=
90+ remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*'
91+
92+ quiet_cmd_strip_relocs = OBJCOPY $@
93+ cmd_strip_relocs = $(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $< $@
94+
95+ targets += vmlinux
96+ vmlinux: vmlinux.unstripped FORCE
97+ $(call if_changed,strip_relocs)
98+
10099# modules.builtin.ranges
101100# ---------------------------------------------------------------------------
102101ifdef CONFIG_BUILTIN_MODULE_RANGES
@@ -110,7 +109,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \
110109 modules.builtin vmlinux.map vmlinux.o.map FORCE
111110 $(call if_changed,modules_builtin_ranges)
112111
113- vmlinux.map: $( vmlinux-final)
112+ vmlinux.map: vmlinux.unstripped
114113 @:
115114
116115endif
0 commit comments