This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[csl-arm] libgcc interworking
- From: Paul Brook <paul at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 30 Apr 2005 17:57:03 +0100
- Subject: [csl-arm] libgcc interworking
The attached patch fixes building libgcc with -march=armv4t -mthumb
-mthumb-interwork. Previously we were incorrectly using .set to create
aliased for thumb routines.
Tested with cross to arm-none-eabi
Applied to csl-arm-branch.
Paul
2005-04-30 Paul Brook <paul@codesourcery.com>
* config/arm/bpabi.h (RENAME_LIBRARY_SET): Always use .thumb_set in
thumb mode.
* config/arm/ieee754-df.S: Use __INTERWORKING_STUBS__.
* config/arm/ieee754-sf.S: Ditto.
* config/arm/lib1funcs.asm: Define and use __INTERWORKING_STUBS__.
(FUNC_ALIAS): New macro.
Index: gcc/config/arm/bpabi.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/bpabi.h,v
retrieving revision 1.1.4.11
diff -u -p -r1.1.4.11 bpabi.h
--- gcc/config/arm/bpabi.h 23 Nov 2004 22:14:11 -0000 1.1.4.11
+++ gcc/config/arm/bpabi.h 30 Apr 2005 12:30:43 -0000
@@ -50,7 +54,7 @@
"%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} " \
"-X"
-#if defined (__thumb__) && !defined (__THUMB_INTERWORK__)
+#if defined (__thumb__)
#define RENAME_LIBRARY_SET ".thumb_set"
#else
#define RENAME_LIBRARY_SET ".set"
Index: gcc/config/arm/ieee754-df.S
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/ieee754-df.S,v
retrieving revision 1.3.10.4
diff -u -p -r1.3.10.4 ieee754-df.S
--- gcc/config/arm/ieee754-df.S 7 Sep 2004 17:19:20 -0000 1.3.10.4
+++ gcc/config/arm/ieee754-df.S 30 Apr 2005 12:40:42 -0000
@@ -80,7 +80,7 @@ ARM_FUNC_START aeabi_drsub
ARM_FUNC_ALIAS aeabi_dsub subdf3
@ flip sign bit of second arg
eor yh, yh, #0x80000000
-#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+#if defined(__INTERWORKING_STUBS__)
b 1f @ Skip Thumb-code prologue
#endif
Index: gcc/config/arm/ieee754-sf.S
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/ieee754-sf.S,v
retrieving revision 1.3.10.3
diff -u -p -r1.3.10.3 ieee754-sf.S
--- gcc/config/arm/ieee754-sf.S 7 Sep 2004 17:19:20 -0000 1.3.10.3
+++ gcc/config/arm/ieee754-sf.S 30 Apr 2005 12:41:15 -0000
@@ -62,7 +62,7 @@ ARM_FUNC_START subsf3
ARM_FUNC_ALIAS aeabi_fsub subsf3
eor r1, r1, #0x80000000 @ flip sign bit of second arg
-#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+#if defined(__INTERWORKING_STUBS__)
b 1f @ Skip Thumb-code prologue
#endif
Index: gcc/config/arm/lib1funcs.asm
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/lib1funcs.asm,v
retrieving revision 1.26.4.12
diff -u -p -r1.26.4.12 lib1funcs.asm
--- gcc/config/arm/lib1funcs.asm 14 Mar 2005 13:38:52 -0000 1.26.4.12
+++ gcc/config/arm/lib1funcs.asm 30 Apr 2005 13:30:19 -0000
@@ -94,10 +94,20 @@ Boston, MA 02111-1307, USA. */
# define RET bx lr
# define RETc(x) bx##x lr
-# if (__ARM_ARCH__ == 4) \
- && (defined(__thumb__) || defined(__THUMB_INTERWORK__))
-# define __INTERWORKING__
-# endif
+/* Special precautions for interworking on armv4t. */
+# if (__ARM_ARCH__ == 4)
+
+/* Always use bx, not ldr pc. */
+# if (defined(__thumb__) || defined(__THUMB_INTERWORK__))
+# define __INTERWORKING__
+# endif /* __THUMB__ || __THUMB_INTERWORK__ */
+
+/* Include thumb stub before arm mode code. */
+# if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+# define __INTERWORKING_STUBS__
+# endif /* __thumb__ && !__THUMB_INTERWORK__ */
+
+#endif /* __ARM_ARCH == 4 */
#else
@@ -192,7 +202,7 @@ SYM (__\name):
/* Special function that will always be coded in ARM assembly, even if
in Thumb-only compilation. */
-#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+#if defined(__INTERWORKING_STUBS__)
.macro ARM_FUNC_START name
FUNC_START \name
bx pc
@@ -226,11 +236,20 @@ SYM (__\name):
.macro ARM_FUNC_ALIAS new old
.globl SYM (__\new)
EQUIV SYM (__\new), SYM (__\old)
-#ifdef __thumb__
+#if defined(__INTERWORKING_STUBS__)
.set SYM (_L__\new), SYM (_L__\old)
#endif
.endm
+.macro FUNC_ALIAS new old
+ .globl SYM (__\new)
+#if defined (__thumb__)
+ .thumb_set SYM (__\new), SYM (__\old)
+#else
+ .set SYM (__\new), SYM (__\old)
+#endif
+.endm
+
#ifdef __thumb__
/* Register aliases. */
@@ -885,8 +904,8 @@ LSYM(Lover12):
#ifdef L_dvmd_tls
FUNC_START div0
- ARM_FUNC_ALIAS aeabi_idiv0 div0
- ARM_FUNC_ALIAS aeabi_ldiv0 div0
+ FUNC_ALIAS aeabi_idiv0 div0
+ FUNC_ALIAS aeabi_ldiv0 div0
RET
@@ -942,7 +961,7 @@ LSYM(Lover12):
#ifdef L_lshrdi3
FUNC_START lshrdi3
- ARM_FUNC_ALIAS aeabi_llsr lshrdi3
+ FUNC_ALIAS aeabi_llsr lshrdi3
#ifdef __thumb__
lsr al, r2
@@ -974,7 +993,7 @@ LSYM(Lover12):
#ifdef L_ashrdi3
FUNC_START ashrdi3
- ARM_FUNC_ALIAS aeabi_lasr ashrdi3
+ FUNC_ALIAS aeabi_lasr ashrdi3
#ifdef __thumb__
lsr al, r2
@@ -1011,7 +1030,7 @@ LSYM(Lover12):
#ifdef L_ashldi3
FUNC_START ashldi3
- ARM_FUNC_ALIAS aeabi_llsl ashldi3
+ FUNC_ALIAS aeabi_llsl ashldi3
#ifdef __thumb__
lsl ah, r2