Makefile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. LDFLAGS_vmlinux :=--no-undefined -X
  13. CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
  14. GZFLAGS :=-9
  15. ifeq ($(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.
  19. LDFLAGS_vmlinux += -shared -Bsymbolic -z notext -z norelro \
  20. $(call ld-option, --no-apply-dynamic-relocs)
  21. endif
  22. ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
  23. ifeq ($(call ld-option, --fix-cortex-a53-843419),)
  24. $(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum)
  25. else
  26. LDFLAGS_vmlinux += --fix-cortex-a53-843419
  27. endif
  28. endif
  29. KBUILD_DEFCONFIG := defconfig
  30. # Check for binutils support for specific extensions
  31. lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
  32. ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
  33. ifeq ($(lseinstr),)
  34. $(warning LSE atomics not supported by binutils)
  35. endif
  36. endif
  37. ifeq ($(CONFIG_ARM64), y)
  38. brokengasinst := $(call as-instr,1:\n.inst 0\n.rept . - 1b\n\nnop\n.endr\n,,-DCONFIG_BROKEN_GAS_INST=1)
  39. ifneq ($(brokengasinst),)
  40. $(warning Detected assembler with broken .inst; disassembly will be unreliable)
  41. endif
  42. endif
  43. KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst)
  44. KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
  45. KBUILD_CFLAGS += $(call cc-disable-warning, psabi)
  46. KBUILD_AFLAGS += $(lseinstr) $(brokengasinst)
  47. KBUILD_CFLAGS += $(call cc-option,-mabi=lp64)
  48. KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
  49. ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  50. KBUILD_CPPFLAGS += -mbig-endian
  51. CHECKFLAGS += -D__AARCH64EB__
  52. AS += -EB
  53. # Prefer the baremetal ELF build target, but not all toolchains include
  54. # it so fall back to the standard linux version if needed.
  55. KBUILD_LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
  56. UTS_MACHINE := aarch64_be
  57. else
  58. KBUILD_CPPFLAGS += -mlittle-endian
  59. CHECKFLAGS += -D__AARCH64EL__
  60. AS += -EL
  61. # Same as above, prefer ELF but fall back to linux target if needed.
  62. KBUILD_LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux)
  63. UTS_MACHINE := aarch64
  64. endif
  65. CHECKFLAGS += -D__aarch64__
  66. ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
  67. KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
  68. endif
  69. # Default value
  70. head-y := arch/arm64/kernel/head.o
  71. # The byte offset of the kernel image in RAM from the start of RAM.
  72. ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
  73. TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \
  74. int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
  75. rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
  76. else
  77. TEXT_OFFSET := 0x00080000
  78. endif
  79. # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - KASAN_SHADOW_SCALE_SHIFT))
  80. # - (1 << (64 - KASAN_SHADOW_SCALE_SHIFT))
  81. # in 32-bit arithmetic
  82. KASAN_SHADOW_SCALE_SHIFT := 3
  83. KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
  84. (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
  85. + (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - $(KASAN_SHADOW_SCALE_SHIFT))) \
  86. - (1 << (64 - 32 - $(KASAN_SHADOW_SCALE_SHIFT))) )) )
  87. export TEXT_OFFSET GZFLAGS
  88. core-y += arch/arm64/kernel/ arch/arm64/mm/
  89. core-$(CONFIG_NET) += arch/arm64/net/
  90. core-$(CONFIG_KVM) += arch/arm64/kvm/
  91. core-$(CONFIG_XEN) += arch/arm64/xen/
  92. core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
  93. libs-y := arch/arm64/lib/ $(libs-y)
  94. core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
  95. # Default target when executing plain make
  96. boot := arch/arm64/boot
  97. KBUILD_IMAGE := $(boot)/Image.gz
  98. KBUILD_DTBS := dtbs
  99. all: Image.gz $(KBUILD_DTBS)
  100. Image: vmlinux
  101. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  102. Image.%: Image
  103. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  104. zinstall install:
  105. $(Q)$(MAKE) $(build)=$(boot) $@
  106. %.dtb: scripts
  107. $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
  108. PHONY += dtbs dtbs_install
  109. dtbs: prepare scripts
  110. $(Q)$(MAKE) $(build)=$(boot)/dts
  111. dtbs_install:
  112. $(Q)$(MAKE) $(dtbinst)=$(boot)/dts
  113. PHONY += vdso_install
  114. vdso_install:
  115. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
  116. # We use MRPROPER_FILES and CLEAN_FILES now
  117. archclean:
  118. $(Q)$(MAKE) $(clean)=$(boot)
  119. $(Q)$(MAKE) $(clean)=$(boot)/dts
  120. ifeq ($(KBUILD_EXTMOD),)
  121. # We need to generate vdso-offsets.h before compiling certain files in kernel/.
  122. # In order to do that, we should use the archprepare target, but we can't since
  123. # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
  124. # asm-offsets.h is built in prepare0, for which archprepare is a dependency.
  125. # Therefore we need to generate the header after prepare0 has been made, hence
  126. # this hack.
  127. prepare: vdso_prepare
  128. vdso_prepare: prepare0
  129. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
  130. endif
  131. define archhelp
  132. echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
  133. echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
  134. echo '* dtbs - Build device tree blobs for enabled boards'
  135. echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
  136. echo ' install - Install uncompressed kernel'
  137. echo ' zinstall - Install compressed kernel'
  138. echo ' Install using (your) ~/bin/installkernel or'
  139. echo ' (distribution) /sbin/installkernel or'
  140. echo ' install to $$(INSTALL_PATH) and run lilo'
  141. endef