[U-Boot] [PATCH] HACK: Some further clang support for ARM

Tom Rini trini at konsulko.com
Sun Apr 22 23:22:34 UTC 2018


- Have logic in one place for -ffixed-r9 or -ffixed-x18 as clang -target
  aarch64-linux-gnu will warn about being passed an invalid arugment,
  -ffixed-r9.  I should submit this on its own as a cleanup.
- clang does NOT like:
  str8w   r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f
  and makes it a fatal error.  Work-around this by expanding the macro
  by hand in 3 places.

Not included in here is that clang does not at all care for the EFI
loader saving / restoring gd in C as it does.  This is already
documented in doc/README.clang, but I'm spelling it out here.

Cc: Alexander Graf <agraf at suse.de>
Signed-off-by: Tom Rini <trini at konsulko.com>
---
 arch/arm/config.mk           | 10 ++++++++--
 arch/arm/cpu/armv8/config.mk |  1 -
 arch/arm/lib/memcpy.S        |  4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index b448ed0b3ebd..f42aa35f4e59 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -13,12 +13,18 @@ CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
 endif
 endif
 
-CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections
+ifeq ($(CONFIG_ARM64),y)
+FIXED_GD_REG := -ffixed-x18
+else
+FIXED_GD_REG := -ffixed-r9
+endif
+
+CFLAGS_NON_EFI := -fno-pic $(FIXED_GD_REG) -ffunction-sections -fdata-sections
 CFLAGS_EFI := -fpic -fshort-wchar
 
 LDFLAGS_FINAL += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \
-		     -fno-common -ffixed-r9
+		     -fno-common $(FIXED_GD_REG)
 PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
       $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
 
diff --git a/arch/arm/cpu/armv8/config.mk b/arch/arm/cpu/armv8/config.mk
index 27b66d41b1a8..2b6ced6648ec 100644
--- a/arch/arm/cpu/armv8/config.mk
+++ b/arch/arm/cpu/armv8/config.mk
@@ -4,7 +4,6 @@
 #
 # SPDX-License-Identifier:	GPL-2.0+
 #
-PLATFORM_RELFLAGS += -fno-common -ffixed-x18
 
 PF_NO_UNALIGNED := $(call cc-option, -mstrict-align)
 PLATFORM_CPPFLAGS += $(PF_NO_UNALIGNED)
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index 588b3f8971ae..307c3bbc1472 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -96,7 +96,7 @@ ENTRY(memcpy)
 3:	PLD(	pld	[r1, #124]		)
 4:		ldr8w	r1, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f
 		subs	r2, r2, #32
-		str8w	r0, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f
+		stmia	r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
 		bge	3b
 	PLD(	cmn	r2, #96			)
 	PLD(	bge	4b			)
@@ -212,7 +212,7 @@ ENTRY(memcpy)
 		orr	r9, r9, ip, lspush #\push
 		mov	ip, ip, lspull #\pull
 		orr	ip, ip, lr, lspush #\push
-		str8w	r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f
+		stmia	r0!, {r3, r4, r5, r6, r7, r8, r9, ip}
 		bge	12b
 	PLD(	cmn	r2, #96			)
 	PLD(	bge	13b			)
-- 
2.7.4



More information about the U-Boot mailing list