diff mbox

[U-Boot,v3,61/62] x86: Update compile/link flags to support 64-bit U-Boot

Message ID 20170116140427.29283-62-sjg@chromium.org
State Accepted
Commit 3a03703afcabb779f8e74720d95889e2be83a861
Delegated to: Bin Meng
Headers show

Commit Message

Simon Glass Jan. 16, 2017, 2:04 p.m. UTC
Update config.mk settings to support both 32-bit and 64-bit U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v3: None
Changes in v2: None

 arch/x86/config.mk     | 30 ++++++++++++++++++++++++++++--
 arch/x86/cpu/config.mk |  2 --
 2 files changed, 28 insertions(+), 4 deletions(-)

Comments

Bin Meng Feb. 7, 2017, 5:18 a.m. UTC | #1
On Mon, Jan 16, 2017 at 10:04 PM, Simon Glass <sjg@chromium.org> wrote:
> Update config.mk settings to support both 32-bit and 64-bit U-Boot.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  arch/x86/config.mk     | 30 ++++++++++++++++++++++++++++--
>  arch/x86/cpu/config.mk |  2 --
>  2 files changed, 28 insertions(+), 4 deletions(-)
>

applied to u-boot-x86, thanks!
diff mbox

Patch

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 1697dca47fb..74b87ceac54 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -15,11 +15,25 @@  PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
 
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
+
+ifdef CONFIG_SPL_BUILD
+IS_32BIT := y
+else
+ifndef CONFIG_X86_64
+IS_32BIT := y
+endif
+endif
+
+ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
+else
+PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common
+endif
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions -m elf_i386
+PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
 
 LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
@@ -31,7 +45,9 @@  LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
 OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
 	-j .rel -j .rela -j .reloc
 
+ifeq ($(IS_32BIT),y)
 CFLAGS_NON_EFI := -mregparm=3
+endif
 CFLAGS_EFI := -fpic -fshort-wchar
 
 ifeq ($(CONFIG_EFI_STUB_64BIT),)
@@ -62,8 +78,18 @@  else
 
 PLATFORM_CPPFLAGS += $(CFLAGS_NON_EFI)
 PLATFORM_LDFLAGS += --emit-relocs
-LDFLAGS_FINAL += --gc-sections -pie
+LDFLAGS_FINAL += --gc-sections $(if $(CONFIG_SPL_BUILD),,-pie)
+
+endif
 
+ifdef CONFIG_X86_64
+ifndef CONFIG_SPL_BUILD
+PLATFORM_CPPFLAGS += -D__x86_64__
+else
+PLATFORM_CPPFLAGS += -D__I386__
+endif
+else
+PLATFORM_CPPFLAGS += -D__I386__
 endif
 
 ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk
index 4c99a35621d..b519f433acf 100644
--- a/arch/x86/cpu/config.mk
+++ b/arch/x86/cpu/config.mk
@@ -7,8 +7,6 @@ 
 
 CROSS_COMPILE ?= i386-linux-
 
-PLATFORM_CPPFLAGS += -D__I386__
-
 # DO NOT MODIFY THE FOLLOWING UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!
 LDPPFLAGS += -DRESET_SEG_START=$(CONFIG_RESET_SEG_START)
 LDPPFLAGS += -DRESET_SEG_SIZE=$(CONFIG_RESET_SEG_SIZE)