Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 :=-p --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 += -pie -shared -Bsymbolic \
  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. KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
  38. KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
  39. KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
  40. KBUILD_AFLAGS += $(lseinstr)
  41. ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  42. KBUILD_CPPFLAGS += -mbig-endian
  43. AS += -EB
  44. LD += -EB
  45. UTS_MACHINE := aarch64_be
  46. else
  47. KBUILD_CPPFLAGS += -mlittle-endian
  48. AS += -EL
  49. LD += -EL
  50. UTS_MACHINE := aarch64
  51. endif
  52. CHECKFLAGS += -D__aarch64__
  53. ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
  54. KBUILD_CFLAGS_MODULE += -mcmodel=large
  55. endif
  56. ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
  57. KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
  58. endif
  59. # Default value
  60. head-y := arch/arm64/kernel/head.o
  61. # The byte offset of the kernel image in RAM from the start of RAM.
  62. ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
  63. TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \
  64. int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
  65. rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
  66. else
  67. TEXT_OFFSET := 0x00080000
  68. endif
  69. # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
  70. # in 32-bit arithmetic
  71. KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
  72. (0xffffffff & (-1 << ($(CONFIG_ARM64_VA_BITS) - 32))) \
  73. + (1 << ($(CONFIG_ARM64_VA_BITS) - 32 - 3)) \
  74. - (1 << (64 - 32 - 3)) )) )
  75. export TEXT_OFFSET GZFLAGS
  76. core-y += arch/arm64/kernel/ arch/arm64/mm/
  77. core-$(CONFIG_NET) += arch/arm64/net/
  78. core-$(CONFIG_KVM) += arch/arm64/kvm/
  79. core-$(CONFIG_XEN) += arch/arm64/xen/
  80. core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
  81. libs-y := arch/arm64/lib/ $(libs-y)
  82. core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
  83. # Default target when executing plain make
  84. KBUILD_IMAGE := Image.gz
  85. KBUILD_DTBS := dtbs
  86. all: $(KBUILD_IMAGE) $(KBUILD_DTBS)
  87. boot := arch/arm64/boot
  88. Image: vmlinux
  89. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  90. Image.%: Image
  91. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  92. zinstall install:
  93. $(Q)$(MAKE) $(build)=$(boot) $@
  94. %.dtb: scripts
  95. $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
  96. PHONY += dtbs dtbs_install
  97. dtbs: prepare scripts
  98. $(Q)$(MAKE) $(build)=$(boot)/dts
  99. dtbs_install:
  100. $(Q)$(MAKE) $(dtbinst)=$(boot)/dts
  101. PHONY += vdso_install
  102. vdso_install:
  103. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
  104. # We use MRPROPER_FILES and CLEAN_FILES now
  105. archclean:
  106. $(Q)$(MAKE) $(clean)=$(boot)
  107. $(Q)$(MAKE) $(clean)=$(boot)/dts
  108. # We need to generate vdso-offsets.h before compiling certain files in kernel/.
  109. # In order to do that, we should use the archprepare target, but we can't since
  110. # asm-offsets.h is included in some files used to generate vdso-offsets.h, and
  111. # asm-offsets.h is built in prepare0, for which archprepare is a dependency.
  112. # Therefore we need to generate the header after prepare0 has been made, hence
  113. # this hack.
  114. prepare: vdso_prepare
  115. vdso_prepare: prepare0
  116. $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
  117. define archhelp
  118. echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
  119. echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
  120. echo '* dtbs - Build device tree blobs for enabled boards'
  121. echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
  122. echo ' install - Install uncompressed kernel'
  123. echo ' zinstall - Install compressed kernel'
  124. echo ' Install using (your) ~/bin/installkernel or'
  125. echo ' (distribution) /sbin/installkernel or'
  126. echo ' install to $$(INSTALL_PATH) and run lilo'
  127. endef