4 # This file is included by the global makefile so that you can add your own
5 # architecture-specific flags and dependencies.
7 # This file is subject to the terms and conditions of the GNU General Public
8 # License. See the file "COPYING" in the main directory of this archive
11 # Copyright (C) 1995-2001 by Russell King
13 ifeq ($(CONFIG_RELOCATABLE_KERNEL
), y
)
14 LDFLAGS_vmlinux
:=-p
--no-undefined
-X
-pie
-Bsymbolic
16 LDFLAGS_vmlinux
:=-p
--no-undefined
-X
18 CPPFLAGS_vmlinux.lds
= -DTEXT_OFFSET
=$(TEXT_OFFSET
)
19 OBJCOPYFLAGS
:=-O binary
-R .note
-R .note.gnu.build-id
-R .comment
-S
22 ifneq ($(CONFIG_RELOCATABLE
),)
23 LDFLAGS_vmlinux
+= -pie
-Bsymbolic
26 KBUILD_DEFCONFIG
:= defconfig
28 # Check for binutils support for specific extensions
29 lseinstr
:= $(call as-instr
,.arch_extension lse
,-DCONFIG_AS_LSE
=1)
31 ifeq ($(CONFIG_ARM64_LSE_ATOMICS
), y
)
33 $(warning LSE atomics not supported by binutils
)
37 ifeq ($(CONFIG_COMPAT_VDSO
), y
)
38 CROSS_COMPILE_ARM32 ?
= $(CONFIG_CROSS_COMPILE_ARM32
:"%"=%)
40 # Check that the user has provided a valid prefix for the 32-bit toolchain.
41 # To prevent selecting the system $(cc-name) by default, the prefix is not
42 # allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the
43 # system $(cc-name) is actually the 32-bit ARM compiler to be used, the
44 # variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/).
45 # Note: this Makefile is read both before and after regenerating the config
46 # (if needed). Any warning appearing before the config has been regenerated
47 # should be ignored. If the error is triggered and you set
48 # CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value
49 # when invoking make and fix CONFIG_CROSS_COMPILE_ARM32.
50 ifeq ($(CROSS_COMPILE_ARM32
),)
51 $(warning CROSS_COMPILE_ARM32 not defined or empty
, the compat vDSO will not be built
)
52 else ifeq ($(cc-name
),clang
)
53 export CLANG_TRIPLE_ARM32 ?
= $(CROSS_COMPILE_ARM32
)
54 export CLANG_TARGET_ARM32
:= --target
=$(notdir $(CLANG_TRIPLE_ARM32
:%-=%))
55 export CONFIG_VDSO32
:= y
56 vdso32
:= -DCONFIG_VDSO32
=1
57 else ifeq ($(shell which
$(CROSS_COMPILE_ARM32
)$(cc-name
) 2> /dev
/null
),)
58 $(error
$(CROSS_COMPILE_ARM32
)$(cc-name
) not found
, check CROSS_COMPILE_ARM32
)
60 export CROSS_COMPILE_ARM32
61 export CONFIG_VDSO32
:= y
62 vdso32
:= -DCONFIG_VDSO32
=1
66 ifeq ($(cc-name
),clang
)
67 # This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=30792.
68 # TODO: revert when this is fixed in LLVM.
69 KBUILD_CFLAGS
+= -mno-implicit-float
71 KBUILD_CFLAGS
+= -mgeneral-regs-only
73 KBUILD_CFLAGS
+= $(lseinstr
) $(vdso32
)
74 KBUILD_CFLAGS
+= -fno-pic
75 KBUILD_CFLAGS
+= -fno-asynchronous-unwind-tables
76 KBUILD_CFLAGS
+= $(call cc-option
, -mpc-relative-literal-loads
)
77 KBUILD_CFLAGS
+= -fno-pic
78 KBUILD_AFLAGS
+= $(lseinstr
) $(vdso32
)
80 ifeq ($(CONFIG_CPU_BIG_ENDIAN
), y
)
81 KBUILD_CPPFLAGS
+= -mbig-endian
85 KBUILD_CPPFLAGS
+= -mlittle-endian
90 CHECKFLAGS
+= -D__aarch64__
92 ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE
), y
)
93 KBUILD_CFLAGS_MODULE
+= -mcmodel
=large
96 ifeq ($(CONFIG_ARM64_MODULE_PLTS
),y
)
97 KBUILD_LDFLAGS_MODULE
+= -T
$(srctree
)/arch
/arm64
/kernel
/module.lds
101 head-y
:= arch
/arm64
/kernel
/head.o
103 # The byte offset of the kernel image in RAM from the start of RAM.
104 ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET
), y
)
105 TEXT_OFFSET
:= $(shell awk
'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}')
107 TEXT_OFFSET
:= 0x00080000
110 ifeq ($(cc-name
),clang
)
111 KBUILD_CFLAGS
+= $(call cc-disable-warning
, asm-operand-widths
)
114 # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
115 # in 32-bit arithmetic
116 KASAN_SHADOW_OFFSET
:= $(shell printf
"0x%08x00000000\n" $$(( \
117 (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS
) - 32))) \
118 + (1 << ($(CONFIG_ARM64_VA_BITS
) - 32 - 3)) \
119 - (1 << (64 - 32 - 3)) )) )
121 export TEXT_OFFSET GZFLAGS
123 core-y
+= arch
/arm64
/kernel
/ arch
/arm64
/mm
/
124 core-
$(CONFIG_NET
) += arch
/arm64
/net
/
125 core-
$(CONFIG_KVM
) += arch
/arm64
/kvm
/
126 core-
$(CONFIG_XEN
) += arch
/arm64
/xen
/
127 core-
$(CONFIG_CRYPTO
) += arch
/arm64
/crypto
/
128 libs-y
:= arch
/arm64
/lib
/ $(libs-y
)
129 core-
$(CONFIG_EFI_STUB
) += $(objtree
)/drivers
/firmware
/efi
/libstub
/lib.a
131 # Default target when executing plain make
132 ifeq ($(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE
),y
)
133 KBUILD_IMAGE
:= $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_KERNEL_IMAGE_NAME
))
135 KBUILD_IMAGE
:= Image.gz
140 all: $(KBUILD_IMAGE
) $(KBUILD_DTBS
)
142 boot
:= arch
/arm64
/boot
145 $(Q
)$(MAKE
) $(build
)=$(boot
) $(boot
)/$@
148 $(Q
)$(MAKE
) $(build
)=$(boot
) $(boot
)/$@
150 zinstall
install: vmlinux
151 $(Q
)$(MAKE
) $(build
)=$(boot
) $@
154 $(Q
)$(MAKE
) $(build
)=$(boot
)/dts
$(boot
)/dts
/$@
156 PHONY
+= dtbs dtbs_install
158 dtbs
: prepare scripts
159 $(Q
)$(MAKE
) $(build
)=$(boot
)/dts
162 $(Q
)$(MAKE
) $(dtbinst
)=$(boot
)/dts
164 Image-dtb Image.gz-dtb
: vmlinux scripts dtbs
165 $(Q
)$(MAKE
) $(build
)=$(boot
) $(boot
)/$@
167 PHONY
+= vdso_install
169 $(Q
)$(MAKE
) $(build
)=arch
/arm64
/kernel
/vdso
$@
171 # We use MRPROPER_FILES and CLEAN_FILES now
173 $(Q
)$(MAKE
) $(clean)=$(boot
)
174 $(Q
)$(MAKE
) $(clean)=$(boot
)/dts
176 # We need to generate vdso-offsets.h before compiling certain files in kernel/.
177 # In order to do that, we should use the archprepare target, but we can't since
178 # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
179 # asm-offsets.h is built in prepare0, for which archprepare is a dependency.
180 # Therefore we need to generate the header after prepare0 has been made, hence
182 prepare
: vdso_prepare
183 vdso_prepare
: prepare0
184 $(Q
)$(MAKE
) $(build
)=arch
/arm64
/kernel
/vdso
include/generated
/vdso-offsets.h
185 $(if
$(CONFIG_VDSO32
),$(Q
)$(MAKE
) $(build
)=arch
/arm64
/kernel
/vdso32 \
186 include/generated
/vdso32-offsets.h
)
189 echo
'* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
190 echo
' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
191 echo
'* dtbs - Build device tree blobs for enabled boards'
192 echo
' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
193 echo
' install - Install uncompressed kernel'
194 echo
' zinstall - Install compressed kernel'
195 echo
' Install using (your) ~/bin/installkernel or'
196 echo
' (distribution) /sbin/installkernel or'
197 echo
' install to $$(INSTALL_PATH) and run lilo'