Skip to content

Commit 0ce5139

Browse files
masahir0ynathanchance
authored andcommitted
kbuild: always create intermediate vmlinux.unstripped
Generate the intermediate vmlinux.unstripped regardless of CONFIG_ARCH_VMLINUX_NEEDS_RELOCS. If CONFIG_ARCH_VMLINUX_NEEDS_RELOCS is unset, vmlinux.unstripped and vmlinux are identiacal. This simplifies the build rule, and allows to strip more sections by adding them to remove-section-y. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/a48ca543fa2305bd17324f41606dcaed9b19f2d4.1758182101.git.legion@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 8d18ef0 commit 0ce5139

1 file changed

Lines changed: 22 additions & 23 deletions

File tree

scripts/Makefile.vmlinux

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib
99

1010
targets :=
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

6248
ifdef CONFIG_GENERIC_BUILTIN_DTB
6349
targets += .builtin-dtbs.S .builtin-dtbs.o
64-
$(vmlinux-final): .builtin-dtbs.o
50+
vmlinux.unstripped: .builtin-dtbs.o
6551
endif
6652

67-
# vmlinux
53+
# vmlinux.unstripped
6854
# ---------------------------------------------------------------------------
6955

7056
ifdef CONFIG_MODULES
7157
targets += .vmlinux.export.o
72-
$(vmlinux-final): .vmlinux.export.o
58+
vmlinux.unstripped: .vmlinux.export.o
7359
endif
7460

7561
ifdef 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

7864
arch/$(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)
9278
ifdef CONFIG_DEBUG_INFO_BTF
93-
$(vmlinux-final): $(RESOLVE_BTFIDS)
79+
vmlinux.unstripped: $(RESOLVE_BTFIDS)
9480
endif
9581

9682
ifdef CONFIG_BUILDTIME_TABLE_SORT
97-
$(vmlinux-final): scripts/sorttable
83+
vmlinux.unstripped: scripts/sorttable
9884
endif
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
# ---------------------------------------------------------------------------
102101
ifdef 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

116115
endif

0 commit comments

Comments
 (0)