Skip to contentSkip to conversation

arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4'

DISCUSSION Colin Watson 3 participants 8 messages Nov 13, 2013 – Nov 14, 2013

lore
Share & tools
lore
#0 lore raw

After my previous fix, arm-uboot still fails to build with:

  arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I../../../grub-core -I..  -Wall -W -I../../../include -I../include  -DGRUB_MACHINE_UBOOT=1 -DGRUB_MACHINE_ARM=1 -DGRUB_MACHINE=ARM_UBOOT -DGRUB_TARGET_CPU_ARM=1 -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -DGRUB_FILE=\"lib/arg.c\" -I. -I../../../grub-core -I.. -I../../.. -I../../../include -I../include -I../../../grub-core/lib/libgcrypt-grub/include -I../../../grub-core/lib/libgcrypt-grub/src/   -DGRUB_KERNEL=1   -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -freg-struct-return -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -fno-stack-protector -mno-unaligned-access -Wtrampolines -Werror -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1     -mthumb-interwork -mlong-calls -ffreestanding   -MT lib/kernel_exec-arg.o -MD -MP -MF lib/.deps-core/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o `test -f 'lib/arg.c' || echo '../../../grub-core/'`lib/arg.c
  misc.S: Assembler messages:
  misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4'
  make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

Signature · 1 line
Colin Watson                                       [[email protected]]
#1 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 3 lines · Colin Watson

After my previous fix, arm-uboot still fails to build with:

arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I../../../grub-core -I.. -Wall -W -I../../../include -I../include -DGRUB_MACHINE_UBOOT=1 -DGRUB_MACHINE_ARM=1 -DGRUB_MACHINE=ARM_UBOOT -DGRUB_TARGET_CPU_ARM=1 -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -DGRUB_FILE=\"lib/arg.c\" -I. -I../../../grub-core -I.. -I../../.. -I../../../include -I../include -I../../../grub-core/lib/libgcrypt-grub/include -I../../../grub-core/lib/libgcrypt-grub/src/ -DGRUB_KERNEL=1 -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-ar

ith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -freg-struct-return -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -fno-stack-protector -mno-unaligned-access -Wtrampolines -Werror -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1 -mthumb-interwork -mlong-calls -ffreestanding -MT lib/kernel_exec-arg.o -MD -MP -MF lib/.deps-core/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o test -f 'lib/arg.c' || echo '../../../grub-core/'lib/arg.c

Quoted 6 lines

misc.S: Assembler messages:
misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4' make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

I think that our asm routines should be in full ARM. Attached patch follows this strategy. One remaining problem is to make sure that thumb flags in TARGET_CFLAGS and TARGET_CCASFLAGS match.

conf/Makefile.common +2 -1
index 0dc26db..c563c51 100644
@@ -19,7 +19,8 @@ if COND_sparc64_ieee1275
   LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
 endif
 if COND_arm
-  CFLAGS_PLATFORM += -mthumb-interwork -mlong-calls
+  CFLAGS_PLATFORM += -mlong-calls -mthumb-interwork
+  CCASFLAGS_PLATFORM = -mthumb-interwork
   LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
 endif
 
grub-core/kern/arm/cache.S +6 -2
index 8522d24..3d2503e 100644
@@ -84,19 +84,22 @@ FUNCTION(grub_arch_sync_caches_armv6)
 #else
 FUNCTION(grub_arch_sync_caches_armv7)
 #endif
+	ARM_PROLOGUE
 	DSB
 	add	r1, r0, r1
 	push	{r0-r2, lr}
 	bl	clean_dcache_range
 	pop	{r0, r1}
 	bl	invalidate_icache_range
-	pop	{r2, pc}
+	pop	{r2, lr}
+	bx 	lr
 
 #ifdef ARMV6
 FUNCTION(grub_arm_disable_caches_mmu_armv6)
 #else
 FUNCTION(grub_arm_disable_caches_mmu_armv7)
 #endif
+	ARM_PROLOGUE
 
 	push	{r4, lr}
 
@@ -132,5 +135,6 @@ FUNCTION(grub_arm_disable_caches_mmu_armv7)
 	DSB
 	ISB
 
-	pop	{r4, pc}
+	pop	{r4, lr}
+	bx	lr
 
grub-core/kern/arm/cache_armv6.S +2 -0
index 52b8157..d6371eb 100644
@@ -37,9 +37,11 @@ clean_invalidate_dcache:
 #include "cache.S"
 
 FUNCTION(grub_arm_main_id)
+	ARM_PROLOGUE
 	mrc 	p15, 0, r0, c0, c0, 0
 	bx lr
 
 FUNCTION(grub_arm_cache_type)
+	ARM_PROLOGUE
 	mrc 	p15, 0, r0, c0, c0, 1
 	bx lr
\ No newline at end of file
grub-core/kern/arm/cache_armv7.S +16 -4
index 0c16b10..454bad3 100644
@@ -22,10 +22,16 @@
 	.text
 	.syntax	unified
 	.arm
+#ifdef __clang__
+# define DMB .long 0xf57ff05f
+# define DSB .long 0xf57ff04f
+# define ISB .long 0xf57ff06f
+#else
 	.arch	armv7a
 # define DMB	dmb
 # define DSB	dsb
 # define ISB	isb
+#endif
 #define ARMV7 1
 
 	@ r0  - CLIDR
@@ -58,11 +64,17 @@ clean_invalidate_dcache:
 	@ read current cache information
 	mrc	p15, 1, r8, c0, c0, 0	@ Read CCSIDR
 	lsr	r3, r8, #13		@ Number of sets -1
-	ldr	r9, =0x3fff
-	and	r3, r3, r9
+
+	@ Keep only 14 bits of r3
+	lsl     r3, r3, #18
+	lsr     r3, r3, #18
+
 	lsr	r4, r8, #3		@ Number of ways -1
-	ldr	r9, =0x1ff
-	and	r4, r4, r9
+
+	@ Keep only 9  bits of r4
+	lsl     r4, r4, #23
+	lsr     r4, r4, #23
+
 	and	r7, r8, #7		@ log2(line size in words) - 2
 	add	r7, r7, #2		@  adjust
 	mov	r8, #1
grub-core/kern/arm/misc.S +3 -5
index 8420a2a..f5513c0 100644
@@ -22,16 +22,13 @@
 	.file	"misc.S"
 	.text
 	.syntax	unified
-#if !defined (__thumb2__)
 	.arm
-#else
-	.thumb
-#endif
 
 	.align	2
 
 FUNCTION(__muldi3)
 FUNCTION(__aeabi_lmul)
+	ARM_PROLOGUE
         stmfd   sp!, {r4, fp}
         add     fp, sp, #4
         sub     sp, sp, #16
@@ -74,14 +71,15 @@ FUNCTION(__aeabi_lmul)
 	.endm
 
 FUNCTION(__aeabi_uidivmod)
+	ARM_PROLOGUE
 	division grub_divmod64
 
-
 /*
  * Null divide-by-zero handler
  */
 FUNCTION(__aeabi_unwind_cpp_pr0)
 FUNCTION(raise)
+	ARM_PROLOGUE
 	mov	r0, #0
 	bx	lr
 	
grub-core/kern/arm/uboot/startup.S +20 -4
index f54b14b..25c978a 100644
@@ -47,7 +47,10 @@
 	
 	.text
 	.arm
-FUNCTION(_start)
+	/* Don't use FUNCTION as this entry point is always ARM.  */
+	.globl EXT_C(_start)
+	.type EXT_C(_start), %function
+EXT_C(_start):
 	b	codestart
 	
 	@ Size of final image integrated module blob - set by grub-mkimage
@@ -66,7 +69,7 @@ bss_start_ptr:
 end_ptr:
 	.long   EXT_C(_end)
 
-FUNCTION(codestart)
+codestart:
 	@ Store context: Machine ID, atags/dtb, ...
 	@ U-Boot API signature is stored on the U-Boot heap
 	@ Stack pointer used as start address for signature probing
@@ -117,8 +120,19 @@ FUNCTION(codestart)
 1:	str	r2, [r0], #4
 	cmp	r0, r1
 	bne	1b
-	
-	b	EXT_C(grub_main)
+
+	ldr     r0, main_addr
+#ifdef __thumb__
+	orr     r0, r0, #1
+#endif
+	bx	r0
+	.p2align 2
+#ifdef __thumb__
+	.thumb
+#endif
+main_addr:
+	.long EXT_C(grub_main)
+	.arm
 
 	/*
 	 * uboot_syscall():
@@ -128,6 +142,7 @@ FUNCTION(codestart)
 	 *   U-Boot (Global Data Pointer) and preserve it for Grub.
 	 */
 FUNCTION(grub_uboot_syscall)
+	ARM_PROLOGUE
 	str     r8, transition_space
 	str     lr, transition_space + 4
 	str     r9, transition_space + 8
@@ -152,6 +167,7 @@ FUNCTION(grub_uboot_syscall)
 	bx	lr
 	
 FUNCTION(grub_uboot_return)
+	ARM_PROLOGUE
 	adr	sp, entry_state_end
 	pop	{r4-r12, lr}
 	mov	sp, r12
grub-core/lib/arm/setjmp.S +2 -0
index 4f15679..b731975 100644
@@ -32,6 +32,7 @@ GRUB_MOD_LICENSE "GPLv3+"
  * int grub_setjmp (grub_jmp_buf env)
  */
 FUNCTION(grub_setjmp)
+	ARM_PROLOGUE
 	stm	r0, { r4-r11, sp, lr }
 	mov	r0, #0
 	bx	lr
@@ -40,6 +41,7 @@ FUNCTION(grub_setjmp)
  * int grub_longjmp (grub_jmp_buf env, int val)
  */
 FUNCTION(grub_longjmp)
+	ARM_PROLOGUE
  	ldm	r0, { r4-r11, sp, lr }
 	movs	r0, r1
 	moveq	r0, #1
include/grub/symbol.h +16 -0
index 62d3cb1..6de9be2 100644
@@ -52,9 +52,25 @@
 /* .type not supported for non-ELF targets.  XXX: Check this in configure? */
 #define FUNCTION(x)	.globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 32; .endef; EXT_C(x):
 #define VARIABLE(x)	.globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 0; .endef; EXT_C(x):
+#elif defined (__thumb__)
+#define FUNCTION(x)	.p2align 2 ; .thumb ; .globl EXT_C(x) ; .type EXT_C(x), %function ; .thumb_func ; EXT_C(x):
+#define VARIABLE(x)	.globl EXT_C(x) ; .type EXT_C(x), %object ; EXT_C(x):
+#ifdef ASM_FILE
+	.macro ARM_PROLOGUE
+	bx pc
+	nop
+	.arm
+	orr lr, lr, #1
+	.endm
+#endif
 #elif defined (__arm__)
 #define FUNCTION(x)	.globl EXT_C(x) ; .type EXT_C(x), %function ; EXT_C(x):
 #define VARIABLE(x)	.globl EXT_C(x) ; .type EXT_C(x), %object ; EXT_C(x):
+#ifdef ASM_FILE
+	.macro ARM_PROLOGUE
+	.arm
+	.endm
+#endif
 #else
 #define FUNCTION(x)	.globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x):
 #define VARIABLE(x)	.globl EXT_C(x) ; .type EXT_C(x), @object ; EXT_C(x):
#2 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Colin Watson

After my previous fix, arm-uboot still fails to build with:

arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I../../../grub-core -I.. -Wall -W -I../../../include -I../include -DGRUB_MACHINE_UBOOT=1 -DGRUB_MACHINE_ARM=1 -DGRUB_MACHINE=ARM_UBOOT -DGRUB_TARGET_CPU_ARM=1 -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -DGRUB_FILE=\"lib/arg.c\" -I. -I../../../grub-core -I.. -I../../.. -I../../../include -I../include -I../../../grub-core/lib/libgcrypt-grub/include -I../../../grub-core/lib/libgcrypt-grub/src/ -DGRUB_KERNEL=1 -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-ar

ith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -freg-struct-return -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -fno-stack-protector -mno-unaligned-access -Wtrampolines -Werror -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1 -mthumb-interwork -mlong-calls -ffreestanding -MT lib/kernel_exec-arg.o -MD -MP -MF lib/.deps-core/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o test -f 'lib/arg.c' || echo '../../../grub-core/'lib/arg.c

Quoted 4 lines

misc.S: Assembler messages:
misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4' make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

Quoted 5 lines
Quoted 2 lines

I don't think SP can be used that way in Thumb mode?

I think that our asm routines should be in full ARM. Attached patch follows this strategy. One remaining problem is to make sure that thumb flags in TARGET_CFLAGS and TARGET_CCASFLAGS match.

There should be no need for this - the only thing is to ensure the -mthumb-interwork is set in CCASFLAGS_PLATFORM as well as CFLAGS_PLATFORM, and even that is just to prevent linker warnings..

There is no special ARM_PROLOGUE needed, and (on armv5te onwards) pop {..., pc} is an interworking branch.

If we want to force a file to build as ARM (which I'm not sure is necessary now that we have split up armv6 separate from later architectures), all that is required is a .arm directive up top.

/
Leif

#3 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 5 lines · Leif Lindholm
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Colin Watson

After my previous fix, arm-uboot still fails to build with:

arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I../../../grub-core -I.. -Wall -W -I../../../include -I../include -DGRUB_MACHINE_UBOOT=1 -DGRUB_MACHINE_ARM=1 -DGRUB_MACHINE=ARM_UBOOT -DGRUB_TARGET_CPU_ARM=1 -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -DGRUB_FILE=\"lib/arg.c\" -I. -I../../../grub-core -I.. -I../../.. -I../../../include -I../include -I../../../grub-core/lib/libgcrypt-grub/include -I../../../grub-core/lib/libgcrypt-grub/src/ -DGRUB_KERNEL=1 -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-

ar

Quoted 15 lines
Quoted 10 lines

ith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -freg-struct-return -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -fno-stack-protector -mno-unaligned-access -Wtrampolines -Werror -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1 -mthumb-interwork -mlong-calls -ffreestanding -MT lib/kernel_exec-arg.o -MD -MP -MF lib/.deps-core/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o test -f 'lib/arg.c' || echo '../../../grub-core/'lib/arg.c

Quoted 6 lines

misc.S: Assembler messages:
misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4' make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

I think that our asm routines should be in full ARM. Attached patch follows this strategy. One remaining problem is to make sure that thumb flags in TARGET_CFLAGS and TARGET_CCASFLAGS match.

There should be no need for this - the only thing is to ensure the -mthumb-interwork is set in CCASFLAGS_PLATFORM as well as CFLAGS_PLATFORM, and even that is just to prevent linker warnings..

Quoted 7 lines

There is no special ARM_PROLOGUE needed, and (on armv5te onwards) pop {..., pc} is an interworking branch.

If we want to force a file to build as ARM (which I'm not sure is necessary now that we have split up armv6 separate from later architectures), all that is required is a .arm directive up top.

Hm. I'm confused. According to
http://stuff.mit.edu/afs/sipb/project/egcs/src/egcs/gcc/config/arm/README-interworking:
"Note that specifying -mthumb-interwork does result in slightly larger, slower code being produced. This is why interworking support must be specifically enabled by a switch."

#4 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 21 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 14 lines
Quoted 9 lines
Quoted 6 lines

misc.S: Assembler messages:
misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4' make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

I think that our asm routines should be in full ARM. Attached patch follows this strategy. One remaining problem is to make sure that thumb flags in TARGET_CFLAGS and TARGET_CCASFLAGS match.

There should be no need for this - the only thing is to ensure the -mthumb-interwork is set in CCASFLAGS_PLATFORM as well as CFLAGS_PLATFORM, and even that is just to prevent linker warnings..

Quoted 7 lines

There is no special ARM_PROLOGUE needed, and (on armv5te onwards) pop {..., pc} is an interworking branch.

If we want to force a file to build as ARM (which I'm not sure is necessary now that we have split up armv6 separate from later architectures), all that is required is a .arm directive up top.

Quoted 5 lines

Hm. I'm confused. According to
http://stuff.mit.edu/afs/sipb/project/egcs/src/egcs/gcc/config/arm/README-interworking:
"Note that specifying -mthumb-interwork does result in slightly larger, slower code being produced. This is why interworking support must be specifically enabled by a switch."

That is fairly outdated documentation (1998).
Yes, it was true before armv5te.

Since then, pop {pc} has been valid, so different code sequences are no longer required for state changes than for normal subroutine calls.

/
Leif

#5 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 22 lines · Leif Lindholm
Quoted 21 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 21 lines
Quoted 9 lines
Quoted 6 lines

misc.S: Assembler messages:
misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4' make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

I think that our asm routines should be in full ARM. Attached patch follows this strategy. One remaining problem is to make sure that thumb flags in TARGET_CFLAGS and TARGET_CCASFLAGS match.

There should be no need for this - the only thing is to ensure the -mthumb-interwork is set in CCASFLAGS_PLATFORM as well as CFLAGS_PLATFORM, and even that is just to prevent linker warnings..

There is no special ARM_PROLOGUE needed, and (on armv5te onwards) pop {..., pc} is an interworking branch.

If we want to force a file to build as ARM (which I'm not sure is necessary now that we have split up armv6 separate from later architectures), all that is required is a .arm directive up top.

Quoted 9 lines
Quoted 5 lines

Hm. I'm confused. According to
http://stuff.mit.edu/afs/sipb/project/egcs/src/egcs/gcc/config/arm/README-interworking:
"Note that specifying -mthumb-interwork does result in slightly larger, slower code being produced. This is why interworking support must be specifically enabled by a switch."

That is fairly outdated documentation (1998).
Yes, it was true before armv5te.

Hm, the qemu board easiest to test uboot with is versatile pb with arm926 with is armv5t. So no need to worry about this. So we require at least armv5 and arm support. Any boards outside of those resuirement which it makes any sense to support?

#6 lore raw

Re: arm-uboot: misc.S:56: Error: r13 not allowed here -- `sub sp, fp, #4'

Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines
Quoted 5 lines

Hm. I'm confused. According to
http://stuff.mit.edu/afs/sipb/project/egcs/src/egcs/gcc/config/arm/README-interworking:
"Note that specifying -mthumb-interwork does result in slightly larger, slower code being produced. This is why interworking support must be specifically enabled by a switch."

Quoted 7 lines
Quoted 3 lines

That is fairly outdated documentation (1998).
Yes, it was true before armv5te.

Hm, the qemu board easiest to test uboot with is versatile pb with arm926 with is armv5t. So no need to worry about this. So we require at least armv5 and arm support. Any boards outside of those resuirement which it makes any sense to support?

I wouldn't have thought so, but then I'm not exactly on the conservative side in that area. ARMv5 also includes things like the original Sheevaplug.

/
Leif

#7 lore raw
In reply to Colin Watson
Quoted 8 lines · Colin Watson

After my previous fix, arm-uboot still fails to build with:

  arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I../../../grub-core -I..  -Wall -W -I../../../include -I../include  -DGRUB_MACHINE_UBOOT=1 -DGRUB_MACHINE_ARM=1 -DGRUB_MACHINE=ARM_UBOOT -DGRUB_TARGET_CPU_ARM=1 -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/include -DGRUB_FILE=\"lib/arg.c\" -I. -I../../../grub-core -I.. -I../../.. -I../../../include -I../include -I../../../grub-core/lib/libgcrypt-grub/include -I../../../grub-core/lib/libgcrypt-grub/src/   -DGRUB_KERNEL=1   -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -freg-struct-return -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -fno-stack-protector -mno-unaligned-access -Wtrampolines -Werror -DUSE_ASCII_FALLBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1     -mthumb-interwork -mlong-calls -ffreestanding   -MT lib/kernel_exec-arg.o -MD -MP -MF lib/.deps-core/kernel_exec-arg.Tpo -c -o lib/kernel_exec-arg.o `test -f 'lib/arg.c' || echo '../../../grub-core/'`lib/arg.c
  misc.S: Assembler messages:
  misc.S:56: Error: r13 not allowed here -- `sub sp,fp,#4'
  make[3]: *** [kern/arm/kernel_exec-misc.o] Error 1

I don't think SP can be used that way in Thumb mode?

No, you would need to insert a
mov sp, fp
and then change to

    sub sp, sp, #4

/
Leif