Linux Audio

Check our new training course

Loading...
v4.6
  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
 13LDFLAGS_vmlinux	:=-p --no-undefined -X
 14CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
 15OBJCOPYFLAGS	:=-O binary -R .note -R .note.gnu.build-id -R .comment -S
 16GZFLAGS		:=-9
 17
 18ifneq ($(CONFIG_RELOCATABLE),)
 19LDFLAGS_vmlinux		+= -pie
 
 
 
 
 20endif
 21
 22KBUILD_DEFCONFIG := defconfig
 23
 24# Check for binutils support for specific extensions
 25lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
 26
 27ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
 28  ifeq ($(lseinstr),)
 29$(warning LSE atomics not supported by binutils)
 30  endif
 31endif
 32
 33KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr)
 34KBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables
 35KBUILD_CFLAGS	+= $(call cc-option, -mpc-relative-literal-loads)
 36KBUILD_AFLAGS	+= $(lseinstr)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 37
 38ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 39KBUILD_CPPFLAGS	+= -mbig-endian
 40AS		+= -EB
 41LD		+= -EB
 42else
 43KBUILD_CPPFLAGS	+= -mlittle-endian
 44AS		+= -EL
 45LD		+= -EL
 46endif
 47
 48CHECKFLAGS	+= -D__aarch64__
 
 49
 50ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
 51KBUILD_CFLAGS_MODULE	+= -mcmodel=large
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 52endif
 53
 54ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
 55KBUILD_LDFLAGS_MODULE	+= -T $(srctree)/arch/arm64/kernel/module.lds
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 56endif
 57
 58# Default value
 59head-y		:= arch/arm64/kernel/head.o
 60
 61# The byte offset of the kernel image in RAM from the start of RAM.
 62ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
 63TEXT_OFFSET := $(shell awk 'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}')
 
 64else
 65TEXT_OFFSET := 0x00080000
 
 
 
 
 
 
 
 
 66endif
 67
 68# KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
 69# in 32-bit arithmetic
 70KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
 71			(0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
 72			+ (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - 3)) \
 73			- (1 << (64 - 32 - 3)) )) )
 74
 75export	TEXT_OFFSET GZFLAGS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 76
 77core-y		+= arch/arm64/kernel arch/arm64/mm/
 78core-$(CONFIG_NET) += arch/arm64/net/
 79core-$(CONFIG_KVM) += arch/arm64/kvm/
 80core-$(CONFIG_XEN) += arch/arm64/xen/
 81core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
 82libs-y		:= arch/arm64/lib/ $(libs-y)
 83core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
 84
 85# Default target when executing plain make
 86KBUILD_IMAGE	:= Image.gz
 87KBUILD_DTBS	:= dtbs
 88
 89all:	$(KBUILD_IMAGE) $(KBUILD_DTBS)
 90
 91boot := arch/arm64/boot
 92
 93Image: vmlinux
 94	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
 
 
 95
 96Image.%: vmlinux
 97	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 98
 99zinstall install:
100	$(Q)$(MAKE) $(build)=$(boot) $@
101
102%.dtb: scripts
103	$(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
 
104
105PHONY += dtbs dtbs_install
 
106
107dtbs: prepare scripts
108	$(Q)$(MAKE) $(build)=$(boot)/dts
 
 
 
109
110dtbs_install:
111	$(Q)$(MAKE) $(dtbinst)=$(boot)/dts
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
113PHONY += vdso_install
114vdso_install:
115	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
 
 
 
 
 
 
 
 
 
 
 
 
 
116
117# We use MRPROPER_FILES and CLEAN_FILES now
118archclean:
119	$(Q)$(MAKE) $(clean)=$(boot)
120	$(Q)$(MAKE) $(clean)=$(boot)/dts
 
 
 
 
121
122define archhelp
123  echo  '* Image.gz      - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
124  echo  '  Image         - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
125  echo  '* dtbs          - Build device tree blobs for enabled boards'
126  echo  '  dtbs_install  - Install dtbs to $(INSTALL_DTBS_PATH)'
127  echo  '  install       - Install uncompressed kernel'
128  echo  '  zinstall      - Install compressed kernel'
129  echo  '                  Install using (your) ~/bin/installkernel or'
130  echo  '                  (distribution) /sbin/installkernel or'
131  echo  '                  install to $$(INSTALL_PATH) and run lilo'
132endef
v6.13.7
  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
 13LDFLAGS_vmlinux	:=--no-undefined -X --pic-veneer
 
 
 
 14
 15ifeq ($(CONFIG_RELOCATABLE), y)
 16# Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
 17# for relative relocs, since this leads to better Image compression
 18# with the relocation offsets always being zero.
 19LDFLAGS_vmlinux		+= -shared -Bsymbolic -z notext \
 20			$(call ld-option, --no-apply-dynamic-relocs)
 21endif
 22
 23ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
 24  ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
 25LDFLAGS_vmlinux	+= --fix-cortex-a53-843419
 
 
 
 
 
 26  endif
 27endif
 28
 29cc_has_k_constraint := $(call try-run,echo				\
 30	'int main(void) {						\
 31		asm volatile("and w0, w0, %w0" :: "K" (4294967295));	\
 32		return 0;						\
 33	}' | $(CC) -S -x c -o "$$TMP" -,,-DCONFIG_CC_HAS_K_CONSTRAINT=1)
 34
 35ifeq ($(CONFIG_BROKEN_GAS_INST),y)
 36$(warning Detected assembler with broken .inst; disassembly will be unreliable)
 37endif
 38
 39# The GCC option -ffreestanding is required in order to compile code containing
 40# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel)
 41CC_FLAGS_FPU	:= -ffreestanding
 42# Enable <arm_neon.h>
 43CC_FLAGS_FPU	+= -isystem $(shell $(CC) -print-file-name=include)
 44CC_FLAGS_NO_FPU	:= -mgeneral-regs-only
 45
 46KBUILD_CFLAGS	+= $(CC_FLAGS_NO_FPU) \
 47		   $(compat_vdso) $(cc_has_k_constraint)
 48KBUILD_CFLAGS	+= $(call cc-disable-warning, psabi)
 49KBUILD_AFLAGS	+= $(compat_vdso)
 50
 51ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y)
 52KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat
 
 
 53else
 54KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon"
 
 
 55endif
 56
 57KBUILD_CFLAGS	+= $(call cc-option,-mabi=lp64)
 58KBUILD_AFLAGS	+= $(call cc-option,-mabi=lp64)
 59
 60# Avoid generating .eh_frame* sections.
 61ifneq ($(CONFIG_UNWIND_TABLES),y)
 62KBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables -fno-unwind-tables
 63KBUILD_AFLAGS	+= -fno-asynchronous-unwind-tables -fno-unwind-tables
 64KBUILD_RUSTFLAGS += -Cforce-unwind-tables=n
 65else
 66KBUILD_CFLAGS	+= -fasynchronous-unwind-tables
 67KBUILD_AFLAGS	+= -fasynchronous-unwind-tables
 68KBUILD_RUSTFLAGS += -Cforce-unwind-tables=y -Zuse-sync-unwind=n
 69endif
 70
 71ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
 72prepare: stack_protector_prepare
 73stack_protector_prepare: prepare0
 74	$(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg		  \
 75				-mstack-protector-guard-reg=sp_el0	  \
 76				-mstack-protector-guard-offset=$(shell	  \
 77			awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
 78				$(objtree)/include/generated/asm-offsets.h))
 79endif
 80
 81ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
 82  KBUILD_CFLAGS += -mbranch-protection=pac-ret+bti
 83  KBUILD_RUSTFLAGS += -Zbranch-protection=bti,pac-ret
 84else ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y)
 85  KBUILD_RUSTFLAGS += -Zbranch-protection=pac-ret
 86  ifeq ($(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET),y)
 87    KBUILD_CFLAGS += -mbranch-protection=pac-ret
 88  else
 89    KBUILD_CFLAGS += -msign-return-address=non-leaf
 90  endif
 91else
 92  KBUILD_CFLAGS += $(call cc-option,-mbranch-protection=none)
 93endif
 94
 95# Tell the assembler to support instructions from the latest target
 96# architecture.
 97#
 98# For non-integrated assemblers we'll pass this on the command line, and for
 99# integrated assemblers we'll define ARM64_ASM_ARCH and ARM64_ASM_PREAMBLE for
100# inline usage.
101#
102# We cannot pass the same arch flag to the compiler as this would allow it to
103# freely generate instructions which are not supported by earlier architecture
104# versions, which would prevent a single kernel image from working on earlier
105# hardware.
106ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
107  asm-arch := armv8.5-a
108else ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
109  asm-arch := armv8.4-a
110else ifeq ($(CONFIG_AS_HAS_ARMV8_3), y)
111  asm-arch := armv8.3-a
112else ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
113  asm-arch := armv8.2-a
114endif
115
116ifdef asm-arch
117KBUILD_CFLAGS	+= -Wa,-march=$(asm-arch) \
118		   -DARM64_ASM_ARCH='"$(asm-arch)"'
119endif
120
121ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
122KBUILD_CFLAGS	+= -ffixed-x18
123KBUILD_RUSTFLAGS += -Zfixed-x18
124endif
125
126ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
127KBUILD_CPPFLAGS	+= -mbig-endian
128CHECKFLAGS	+= -D__AARCH64EB__
129# Prefer the baremetal ELF build target, but not all toolchains include
130# it so fall back to the standard linux version if needed.
131KBUILD_LDFLAGS	+= -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro)
132UTS_MACHINE	:= aarch64_be
133else
134KBUILD_CPPFLAGS	+= -mlittle-endian
135CHECKFLAGS	+= -D__AARCH64EL__
136# Same as above, prefer ELF but fall back to linux target if needed.
137KBUILD_LDFLAGS	+= -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro)
138UTS_MACHINE	:= aarch64
139endif
140
141ifeq ($(CONFIG_LD_IS_LLD), y)
142KBUILD_LDFLAGS	+= -z norelro
143endif
144
145CHECKFLAGS	+= -D__aarch64__
 
 
 
 
 
146
147ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS),y)
148  KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
149  CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2
150else ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_ARGS),y)
151  KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
152  CC_FLAGS_FTRACE := -fpatchable-function-entry=2
153endif
154
155ifeq ($(CONFIG_KASAN_SW_TAGS), y)
156KASAN_SHADOW_SCALE_SHIFT := 4
157else ifeq ($(CONFIG_KASAN_GENERIC), y)
158KASAN_SHADOW_SCALE_SHIFT := 3
159endif
160
161KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
162KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
163KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
164
 
 
 
 
 
165libs-y		:= arch/arm64/lib $(libs-y)
166libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
167
168# Default target when executing plain make
169boot		:= arch/arm64/boot
 
170
171BOOT_TARGETS	:= Image vmlinuz.efi image.fit
172
173PHONY += $(BOOT_TARGETS)
174
175ifeq ($(CONFIG_EFI_ZBOOT),)
176KBUILD_IMAGE	:= $(boot)/Image.gz
177else
178KBUILD_IMAGE	:= $(boot)/vmlinuz.efi
179endif
180
181all:	$(notdir $(KBUILD_IMAGE))
 
182
183image.fit: dtbs
 
184
185vmlinuz.efi image.fit: Image
186$(BOOT_TARGETS): vmlinux
187	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
188
189Image.%: Image
190	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
191
192ifeq ($(CONFIG_COMPRESSED_INSTALL),y)
193 DEFAULT_KBUILD_IMAGE = $(KBUILD_IMAGE)
194else
195 DEFAULT_KBUILD_IMAGE = $(boot)/Image
196endif
197
198install: KBUILD_IMAGE := $(DEFAULT_KBUILD_IMAGE)
199install zinstall:
200	$(call cmd,install)
201
202archprepare:
203	$(Q)$(MAKE) $(build)=arch/arm64/tools kapi
204ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
205  ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
206	@echo "warning: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum" >&2
207  endif
208endif
209ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
210  ifneq ($(CONFIG_ARM64_LSE_ATOMICS),y)
211	@echo "warning: LSE atomics not supported by binutils" >&2
212  endif
213endif
214
215ifeq ($(KBUILD_EXTMOD),)
216# We need to generate vdso-offsets.h before compiling certain files in kernel/.
217# In order to do that, we should use the archprepare target, but we can't since
218# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
219# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
220# Therefore we need to generate the header after prepare0 has been made, hence
221# this hack.
222prepare: vdso_prepare
223vdso_prepare: prepare0
224	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso \
225	include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so
226ifdef CONFIG_COMPAT_VDSO
227	$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
228	arch/arm64/kernel/vdso32/vdso.so
229endif
230endif
231
232vdso-install-y				+= arch/arm64/kernel/vdso/vdso.so.dbg
233vdso-install-$(CONFIG_COMPAT_VDSO)	+= arch/arm64/kernel/vdso32/vdso32.so.dbg
234
235include $(srctree)/scripts/Makefile.defconf
236
237PHONY += virtconfig
238virtconfig:
239	$(call merge_into_defconfig_override,defconfig,virt)
240
241define archhelp
242  echo  '* Image.gz      - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
243  echo  '  Image         - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
244  echo  '  image.fit     - Flat Image Tree (arch/$(ARCH)/boot/image.fit)'
245  echo  '  install       - Install kernel (compressed if COMPRESSED_INSTALL set)'
 
246  echo  '  zinstall      - Install compressed kernel'
247  echo  '                  Install using (your) ~/bin/installkernel or'
248  echo  '                  (distribution) /sbin/installkernel or'
249  echo  '                  install to $$(INSTALL_PATH) and run lilo'
250endef