File tree 10 files changed +17
-12
lines changed
10 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -1120,6 +1120,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
1120
1120
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL )
1121
1121
endif
1122
1122
1123
+ ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS ) ,)
1124
+ LDFLAGS_vmlinux += --emit-relocs --discard-none
1125
+ endif
1126
+
1123
1127
# Align the bit size of userspace programs with the kernel
1124
1128
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=% , $(KBUILD_CPPFLAGS ) $(KBUILD_CFLAGS ) )
1125
1129
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=% , $(KBUILD_CPPFLAGS ) $(KBUILD_CFLAGS ) )
Original file line number Diff line number Diff line change @@ -1695,6 +1695,13 @@ config ARCH_HAS_KERNEL_FPU_SUPPORT
1695
1695
Architectures that select this option can run floating-point code in
1696
1696
the kernel, as described in Documentation/core-api/floating-point.rst.
1697
1697
1698
+ config ARCH_VMLINUX_NEEDS_RELOCS
1699
+ bool
1700
+ help
1701
+ Whether the architecture needs vmlinux to be built with static
1702
+ relocations preserved. This is used by some architectures to
1703
+ construct bespoke relocation tables for KASLR.
1704
+
1698
1705
source "kernel/gcov/Kconfig"
1699
1706
1700
1707
source "scripts/gcc-plugins/Kconfig"
Original file line number Diff line number Diff line change @@ -2617,6 +2617,7 @@ config RELOCATABLE
2617
2617
CPU_MIPS32_R6 || CPU_MIPS64_R6 || \
2618
2618
CPU_P5600 || CAVIUM_OCTEON_SOC || \
2619
2619
CPU_LOONGSON64
2620
+ select ARCH_VMLINUX_NEEDS_RELOCS
2620
2621
help
2621
2622
This builds a kernel image that retains relocation information
2622
2623
so it can be loaded someplace besides the default 1MB.
Original file line number Diff line number Diff line change @@ -100,10 +100,6 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
100
100
KBUILD_AFLAGS_MODULE += -mlong-calls
101
101
KBUILD_CFLAGS_MODULE += -mlong-calls
102
102
103
- ifeq ($(CONFIG_RELOCATABLE ) ,y)
104
- LDFLAGS_vmlinux += --emit-relocs
105
- endif
106
-
107
103
cflags-y += -ffreestanding
108
104
109
105
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
Original file line number Diff line number Diff line change @@ -1077,6 +1077,7 @@ config RELOCATABLE
1077
1077
bool "Build a relocatable kernel"
1078
1078
depends on MMU && 64BIT && !XIP_KERNEL
1079
1079
select MODULE_SECTIONS if MODULES
1080
+ select ARCH_VMLINUX_NEEDS_RELOCS
1080
1081
help
1081
1082
This builds a kernel as a Position Independent Executable (PIE),
1082
1083
which retains all relocation metadata required to relocate the
Original file line number Diff line number Diff line change 8
8
9
9
LDFLAGS_vmlinux := -z norelro
10
10
ifeq ($(CONFIG_RELOCATABLE ) ,y)
11
- LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
11
+ LDFLAGS_vmlinux += -shared -Bsymbolic -z notext
12
12
KBUILD_CFLAGS += -fPIE
13
13
endif
14
14
ifeq ($(CONFIG_DYNAMIC_FTRACE ) ,y)
Original file line number Diff line number Diff line change @@ -630,6 +630,7 @@ endchoice
630
630
631
631
config RELOCATABLE
632
632
def_bool y
633
+ select ARCH_VMLINUX_NEEDS_RELOCS
633
634
help
634
635
This builds a kernel image that retains relocation information
635
636
so it can be loaded at an arbitrary address.
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ KBUILD_CFLAGS_MODULE += -fPIC
15
15
KBUILD_AFLAGS += -m64
16
16
KBUILD_CFLAGS += -m64
17
17
KBUILD_CFLAGS += -fPIC
18
- LDFLAGS_vmlinux := -no-pie --emit-relocs --discard-none
18
+ LDFLAGS_vmlinux := -no-pie
19
19
extra_tools := relocs
20
20
aflags_dwarf := -Wa,-gdwarf-2
21
21
KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS ) -m64 -D__ASSEMBLY__
Original file line number Diff line number Diff line change @@ -2200,6 +2200,7 @@ config RANDOMIZE_BASE
2200
2200
config X86_NEED_RELOCS
2201
2201
def_bool y
2202
2202
depends on RANDOMIZE_BASE || (X86_32 && RELOCATABLE)
2203
+ select ARCH_VMLINUX_NEEDS_RELOCS
2203
2204
2204
2205
config PHYSICAL_ALIGN
2205
2206
hex "Alignment value to which kernel should be aligned"
Original file line number Diff line number Diff line change @@ -251,12 +251,6 @@ endif
251
251
252
252
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE )
253
253
254
- ifdef CONFIG_X86_NEED_RELOCS
255
- LDFLAGS_vmlinux := --emit-relocs --discard-none
256
- else
257
- LDFLAGS_vmlinux :=
258
- endif
259
-
260
254
#
261
255
# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
262
256
# the linker to force 2MB page size regardless of the default page size used
You can’t perform that action at this time.
0 commit comments