[klibc] ARM/Thumb updates and some other minor tweaks

Andre armcc2000 at yahoo.com
Sun Feb 22 11:19:42 PST 2004


The attached patches are against the v0.114 release and cover some of
the tweaks I made while playing about testing ARM and Thumb support.
Please review and consider applying.

Even with the patches, ARM dynamic linking doesn't seem to work and
the Thumb test applications seem to have shaken out a Thumb bug in
the 2.4.21-rmk2 kernel which I'm still trying to track down. Still
more fun to be had it seems :-)

Andre
--

__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
-------------- next part --------------
diff -ruN klibc-0.114_orig/klibc/arch/i386/libgcc/__muldi3.S klibc-0.114/klibc/arch/i386/libgcc/__muldi3.S
--- klibc-0.114_orig/klibc/arch/i386/libgcc/__muldi3.S	2002-08-27 16:04:29.000000000 -0700
+++ klibc-0.114/klibc/arch/i386/libgcc/__muldi3.S	2004-02-22 04:39:00.000000000 -0800
@@ -1,7 +1,7 @@
 /*
  * arch/i386/libgcc/__muldi3.S
  *
- * 64*64 = 64 bit unsigned multiplication
+ * 64*64 = 64 bit signed multiplication
  */
 
 	.text
diff -ruN klibc-0.114_orig/klibc/libgcc/__divdi3.c klibc-0.114/klibc/libgcc/__divdi3.c
--- klibc-0.114_orig/klibc/libgcc/__divdi3.c	2002-08-27 22:16:15.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__divdi3.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * arch/i386/libgcc/__divdi3.c
+ * libgcc/__divdi3.c
  */
 
 #include <stdint.h>
diff -ruN klibc-0.114_orig/klibc/libgcc/__moddi3.c klibc-0.114/klibc/libgcc/__moddi3.c
--- klibc-0.114_orig/klibc/libgcc/__moddi3.c	2002-08-27 22:16:15.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__moddi3.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * arch/i386/libgcc/__moddi3.c
+ * libgcc/__moddi3.c
  */
 
 #include <stdint.h>
diff -ruN klibc-0.114_orig/klibc/libgcc/__udivdi3.c klibc-0.114/klibc/libgcc/__udivdi3.c
--- klibc-0.114_orig/klibc/libgcc/__udivdi3.c	2002-08-27 22:16:15.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__udivdi3.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * arch/i386/libgcc/__divdi3.c
+ * libgcc/__udivdi3.c
  */
 
 #include <stdint.h>
diff -ruN klibc-0.114_orig/klibc/libgcc/__udivmoddi4.c klibc-0.114/klibc/libgcc/__udivmoddi4.c
--- klibc-0.114_orig/klibc/libgcc/__udivmoddi4.c	2002-08-27 22:16:15.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__udivmoddi4.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,3 +1,7 @@
+/*
+ * libgcc/__udivmoddi4.c
+ */
+
 #include <klibc/diverr.h>
 #include <stdint.h>
 
diff -ruN klibc-0.114_orig/klibc/libgcc/__udivmodsi4.c klibc-0.114/klibc/libgcc/__udivmodsi4.c
--- klibc-0.114_orig/klibc/libgcc/__udivmodsi4.c	2002-09-16 09:45:47.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__udivmodsi4.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,3 +1,7 @@
+/*
+ * libgcc/__udivmodsi4.c
+ */
+
 #include <klibc/diverr.h>
 #include <stdint.h>
 
diff -ruN klibc-0.114_orig/klibc/libgcc/__udivsi3.c klibc-0.114/klibc/libgcc/__udivsi3.c
--- klibc-0.114_orig/klibc/libgcc/__udivsi3.c	2002-09-16 09:45:47.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__udivsi3.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * libgcc/__divsi3.c
+ * libgcc/__udivsi3.c
  */
 
 #include <stdint.h>
diff -ruN klibc-0.114_orig/klibc/libgcc/__umoddi3.c klibc-0.114/klibc/libgcc/__umoddi3.c
--- klibc-0.114_orig/klibc/libgcc/__umoddi3.c	2002-08-27 22:16:15.000000000 -0700
+++ klibc-0.114/klibc/libgcc/__umoddi3.c	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * arch/i386/libgcc/__umoddi3.c
+ * libgcc/__umoddi3.c
  */
 
 #include <stdint.h>
-------------- next part --------------
diff -ruN klibc-0.114_orig/klibc/arch/arm/crt0.S klibc-0.114/klibc/arch/arm/crt0.S
--- klibc-0.114_orig/klibc/arch/arm/crt0.S	2002-08-23 16:11:01.000000000 -0700
+++ klibc-0.114/klibc/arch/arm/crt0.S	2004-02-22 04:39:00.000000000 -0800
@@ -10,7 +10,7 @@
 #
 
 	.text
-	.align 4
+	.align 2		@ For ARM, align means align on a 2^n boundary
 	.type _start,#function
 	.globl _start
 
diff -ruN klibc-0.114_orig/klibc/arch/arm/setjmp-arm.S klibc-0.114/klibc/arch/arm/setjmp-arm.S
--- klibc-0.114_orig/klibc/arch/arm/setjmp-arm.S	2002-08-21 07:12:10.000000000 -0700
+++ klibc-0.114/klibc/arch/arm/setjmp-arm.S	2004-02-22 04:39:00.000000000 -0800
@@ -1,5 +1,5 @@
 #
-# arch/arm/setjmp.S
+# arch/arm/setjmp-arm.S
 #
 # setjmp/longjmp for the ARM architecture
 #
@@ -19,7 +19,7 @@
 #
 
 	.text
-	.align 4
+	.align 2		@ For ARM, align means align on a 2^n boundary
 	.globl setjmp
 	.type setjmp, #function
 setjmp:
@@ -29,7 +29,7 @@
 	.size setjmp,.-setjmp
 
 	.text
-	.align 4
+	.align 2		@ For ARM, align means align on a 2^n boundary
 	.globl longjmp
 	.type longjmp, #function
 longjmp:
diff -ruN klibc-0.114_orig/klibc/arch/arm/setjmp-thumb.S klibc-0.114/klibc/arch/arm/setjmp-thumb.S
--- klibc-0.114_orig/klibc/arch/arm/setjmp-thumb.S	2002-08-21 07:12:10.000000000 -0700
+++ klibc-0.114/klibc/arch/arm/setjmp-thumb.S	2004-02-22 04:39:00.000000000 -0800
@@ -19,7 +19,7 @@
 #
 
 	.text
-	.align 4
+	.align 1		@ For ARM, align means align on a 2^n boundary
 	.globl setjmp
 	.type setjmp, #function
 	.thumb_func
@@ -37,7 +37,7 @@
 	.size setjmp,.-setjmp
 
 	.text
-	.align 4
+	.align 1		@ For ARM, align means align on a 2^n boundary
 	.globl longjmp
 	.type longjmp, #function
 	.thumb_func
diff -ruN klibc-0.114_orig/klibc/include/sys/types.h klibc-0.114/klibc/include/sys/types.h
--- klibc-0.114_orig/klibc/include/sys/types.h	2004-02-08 22:19:37.000000000 -0800
+++ klibc-0.114/klibc/include/sys/types.h	2004-02-22 04:39:00.000000000 -0800
@@ -27,7 +27,12 @@
 typedef __kernel_daddr_t	daddr_t;
 typedef __kernel_key_t		key_t;
 typedef __kernel_suseconds_t	suseconds_t;
-typedef __kernel_timer_t	timer_t;
+/*
+ * __kernel_timer_t is not defined in arm kernel 2.4.21-rmk2 which causes
+ * arm klibc builds to fail. timer_t doesn't seem to be used within klibc
+ * so commenting out the typedef seems like a valid fix ?
+ */
+//typedef __kernel_timer_t	timer_t;
 
 typedef __kernel_uid32_t	uid_t;
 typedef __kernel_gid32_t	gid_t;
diff -ruN klibc-0.114_orig/klibc/strntoumax.c klibc-0.114/klibc/strntoumax.c
--- klibc-0.114_orig/klibc/strntoumax.c	2002-08-09 19:25:24.000000000 -0700
+++ klibc-0.114/klibc/strntoumax.c	2004-02-22 04:39:00.000000000 -0800
@@ -10,15 +10,12 @@
 
 static inline int digitval(int ch)
 {
-  if ( ch >= '0' && ch <= '9' ) {
-    return ch-'0';
-  } else if ( ch >= 'A' && ch <= 'Z' ) {
-    return ch-'A'+10;
-  } else if ( ch >= 'a' && ch <= 'z' ) {
-    return ch-'a'+10;
-  } else {
-    return -1;
-  }
+  if (ch >= '0' && ch <= '9')
+    return (ch - '0');
+  ch |= 0x20;
+  if (ch >= 'a' && ch <= 'f')
+    return (ch - 'a' + 10);
+  return -1;
 }
 
 uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
diff -ruN klibc-0.114_orig/klibc/tests/hello.c klibc-0.114/klibc/tests/hello.c
--- klibc-0.114_orig/klibc/tests/hello.c	2002-08-12 20:58:57.000000000 -0700
+++ klibc-0.114/klibc/tests/hello.c	2004-02-22 04:39:00.000000000 -0800
@@ -2,6 +2,10 @@
 
 int main(void)
 {
-  printf("Hello, World!\n");
+  /*
+   * For a fair test, we need to call printf() with a format string,
+   * otherwise gcc will optimise printf() into puts()
+   */
+  printf("%s", "Hello, World!\n");
   return 0;
 }
-------------- next part --------------
diff -ruN klibc-0.114_orig/klibc/arch/arm/Makefile.inc klibc-0.114/klibc/arch/arm/Makefile.inc
--- klibc-0.114_orig/klibc/arch/arm/Makefile.inc	2002-09-16 09:47:55.000000000 -0700
+++ klibc-0.114/klibc/arch/arm/Makefile.inc	2004-02-22 06:35:37.000000000 -0800
@@ -8,6 +8,7 @@
 #
 
 ARCHOBJS = \
+	arch/arm/exits.o \
 	libgcc/__divsi3.o \
 	libgcc/__modsi3.o \
 	libgcc/__udivsi3.o \
@@ -17,10 +18,28 @@
 	libgcc/__moddi3.o \
 	libgcc/__udivdi3.o \
 	libgcc/__umoddi3.o \
-	libgcc/__udivmoddi4.o
+	libgcc/__udivmoddi4.o \
+	arch/arm/libgcc/__muldi3.o
+
+THUMBOBJS = \
+	arch/arm/libgcc/_call_via_r0.o \
+	arch/arm/libgcc/_call_via_r1.o \
+	arch/arm/libgcc/_call_via_r2.o \
+	arch/arm/libgcc/_call_via_r3.o \
+	arch/arm/libgcc/_call_via_r4.o \
+	arch/arm/libgcc/_call_via_r5.o \
+	arch/arm/libgcc/_call_via_r6.o \
+	arch/arm/libgcc/_call_via_r7.o \
+	arch/arm/libgcc/_call_via_r8.o \
+	arch/arm/libgcc/_call_via_r9.o \
+	arch/arm/libgcc/_call_via_sl.o \
+	arch/arm/libgcc/_call_via_fp.o \
+	arch/arm/libgcc/_call_via_ip.o \
+	arch/arm/libgcc/_call_via_sp.o \
+	arch/arm/libgcc/_call_via_lr.o
 
 ifeq ($(THUMB),y)
-ARCHOBJS += arch/arm/setjmp-thumb.o
+ARCHOBJS += arch/arm/setjmp-thumb.o $(THUMBOBJS)
 LIBGCC   =
 else
 ARCHOBJS += arch/arm/setjmp-arm.o
diff -ruN klibc-0.114_orig/klibc/arch/arm/exits.S klibc-0.114/klibc/arch/arm/exits.S
--- klibc-0.114_orig/klibc/arch/arm/exits.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/exits.S	2004-02-22 07:03:58.000000000 -0800
@@ -0,0 +1,54 @@
+#
+# arch/arm/exit.S
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them.  Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+	.data
+	.align	2		@ For ARM, align means align on a 2^n boundary
+	.globl	__exit_handler
+	.type	__exit_handler,object
+	
+__exit_handler:
+	.word	_exit
+	.size	__exit_handler,4
+
+
+	.text
+	.align	2		@ For ARM, align means align on a 2^n boundary
+	.globl	exit
+	.type	exit,function
+	.globl	_exit
+	.type	_exit,function
+
+#ifdef __thumb__
+
+	.thumb_func
+exit:
+	ldr	r1, =__exit_handler
+	ldr	r1, [r1, #0]
+	bx	r1
+	.size	exit,.-exit
+
+	.thumb_func
+_exit:
+	mov	r7, #__NR_exit
+	swi	0
+	.size	exit,.-_exit
+
+#else
+
+exit:
+	ldr	r1, =__exit_handler
+	ldr	pc, [r1, #0]
+	.size	exit,.-exit
+
+_exit:
+	swi	$__NR_exit
+	.size	exit,.-_exit
+
+#endif
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/__muldi3.S klibc-0.114/klibc/arch/arm/libgcc/__muldi3.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/__muldi3.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/__muldi3.S	2004-02-22 04:39:00.000000000 -0800
@@ -0,0 +1,51 @@
+#
+# arch/arm/libgcc/__muldi3.S
+#
+# 64*64 = 64 bit signed multiplication
+#
+# This is smaller and faster in ARM mode so use arm code for the inner guts
+# even if we are compiling for Thumb.
+#
+# Fixme: umull is not supported by pre ARM7TDMI cores.
+#        For these we need an alternative (eg __muldi3 code from kernel)
+#
+
+	.text
+	.align  2		@ For ARM, align means align on a 2^n boundary
+	.globl  __muldi3
+	.type 	__muldi3,function
+
+#ifdef __thumb__
+	.thumb_func
+#endif
+
+__muldi3:
+
+#ifdef __thumb__
+	bx	pc
+	nop
+#endif
+
+	.code 	32			@ remining instructions are ARM mode
+
+	stmdb	sp!, { r4, lr } 	@ preserve 8 byte stack alignment
+#ifdef __ARMEB__
+	mov	lr, r1
+	umull	r1, r12, r3, lr
+	mla	r0, r3, r0, r12
+	mla	r0, r2, lr, r0
+#else
+	mov	lr, r0
+	umull	r0, r12, r2, lr
+	mla	r1, r2, r1, r12
+	mla	r1, r3, lr, r1
+#endif
+#ifdef __thumb__
+	ldmia	sp!, { r4, lr }
+	bx	lr			@ back to Thumb mode
+#else
+	ldmia	sp!, { r4, pc }
+#endif
+
+	.size __muldi3,.-__muldi3
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_fp.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_fp.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_fp.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_fp.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_fp.S
+#
+# Thumb mode helper to call a function pointer held in fp
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_fp
+	.type	_call_via_fp,function
+	.thumb_func
+
+_call_via_fp:
+	bx	fp
+	.size	_call_via_fp,.-_call_via_fp
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_ip.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_ip.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_ip.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_ip.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_ip.S
+#
+# Thumb mode helper to call a function pointer held in ip
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_ip
+	.type	_call_via_ip,function
+	.thumb_func
+
+_call_via_ip:
+	bx	ip
+	.size	_call_via_ip,.-_call_via_ip
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_lr.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_lr.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_lr.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_lr.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_lr.S
+#
+# Thumb mode helper to call a function pointer held in lr
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_lr
+	.type	_call_via_lr,function
+	.thumb_func
+
+_call_via_lr:
+	bx	lr
+	.size	_call_via_lr,.-_call_via_lr
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r0.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r0.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r0.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r0.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r0.S
+#
+# Thumb mode helper to call a function pointer held in r0
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r0
+	.type	_call_via_r0,function
+	.thumb_func
+
+_call_via_r0:
+	bx	r0
+	.size	_call_via_r0,.-_call_via_r0
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r1.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r1.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r1.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r1.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r1.S
+#
+# Thumb mode helper to call a function pointer held in r1
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r1
+	.type	_call_via_r1,function
+	.thumb_func
+
+_call_via_r1:
+	bx	r1
+	.size	_call_via_r1,.-_call_via_r1
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r2.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r2.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r2.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r2.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r2.S
+#
+# Thumb mode helper to call a function pointer held in r2
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r2
+	.type	_call_via_r2,function
+	.thumb_func
+
+_call_via_r2:
+	bx	r2
+	.size	_call_via_r2,.-_call_via_r2
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r3.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r3.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r3.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r3.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r3.S
+#
+# Thumb mode helper to call a function pointer held in r3
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r3
+	.type	_call_via_r3,function
+	.thumb_func
+
+_call_via_r3:
+	bx	r3
+	.size	_call_via_r3,.-_call_via_r3
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r4.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r4.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r4.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r4.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r4.S
+#
+# Thumb mode helper to call a function pointer held in r4
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r4
+	.type	_call_via_r4,function
+	.thumb_func
+
+_call_via_r4:
+	bx	r4
+	.size	_call_via_r4,.-_call_via_r4
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r5.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r5.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r5.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r5.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r5.S
+#
+# Thumb mode helper to call a function pointer held in r5
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r5
+	.type	_call_via_r5,function
+	.thumb_func
+
+_call_via_r5:
+	bx	r5
+	.size	_call_via_r5,.-_call_via_r5
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r6.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r6.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r6.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r6.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r6.S
+#
+# Thumb mode helper to call a function pointer held in r6
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r6
+	.type	_call_via_r6,function
+	.thumb_func
+
+_call_via_r6:
+	bx	r6
+	.size	_call_via_r6,.-_call_via_r6
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r7.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r7.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r7.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r7.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r7.S
+#
+# Thumb mode helper to call a function pointer held in r7
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r7
+	.type	_call_via_r7,function
+	.thumb_func
+
+_call_via_r7:
+	bx	r7
+	.size	_call_via_r7,.-_call_via_r7
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r8.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r8.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r8.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r8.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r8.S
+#
+# Thumb mode helper to call a function pointer held in r8
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r8
+	.type	_call_via_r8,function
+	.thumb_func
+
+_call_via_r8:
+	bx	r8
+	.size	_call_via_r8,.-_call_via_r8
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r9.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_r9.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_r9.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_r9.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_r9.S
+#
+# Thumb mode helper to call a function pointer held in r9
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_r9
+	.type	_call_via_r9,function
+	.thumb_func
+
+_call_via_r9:
+	bx	r9
+	.size	_call_via_r9,.-_call_via_r9
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_sl.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_sl.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_sl.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_sl.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_sl.S
+#
+# Thumb mode helper to call a function pointer held in sl
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_sl
+	.type	_call_via_sl,function
+	.thumb_func
+
+_call_via_sl:
+	bx	sl
+	.size	_call_via_sl,.-_call_via_sl
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_sp.S klibc-0.114/klibc/arch/arm/libgcc/_call_via_sp.S
--- klibc-0.114_orig/klibc/arch/arm/libgcc/_call_via_sp.S	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/_call_via_sp.S	2004-02-22 04:42:13.000000000 -0800
@@ -0,0 +1,16 @@
+#
+# arch/arm/libgcc/_call_via_sp.S
+#
+# Thumb mode helper to call a function pointer held in sp
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_sp
+	.type	_call_via_sp,function
+	.thumb_func
+
+_call_via_sp:
+	bx	sp
+	.size	_call_via_sp,.-_call_via_sp
+
diff -ruN klibc-0.114_orig/klibc/arch/arm/libgcc/generate_call_via_rX.sh klibc-0.114/klibc/arch/arm/libgcc/generate_call_via_rX.sh
--- klibc-0.114_orig/klibc/arch/arm/libgcc/generate_call_via_rX.sh	1969-12-31 16:00:00.000000000 -0800
+++ klibc-0.114/klibc/arch/arm/libgcc/generate_call_via_rX.sh	2004-02-22 04:41:24.000000000 -0800
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Although each _call_via_rX function is only a single instruction, most
+# are never needed. Therefore we can save some bytes by putting each in its
+# own object file. This script eases the pain if changes are needed :-)
+#
+
+cat << 'EOF' > _call_via_rX.S
+#
+# arch/arm/libgcc/_call_via_rX.S
+#
+# Thumb mode helper to call a function pointer held in rX
+#
+
+	.text
+	.align	1		@ For ARM, align means align on a 2^n boundary
+	.globl	_call_via_rX
+	.type	_call_via_rX,function
+	.thumb_func
+
+_call_via_rX:
+	bx	rX
+	.size	_call_via_rX,.-_call_via_rX
+
+EOF
+
+for reg in r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 sl fp ip sp lr
+do
+	sed "s/rX/$reg/g" < _call_via_rX.S > _call_via_$reg.S
+done
+
+rm _call_via_rX.S
diff -ruN klibc-0.114_orig/klibc/exitc.c klibc-0.114/klibc/exitc.c
--- klibc-0.114_orig/klibc/exitc.c	2002-08-12 15:48:08.000000000 -0700
+++ klibc-0.114/klibc/exitc.c	2004-02-22 06:51:56.000000000 -0800
@@ -1,5 +1,5 @@
 /*
- * exit.c
+ * exitc.c
  *
  * Note: all programs need exit(), since it's invoked from
  * crt0.o.  Therefore there is no point in breaking apart
@@ -10,9 +10,10 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 
-/* We have an assembly version for i386 and x86-64 */
+/* We have assembly versions for i386, x86-64 and ARM/Thumb */
 
-#if !defined(__i386__) && !defined(__x86_64__)
+#if !defined(__i386__) && !defined(__x86_64__) && \
+    !defined(__arm__) && !defined(__thumb__)
 
 #define __NR___exit __NR_exit
 


More information about the klibc mailing list