|
@@ -26,7 +26,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
|
|
vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
|
|
vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
|
|
|
|
|
|
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
|
|
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
|
|
-KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
|
|
|
|
|
|
+KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
|
|
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
|
|
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
|
|
cflags-$(CONFIG_X86_32) := -march=i386
|
|
cflags-$(CONFIG_X86_32) := -march=i386
|
|
cflags-$(CONFIG_X86_64) := -mcmodel=small
|
|
cflags-$(CONFIG_X86_64) := -mcmodel=small
|
|
@@ -40,6 +40,18 @@ GCOV_PROFILE := n
|
|
UBSAN_SANITIZE :=n
|
|
UBSAN_SANITIZE :=n
|
|
|
|
|
|
LDFLAGS := -m elf_$(UTS_MACHINE)
|
|
LDFLAGS := -m elf_$(UTS_MACHINE)
|
|
|
|
+ifeq ($(CONFIG_RELOCATABLE),y)
|
|
|
|
+# If kernel is relocatable, build compressed kernel as PIE.
|
|
|
|
+ifeq ($(CONFIG_X86_32),y)
|
|
|
|
+LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
|
|
|
|
+else
|
|
|
|
+# To build 64-bit compressed kernel as PIE, we disable relocation
|
|
|
|
+# overflow check to avoid relocation overflow error with a new linker
|
|
|
|
+# command-line option, -z noreloc-overflow.
|
|
|
|
+LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
|
|
|
|
+ && echo "-z noreloc-overflow -pie --no-dynamic-linker")
|
|
|
|
+endif
|
|
|
|
+endif
|
|
LDFLAGS_vmlinux := -T
|
|
LDFLAGS_vmlinux := -T
|
|
|
|
|
|
hostprogs-y := mkpiggy
|
|
hostprogs-y := mkpiggy
|