[PATCH] ARM: Fix strcmp() for Thumb-1
Sebastian Huber
sebastian.huber@embedded-brains.de
Sun May 26 11:30:00 GMT 2013
The GCC multilib for ARMv4T is broken with the current strcmp()
implementation. GCC will pass no architecture flag to AS in case it
builds a multilib for -mthumb with no further architecture options. The
default architecture is ARMv4T in GCC. The usage of ".syntax unified"
instructs AS to produce output for the ARMv6T2 architecture. Thus we
have (readelf -A):
File: ./arm-rtems4.11/thumb/newlib/libc/machine/arm/lib_a-strcmp.o
Attribute Section: aeabi
File Attributes
Tag_CPU_arch: v6T2
Tag_THUMB_ISA_use: Thumb-2
The change suppresses ".syntax unified" for Thumb-1 and uses only
Thumb-1 instructions. This leads to:
File: ./arm-rtems4.11/thumb/newlib/libc/machine/arm/lib_a-strcmp.o
Attribute Section: aeabi
File Attributes
Tag_CPU_arch: v4T
Tag_THUMB_ISA_use: Thumb-1
newlib/ChangeLog
2013-05-26 Sebastian Huber <sebastian.huber@embedded-brains.de>
libc/machine/arm/strcmp.S: Fix Thumb-1 version.
---
newlib/libc/machine/arm/strcmp.S | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S
index 0a4057e..c6cb991 100644
--- a/newlib/libc/machine/arm/strcmp.S
+++ b/newlib/libc/machine/arm/strcmp.S
@@ -50,7 +50,9 @@
#define LSB 0x000000ff
#endif /* not __ARMEB__ */
+#if !(defined (__thumb__) && !defined (__thumb2__))
.syntax unified
+#endif
#if defined (__thumb__)
.thumb
@@ -64,14 +66,14 @@ strcmp:
1:
ldrb r2, [r0]
ldrb r3, [r1]
- adds r0, r0, #1
- adds r1, r1, #1
+ add r0, r0, #1
+ add r1, r1, #1
cmp r2, #0
beq 2f
cmp r2, r3
beq 1b
2:
- subs r0, r2, r3
+ sub r0, r2, r3
bx lr
#elif (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
1:
--
1.7.10.4
More information about the Newlib
mailing list