Back to home page

OSCL-LXR

 
 

    


0001 #
0002 # arch/arm64/Makefile
0003 #
0004 # This file is included by the global makefile so that you can add your own
0005 # architecture-specific flags and dependencies.
0006 #
0007 # This file is subject to the terms and conditions of the GNU General Public
0008 # License.  See the file "COPYING" in the main directory of this archive
0009 # for more details.
0010 #
0011 # Copyright (C) 1995-2001 by Russell King
0012 
0013 LDFLAGS_vmlinux :=--no-undefined -X
0014 
0015 ifeq ($(CONFIG_RELOCATABLE), y)
0016 # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
0017 # for relative relocs, since this leads to better Image compression
0018 # with the relocation offsets always being zero.
0019 LDFLAGS_vmlinux         += -shared -Bsymbolic -z notext \
0020                         $(call ld-option, --no-apply-dynamic-relocs)
0021 endif
0022 
0023 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
0024   ifeq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
0025 LDFLAGS_vmlinux += --fix-cortex-a53-843419
0026   endif
0027 endif
0028 
0029 cc_has_k_constraint := $(call try-run,echo                              \
0030         'int main(void) {                                               \
0031                 asm volatile("and w0, w0, %w0" :: "K" (4294967295));    \
0032                 return 0;                                               \
0033         }' | $(CC) -S -x c -o "$$TMP" -,,-DCONFIG_CC_HAS_K_CONSTRAINT=1)
0034 
0035 ifeq ($(CONFIG_BROKEN_GAS_INST),y)
0036 $(warning Detected assembler with broken .inst; disassembly will be unreliable)
0037 endif
0038 
0039 KBUILD_CFLAGS   += -mgeneral-regs-only  \
0040                    $(compat_vdso) $(cc_has_k_constraint)
0041 KBUILD_CFLAGS   += $(call cc-disable-warning, psabi)
0042 KBUILD_AFLAGS   += $(compat_vdso)
0043 
0044 KBUILD_CFLAGS   += $(call cc-option,-mabi=lp64)
0045 KBUILD_AFLAGS   += $(call cc-option,-mabi=lp64)
0046 
0047 # Avoid generating .eh_frame* sections.
0048 KBUILD_CFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
0049 KBUILD_AFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
0050 
0051 ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
0052 prepare: stack_protector_prepare
0053 stack_protector_prepare: prepare0
0054         $(eval KBUILD_CFLAGS += -mstack-protector-guard=sysreg            \
0055                                 -mstack-protector-guard-reg=sp_el0        \
0056                                 -mstack-protector-guard-offset=$(shell    \
0057                         awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
0058                                         include/generated/asm-offsets.h))
0059 endif
0060 
0061 ifeq ($(CONFIG_AS_HAS_ARMV8_2), y)
0062 # make sure to pass the newest target architecture to -march.
0063 asm-arch := armv8.2-a
0064 endif
0065 
0066 # Ensure that if the compiler supports branch protection we default it
0067 # off, this will be overridden if we are using branch protection.
0068 branch-prot-flags-y += $(call cc-option,-mbranch-protection=none)
0069 
0070 ifeq ($(CONFIG_ARM64_PTR_AUTH_KERNEL),y)
0071 branch-prot-flags-$(CONFIG_CC_HAS_SIGN_RETURN_ADDRESS) := -msign-return-address=all
0072 # We enable additional protection for leaf functions as there is some
0073 # narrow potential for ROP protection benefits and no substantial
0074 # performance impact has been observed.
0075 ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
0076 branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=pac-ret+leaf+bti
0077 else
0078 branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pac-ret+leaf
0079 endif
0080 # -march=armv8.3-a enables the non-nops instructions for PAC, to avoid the
0081 # compiler to generate them and consequently to break the single image contract
0082 # we pass it only to the assembler. This option is utilized only in case of non
0083 # integrated assemblers.
0084 ifeq ($(CONFIG_AS_HAS_PAC), y)
0085 asm-arch := armv8.3-a
0086 endif
0087 endif
0088 
0089 KBUILD_CFLAGS += $(branch-prot-flags-y)
0090 
0091 ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
0092 # make sure to pass the newest target architecture to -march.
0093 asm-arch := armv8.4-a
0094 endif
0095 
0096 ifeq ($(CONFIG_AS_HAS_ARMV8_5), y)
0097 # make sure to pass the newest target architecture to -march.
0098 asm-arch := armv8.5-a
0099 endif
0100 
0101 ifdef asm-arch
0102 KBUILD_CFLAGS   += -Wa,-march=$(asm-arch) \
0103                    -DARM64_ASM_ARCH='"$(asm-arch)"'
0104 endif
0105 
0106 ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
0107 KBUILD_CFLAGS   += -ffixed-x18
0108 endif
0109 
0110 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
0111 KBUILD_CPPFLAGS += -mbig-endian
0112 CHECKFLAGS      += -D__AARCH64EB__
0113 # Prefer the baremetal ELF build target, but not all toolchains include
0114 # it so fall back to the standard linux version if needed.
0115 KBUILD_LDFLAGS  += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb -z norelro)
0116 UTS_MACHINE     := aarch64_be
0117 else
0118 KBUILD_CPPFLAGS += -mlittle-endian
0119 CHECKFLAGS      += -D__AARCH64EL__
0120 # Same as above, prefer ELF but fall back to linux target if needed.
0121 KBUILD_LDFLAGS  += -EL $(call ld-option, -maarch64elf, -maarch64linux -z norelro)
0122 UTS_MACHINE     := aarch64
0123 endif
0124 
0125 ifeq ($(CONFIG_LD_IS_LLD), y)
0126 KBUILD_LDFLAGS  += -z norelro
0127 endif
0128 
0129 CHECKFLAGS      += -D__aarch64__
0130 
0131 ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y)
0132   KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
0133   CC_FLAGS_FTRACE := -fpatchable-function-entry=2
0134 endif
0135 
0136 # Default value
0137 head-y          := arch/arm64/kernel/head.o
0138 
0139 ifeq ($(CONFIG_KASAN_SW_TAGS), y)
0140 KASAN_SHADOW_SCALE_SHIFT := 4
0141 else ifeq ($(CONFIG_KASAN_GENERIC), y)
0142 KASAN_SHADOW_SCALE_SHIFT := 3
0143 endif
0144 
0145 KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
0146 KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
0147 KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
0148 
0149 libs-y          := arch/arm64/lib/ $(libs-y)
0150 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
0151 
0152 # Default target when executing plain make
0153 boot            := arch/arm64/boot
0154 KBUILD_IMAGE    := $(boot)/Image.gz
0155 
0156 all:    Image.gz
0157 
0158 
0159 Image: vmlinux
0160         $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
0161 
0162 Image.%: Image
0163         $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
0164 
0165 install: KBUILD_IMAGE := $(boot)/Image
0166 install zinstall:
0167         $(call cmd,install)
0168 
0169 PHONY += vdso_install
0170 vdso_install:
0171         $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
0172         $(if $(CONFIG_COMPAT_VDSO), \
0173                 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
0174 
0175 archprepare:
0176         $(Q)$(MAKE) $(build)=arch/arm64/tools kapi
0177 ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
0178   ifneq ($(CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419),y)
0179         @echo "warning: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum" >&2
0180   endif
0181 endif
0182 ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS),y)
0183   ifneq ($(CONFIG_ARM64_LSE_ATOMICS),y)
0184         @echo "warning: LSE atomics not supported by binutils" >&2
0185   endif
0186 endif
0187 
0188 ifeq ($(KBUILD_EXTMOD),)
0189 # We need to generate vdso-offsets.h before compiling certain files in kernel/.
0190 # In order to do that, we should use the archprepare target, but we can't since
0191 # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
0192 # asm-offsets.h is built in prepare0, for which archprepare is a dependency.
0193 # Therefore we need to generate the header after prepare0 has been made, hence
0194 # this hack.
0195 prepare: vdso_prepare
0196 vdso_prepare: prepare0
0197         $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso \
0198         include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so
0199 ifdef CONFIG_COMPAT_VDSO
0200         $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
0201         include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so
0202 endif
0203 endif
0204 
0205 define archhelp
0206   echo  '* Image.gz      - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
0207   echo  '  Image         - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
0208   echo  '  install       - Install uncompressed kernel'
0209   echo  '  zinstall      - Install compressed kernel'
0210   echo  '                  Install using (your) ~/bin/installkernel or'
0211   echo  '                  (distribution) /sbin/installkernel or'
0212   echo  '                  install to $$(INSTALL_PATH) and run lilo'
0213 endef