config.mk 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # (C) Copyright 2000-2002
  4. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. PLATFORM_CPPFLAGS += -fomit-frame-pointer
  6. PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \
  7. $(call cc-option, -fno-unit-at-a-time))
  8. PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
  9. PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
  10. ifdef CONFIG_SPL_BUILD
  11. IS_32BIT := y
  12. else
  13. ifndef CONFIG_X86_64
  14. IS_32BIT := y
  15. endif
  16. endif
  17. EFI_IS_32BIT := $(IS_32BIT)
  18. ifdef CONFIG_EFI_STUB_64BIT
  19. EFI_IS_32BIT :=
  20. endif
  21. ifeq ($(IS_32BIT),y)
  22. PLATFORM_CPPFLAGS += -march=i386 -m32
  23. else
  24. PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
  25. PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
  26. endif
  27. PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
  28. KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions
  29. KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
  30. # This is used in the top-level Makefile which does not include
  31. # KBUILD_LDFLAGS
  32. LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
  33. -s -zexecstack
  34. OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
  35. -j .rel -j .rela -j .reloc --strip-all
  36. # Compiler flags to be added when building UEFI applications
  37. CFLAGS_EFI := -fpic -fshort-wchar
  38. # Compiler flags to be removed when building UEFI applications
  39. CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong
  40. ifeq ($(IS_32BIT),y)
  41. EFIPAYLOAD_BFDARCH = i386
  42. else
  43. CFLAGS_EFI += $(call cc-option, -mno-red-zone)
  44. EFIPAYLOAD_BFDARCH = x86_64
  45. endif
  46. ifeq ($(EFI_IS_32BIT),y)
  47. EFIARCH = ia32
  48. EFIPAYLOAD_BFDTARGET = elf32-i386
  49. else
  50. EFIARCH = x86_64
  51. EFIPAYLOAD_BFDTARGET = elf64-x86-64
  52. endif
  53. LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
  54. EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
  55. OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
  56. CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
  57. CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
  58. ifeq ($(CONFIG_EFI_APP),y)
  59. PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
  60. LDFLAGS_FINAL += -znocombreloc -shared
  61. LDSCRIPT := $(LDSCRIPT_EFI)
  62. else
  63. ifeq ($(IS_32BIT),y)
  64. PLATFORM_CPPFLAGS += -mregparm=3
  65. endif
  66. KBUILD_LDFLAGS += --emit-relocs
  67. LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
  68. endif
  69. ifdef CONFIG_X86_64
  70. ifndef CONFIG_SPL_BUILD
  71. PLATFORM_CPPFLAGS += -D__x86_64__
  72. else
  73. PLATFORM_CPPFLAGS += -D__I386__
  74. endif
  75. else
  76. PLATFORM_CPPFLAGS += -D__I386__
  77. endif
  78. ifdef CONFIG_EFI_STUB
  79. ifdef CONFIG_EFI_STUB_64BIT
  80. EFI_LDS := elf_x86_64_efi.lds
  81. EFI_CRT0 := crt0_x86_64_efi.o
  82. EFI_RELOC := reloc_x86_64_efi.o
  83. else
  84. EFI_LDS := elf_ia32_efi.lds
  85. EFI_CRT0 := crt0_ia32_efi.o
  86. EFI_RELOC := reloc_ia32_efi.o
  87. endif
  88. else
  89. ifdef CONFIG_X86_64
  90. EFI_LDS := elf_x86_64_efi.lds
  91. EFI_CRT0 := crt0_x86_64_efi.o
  92. EFI_RELOC := reloc_x86_64_efi.o
  93. else
  94. EFI_LDS := elf_ia32_efi.lds
  95. EFI_CRT0 := crt0_ia32_efi.o
  96. EFI_RELOC := reloc_ia32_efi.o
  97. endif
  98. endif
  99. ifdef CONFIG_X86_64
  100. EFI_TARGET := --target=efi-app-x86_64
  101. else
  102. EFI_TARGET := --target=efi-app-ia32
  103. endif