Skip to content

Commit 587af64

Browse files
nivedita76Ingo Molnar
authored andcommitted
x86/build: Move max-page-size option to LDFLAGS_vmlinux
This option is only required for vmlinux on 64-bit, to enforce 2MiB alignment, so set it in LDFLAGS_vmlinux instead of KBUILD_LDFLAGS. Also drop the ld-option check: this option was added in binutils-2.18 and all the other places that use it already don't have the check. This reduces the size of the intermediate ELF files arch/x86/boot/setup.elf and arch/x86/realmode/rm/realmode.elf by about 2MiB each. The binary versions are unchanged. Move the LDFLAGS settings to all be together and just after CFLAGS settings are done. Signed-off-by: Arvind Sankar <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Sedat Dilek <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Michal Marek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6526b12 commit 587af64

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

arch/x86/Makefile

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ export REALMODE_CFLAGS
4747
# e.g.: obj-y += foo_$(BITS).o
4848
export BITS
4949

50-
ifdef CONFIG_X86_NEED_RELOCS
51-
LDFLAGS_vmlinux := --emit-relocs --discard-none
52-
endif
53-
5450
#
5551
# Prevent GCC from generating any FP code by mistake.
5652
#
@@ -177,17 +173,6 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
177173
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
178174
endif
179175

180-
KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
181-
182-
#
183-
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
184-
# the linker to force 2MB page size regardless of the default page size used
185-
# by the linker.
186-
#
187-
ifdef CONFIG_X86_64
188-
KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
189-
endif
190-
191176
# Workaround for a gcc prelease that unfortunately was shipped in a suse release
192177
KBUILD_CFLAGS += -Wno-sign-compare
193178
#
@@ -207,6 +192,23 @@ ifdef CONFIG_RETPOLINE
207192
endif
208193
endif
209194

195+
KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
196+
197+
ifdef CONFIG_X86_NEED_RELOCS
198+
LDFLAGS_vmlinux := --emit-relocs --discard-none
199+
else
200+
LDFLAGS_vmlinux :=
201+
endif
202+
203+
#
204+
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
205+
# the linker to force 2MB page size regardless of the default page size used
206+
# by the linker.
207+
#
208+
ifdef CONFIG_X86_64
209+
LDFLAGS_vmlinux += -z max-page-size=0x200000
210+
endif
211+
210212
archscripts: scripts_basic
211213
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
212214

0 commit comments

Comments
 (0)