This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Automatically mark Thumb functions.


The attached patch makes gas mark ELF function symbols as being Thumb symbols 
based on the current mode, rather than relying on .thumb_func directives.
The motivation for this is that unified assembly mode allows the same source 
to be assembled as both arm and thumb. This is rather less useful if 
functions require additional annotations in Thumb mode.

For full backwards compatibility I guess the automatic annotation would only 
apply in unified mode.  However I can't think of any reason to preserve the 
old behavior, and it's simpler to be consistent between unified and legacy 
syntax.

Tested with cross to arm-none-eabi.
Ok?

Paul

2006-10-20  Paul Brook  <paul@codesourcery.com>

	gas/
	* config/tc-arm.c (arm_is_eabi): New function.
	* config/tc-arm.h (arm_is_eabi): New prototype.
	(THUMB_IS_FUNC): Use ELF function type for EABI objects.
	* doc/c-arm.texi (.thumb_func): Update documentation.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.37
diff -u -p -r1.250.2.37 tc-arm.c
--- gas/config/tc-arm.c	19 Sep 2006 18:44:37 -0000	1.250.2.37
+++ gas/config/tc-arm.c	18 Oct 2006 20:57:27 -0000
@@ -238,6 +240,12 @@ static int meabi_flags = EABI_DEFAULT;
 # else
 static int meabi_flags = EF_ARM_EABI_UNKNOWN;
 # endif
+
+bfd_boolean
+arm_is_eabi(void)
+{
+  return (EF_ARM_EABI_VERSION (meabi_flags) >= EF_ARM_EABI_VER4);
+}
 #endif
 
 #ifdef OBJ_ELF
Index: gas/config/tc-arm.h
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.h,v
retrieving revision 1.36.2.1
diff -u -p -r1.36.2.1 tc-arm.h
--- gas/config/tc-arm.h	1 May 2006 16:27:16 -0000	1.36.2.1
+++ gas/config/tc-arm.h	18 Oct 2006 17:58:25 -0000
@@ -98,6 +98,7 @@ extern int arm_optimize_expr (expression
 #ifdef OBJ_ELF
 #define md_end arm_md_end
 extern void arm_md_end (void);
+bfd_boolean arm_is_eabi (void);
 #endif
 
 /* NOTE: The fake label creation in stabs.c:s_stab_generic() has
@@ -120,7 +121,19 @@ extern void arm_md_end (void);
 
 #define ARM_IS_THUMB(s)		(ARM_GET_FLAG (s) & ARM_FLAG_THUMB)
 #define ARM_IS_INTERWORK(s)	(ARM_GET_FLAG (s) & ARM_FLAG_INTERWORK)
+#ifdef OBJ_ELF
+
+/* For ELF objects THUMB_IS_FUNC is inferred from
+   ARM_IS_TUMB and the function type.  */
+#define THUMB_IS_FUNC(s) \
+  ((arm_is_eabi () \
+    && (ARM_IS_THUMB (s)) \
+    && (symbol_get_bfdsym (s)->flags & BSF_FUNCTION)) \
+   || (ARM_GET_FLAG (s) & THUMB_FLAG_FUNC))
+
+#else
 #define THUMB_IS_FUNC(s)	(ARM_GET_FLAG (s) & THUMB_FLAG_FUNC)
+#endif
 
 #define ARM_SET_THUMB(s,t)      ((t) ? ARM_SET_FLAG (s, ARM_FLAG_THUMB)     : ARM_RESET_FLAG (s, ARM_FLAG_THUMB))
 #define ARM_SET_INTERWORK(s,t)  ((t) ? ARM_SET_FLAG (s, ARM_FLAG_INTERWORK) : ARM_RESET_FLAG (s, ARM_FLAG_INTERWORK))
Index: gas/doc/c-arm.texi
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/doc/c-arm.texi,v
retrieving revision 1.37.2.5
diff -u -p -r1.37.2.5 c-arm.texi
--- gas/doc/c-arm.texi	14 Sep 2006 22:33:48 -0000	1.37.2.5
+++ gas/doc/c-arm.texi	18 Oct 2006 23:45:32 -0000
@@ -458,6 +458,9 @@ between Arm and Thumb instructions and s
 interworking is not going to be performed.  The presence of this
 directive also implies @code{.thumb}
 
+This directive is not neccessary when generating EABI objects.  On these
+targets the encoding is implicit when generating Thumb code.
+
 @cindex @code{thumb_set} directive, ARM
 @item .thumb_set
 This performs the equivalent of a @code{.set} directive in that it

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]