summaryrefslogtreecommitdiffstats
path: root/arch/loongarch/Makefile
diff options
context:
space:
mode:
authorYouling Tang <tangyouling@loongson.cn>2023-02-25 15:52:56 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2023-02-25 22:12:16 +0800
commitd8da19fbdedd5852592fbba18a7348e3f09500e6 (patch)
treea6a4a921da97d0b7379e9034532c8267a14b631e /arch/loongarch/Makefile
parent396233c650084cb957eb6d87dd4abd3e56a7d499 (diff)
downloadlinux-stable-d8da19fbdedd5852592fbba18a7348e3f09500e6.tar.gz
linux-stable-d8da19fbdedd5852592fbba18a7348e3f09500e6.tar.bz2
linux-stable-d8da19fbdedd5852592fbba18a7348e3f09500e6.zip
LoongArch: Add support for kernel relocation
This config allows to compile kernel as PIE and to relocate it at any virtual address at runtime: this paves the way to KASLR. Runtime relocation is possible since relocation metadata are embedded into the kernel. Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Xi Ruoyao <xry111@xry111.site> # Use arch_initcall Signed-off-by: Jinyang He <hejinyang@loongson.cn> # Provide la_abs relocation code Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/Makefile')
-rw-r--r--arch/loongarch/Makefile5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 6e1c931a8507..768592998b39 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -71,6 +71,11 @@ KBUILD_AFLAGS_MODULE += -Wa,-mla-global-with-abs
KBUILD_CFLAGS_MODULE += -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
endif
+ifeq ($(CONFIG_RELOCATABLE),y)
+KBUILD_CFLAGS_KERNEL += -fPIE
+LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext
+endif
+
cflags-y += -ffreestanding
cflags-y += $(call cc-option, -mno-check-zero-division)