Commit | Line | Data |
---|---|---|
8c2c3df3 CM |
1 | # |
2 | # arch/arm64/Makefile | |
3 | # | |
4 | # This file is included by the global makefile so that you can add your own | |
5 | # architecture-specific flags and dependencies. | |
6 | # | |
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 | |
9 | # for more details. | |
10 | # | |
11 | # Copyright (C) 1995-2001 by Russell King | |
12 | ||
1cac41cb MB |
13 | ifeq ($(CONFIG_RELOCATABLE_KERNEL), y) |
14 | LDFLAGS_vmlinux :=-p --no-undefined -X -pie -Bsymbolic | |
15 | else | |
8c2c3df3 | 16 | LDFLAGS_vmlinux :=-p --no-undefined -X |
1cac41cb | 17 | endif |
8c2c3df3 CM |
18 | CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) |
19 | OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S | |
20 | GZFLAGS :=-9 | |
21 | ||
01684359 | 22 | ifneq ($(CONFIG_RELOCATABLE),) |
8f012745 | 23 | LDFLAGS_vmlinux += -pie -Bsymbolic |
01684359 AB |
24 | endif |
25 | ||
8c2c3df3 CM |
26 | KBUILD_DEFCONFIG := defconfig |
27 | ||
c09d6a04 WD |
28 | # Check for binutils support for specific extensions |
29 | lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1) | |
30 | ||
31 | ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y) | |
32 | ifeq ($(lseinstr),) | |
33 | $(warning LSE atomics not supported by binutils) | |
34 | endif | |
35 | endif | |
36 | ||
ca9386d7 KB |
37 | ifeq ($(CONFIG_COMPAT_VDSO), y) |
38 | CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%) | |
39 | ||
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),) | |
d49555fd | 51 | $(error CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built) |
ca9386d7 KB |
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) | |
59 | else | |
60 | export CROSS_COMPILE_ARM32 | |
61 | export CONFIG_VDSO32 := y | |
62 | vdso32 := -DCONFIG_VDSO32=1 | |
63 | endif | |
64 | endif | |
65 | ||
20ea9516 GH |
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 | |
70 | else | |
71 | KBUILD_CFLAGS += -mgeneral-regs-only | |
72 | endif | |
ca9386d7 | 73 | KBUILD_CFLAGS += $(lseinstr) $(vdso32) |
2e039261 | 74 | KBUILD_CFLAGS += -fno-pic |
72034521 | 75 | KBUILD_CFLAGS += -fno-asynchronous-unwind-tables |
db8bb76c | 76 | KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads) |
1cac41cb | 77 | KBUILD_CFLAGS += -fno-pic |
ca9386d7 | 78 | KBUILD_AFLAGS += $(lseinstr) $(vdso32) |
c09d6a04 | 79 | |
a0974e6e WD |
80 | ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) |
81 | KBUILD_CPPFLAGS += -mbig-endian | |
82 | AS += -EB | |
83 | LD += -EB | |
84 | else | |
8c2c3df3 CM |
85 | KBUILD_CPPFLAGS += -mlittle-endian |
86 | AS += -EL | |
87 | LD += -EL | |
a0974e6e | 88 | endif |
8c2c3df3 | 89 | |
8c2c3df3 CM |
90 | CHECKFLAGS += -D__aarch64__ |
91 | ||
4166edc4 | 92 | ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y) |
b6dd8e07 | 93 | KBUILD_CFLAGS_MODULE += -mcmodel=large |
df057cc7 WD |
94 | endif |
95 | ||
4166edc4 AB |
96 | ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) |
97 | KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds | |
98 | endif | |
99 | ||
8c2c3df3 CM |
100 | # Default value |
101 | head-y := arch/arm64/kernel/head.o | |
102 | ||
103 | # The byte offset of the kernel image in RAM from the start of RAM. | |
da57a369 | 104 | ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y) |
4190312b | 105 | TEXT_OFFSET := $(shell awk 'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}') |
da57a369 | 106 | else |
8c2c3df3 | 107 | TEXT_OFFSET := 0x00080000 |
da57a369 | 108 | endif |
8c2c3df3 | 109 | |
e9186826 MK |
110 | ifeq ($(cc-name),clang) |
111 | KBUILD_CFLAGS += $(call cc-disable-warning, asm-operand-widths) | |
112 | endif | |
113 | ||
39d114dd AR |
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)) )) ) | |
120 | ||
8c2c3df3 CM |
121 | export TEXT_OFFSET GZFLAGS |
122 | ||
123 | core-y += arch/arm64/kernel/ arch/arm64/mm/ | |
e54bcde3 | 124 | core-$(CONFIG_NET) += arch/arm64/net/ |
6211753f | 125 | core-$(CONFIG_KVM) += arch/arm64/kvm/ |
63917f0b | 126 | core-$(CONFIG_XEN) += arch/arm64/xen/ |
2c98833a | 127 | core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ |
8c2c3df3 | 128 | libs-y := arch/arm64/lib/ $(libs-y) |
ad08fd49 | 129 | core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a |
8c2c3df3 CM |
130 | |
131 | # Default target when executing plain make | |
69a800c9 | 132 | ifeq ($(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE),y) |
a08cafa7 | 133 | KBUILD_IMAGE := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_KERNEL_IMAGE_NAME)) |
69a800c9 | 134 | else |
70f915a2 | 135 | KBUILD_IMAGE := Image.gz |
69a800c9 AR |
136 | endif |
137 | ||
70f915a2 | 138 | KBUILD_DTBS := dtbs |
8c2c3df3 | 139 | |
70f915a2 | 140 | all: $(KBUILD_IMAGE) $(KBUILD_DTBS) |
8c2c3df3 CM |
141 | |
142 | boot := arch/arm64/boot | |
143 | ||
0723c05f OJ |
144 | Image: vmlinux |
145 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ | |
146 | ||
147 | Image.%: vmlinux | |
70f915a2 | 148 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ |
8c2c3df3 CM |
149 | |
150 | zinstall install: vmlinux | |
70f915a2 | 151 | $(Q)$(MAKE) $(build)=$(boot) $@ |
8c2c3df3 | 152 | |
70f915a2 RH |
153 | %.dtb: scripts |
154 | $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@ | |
155 | ||
862f464a | 156 | PHONY += dtbs dtbs_install |
9fb5e537 RR |
157 | |
158 | dtbs: prepare scripts | |
d38726c4 | 159 | $(Q)$(MAKE) $(build)=$(boot)/dts |
8c2c3df3 | 160 | |
9fb5e537 RR |
161 | dtbs_install: |
162 | $(Q)$(MAKE) $(dtbinst)=$(boot)/dts | |
163 | ||
c11dd134 | 164 | Image-dtb Image.gz-dtb: vmlinux scripts dtbs |
69a800c9 AR |
165 | $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ |
166 | ||
3c01742a KM |
167 | PHONY += vdso_install |
168 | vdso_install: | |
169 | $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@ | |
170 | ||
8c2c3df3 CM |
171 | # We use MRPROPER_FILES and CLEAN_FILES now |
172 | archclean: | |
173 | $(Q)$(MAKE) $(clean)=$(boot) | |
c7c52e48 | 174 | $(Q)$(MAKE) $(clean)=$(boot)/dts |
8c2c3df3 | 175 | |
fb47dee8 KB |
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 | |
181 | # this hack. | |
182 | prepare: vdso_prepare | |
183 | vdso_prepare: prepare0 | |
184 | $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h | |
ca9386d7 KB |
185 | $(if $(CONFIG_VDSO32),$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \ |
186 | include/generated/vdso32-offsets.h) | |
fb47dee8 | 187 | |
8c2c3df3 CM |
188 | define archhelp |
189 | echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' | |
190 | echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' | |
70f915a2 | 191 | echo '* dtbs - Build device tree blobs for enabled boards' |
862f464a | 192 | echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)' |
8c2c3df3 CM |
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' | |
198 | endef |