This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

ARM EABI wchar_t markings


The attached patch ensures that ARM EABI objects are marked with the correct 
wchar_t size attributes.  The problem is that WCHAR_TYPE_SIZE only specifies 
the default size, and may be overridden with -fshort-wchar. It's necessary to 
poke at the frontend types to find the correct size.

The C specific bits of the backend are initialized by REGISTER_TARGET_PRAGMAS. 
This is a hack, but one already used by other targets.

Tested on arm-non-eabi.
I will apply to SVN head once we're out of lockdown.

Paul

2007-06-20  Paul Brook  <paul@codesourcery.com>

	gcc/
	* config.gcc (arm*-*-*): Set c_target_objs and cxx_target_objs.
	* config/arm/arm.c (arm_lang_output_object_attributes_hook): New.
	(arm_file_start): Don't set Tag_ABI_PCS_wchar_t.  Call
	arm_lang_output_object_attributes_hook.
	* config/arm/arm.h (arm_lang_output_object_attributes_hook): Declare.
	(REGISTER_TARGET_PRAGMAS): Call arm_lang_object_attributes_init.
	* config/arm/arm-protos.h (arm_lang_object_attributes_init): Add
	prototype.
	* config/arm/t-arm.c (arm.o): New rule.
	* config/arm/arm-c.c: New file.
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 125884)
+++ gcc/config.gcc	(working copy)
@@ -256,6 +256,8 @@ strongarm*-*-*)
 arm*-*-*)
 	cpu_type=arm
 	extra_headers="mmintrin.h"
+	c_target_objs="arm-c.o"
+	cxx_target_objs="arm-c.o"
 	;;
 bfin*-*)
 	cpu_type=bfin
@@ -767,6 +769,7 @@ arm*-*-eabi* | arm*-*-symbianelf* )
 	tmake_file="arm/t-arm arm/t-arm-elf"
 	case ${target} in
 	arm*-*-eabi*)
+	  tm_file="${tm_file} arm/nocrt0.h"
 	  tmake_file="${tmake_file} arm/t-bpabi"
 	  ;;
 	arm*-*-symbianelf*)
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 125884)
+++ gcc/config/arm/arm.c	(working copy)
@@ -60,6 +60,8 @@ typedef struct minipool_fixup   Mfix;
 
 const struct attribute_spec arm_attribute_table[];
 
+void (*arm_lang_output_object_attributes_hook)(void);
+
 /* Forward function declarations.  */
 static arm_stack_offsets *arm_get_frame_offsets (void);
 static void arm_add_gc_roots (void);
@@ -15302,10 +15304,6 @@ arm_file_start (void)
          are used.  However we don't have any easy way of figuring this out.
 	 Conservatively record the setting that would have been used.  */
 
-      /* Tag_ABI_PCS_wchar_t.  */
-      asm_fprintf (asm_out_file, "\t.eabi_attribute 18, %d\n",
-		   (int)WCHAR_TYPE_SIZE / BITS_PER_UNIT);
-
       /* Tag_ABI_FP_rounding.  */
       if (flag_rounding_math)
 	asm_fprintf (asm_out_file, "\t.eabi_attribute 19, 1\n");
@@ -15341,6 +15339,9 @@ arm_file_start (void)
       else
 	val = 6;
       asm_fprintf (asm_out_file, "\t.eabi_attribute 30, %d\n", val);
+
+      if (arm_lang_output_object_attributes_hook)
+	arm_lang_output_object_attributes_hook();
     }
   default_file_start();
 }
Index: gcc/config/arm/arm.h
===================================================================
--- gcc/config/arm/arm.h	(revision 125884)
+++ gcc/config/arm/arm.h	(working copy)
@@ -132,6 +132,8 @@ extern rtx pool_vector_label;
 extern int return_used_this_function;
 /* Used to produce AOF syntax assembler.  */
 extern GTY(()) rtx aof_pic_label;
+/* Callback to output language specific object attributes.  */
+extern void (*arm_lang_output_object_attributes_hook)(void);
 
 /* Just in case configure has failed to define anything.  */
 #ifndef TARGET_CPU_DEFAULT
@@ -2185,10 +2187,12 @@ extern unsigned arm_pic_register;
 extern int making_const_table;
 
 /* Handle pragmas for compatibility with Intel's compilers.  */
+/* Also abuse this to register additional C specific EABI attributes.  */
 #define REGISTER_TARGET_PRAGMAS() do {					\
   c_register_pragma (0, "long_calls", arm_pr_long_calls);		\
   c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls);		\
   c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off);	\
+  arm_lang_object_attributes_init(); \
 } while (0)
 
 /* Condition code information.  */
Index: gcc/config/arm/arm-protos.h
===================================================================
--- gcc/config/arm/arm-protos.h	(revision 125884)
+++ gcc/config/arm/arm-protos.h	(working copy)
@@ -192,4 +192,6 @@ extern void arm_pr_long_calls (struct cp
 extern void arm_pr_no_long_calls (struct cpp_reader *);
 extern void arm_pr_long_calls_off (struct cpp_reader *);
 
+extern void arm_lang_object_attributes_init(void);
+
 #endif /* ! GCC_ARM_PROTOS_H */
Index: gcc/config/arm/arm-c.c
===================================================================
--- gcc/config/arm/arm-c.c	(revision 0)
+++ gcc/config/arm/arm-c.c	(revision 0)
@@ -0,0 +1,27 @@
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tm_p.h"
+#include "tree.h"
+#include "output.h"
+#include "c-common.h"
+
+
+/* Output C specific EABI object attributes.  These can not be done in
+   arm.c because they require information from the C frontend.  */
+
+static void arm_output_c_attributes(void)
+{
+  /* Tag_ABI_PCS_wchar_t.  */
+  asm_fprintf (asm_out_file, "\t.eabi_attribute 18, %d\n",
+	       (int)(TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT));
+}
+
+
+/* Setup so that common code calls arm_output_c_attributes.  */
+
+void arm_lang_object_attributes_init(void)
+{
+  arm_lang_output_object_attributes_hook = arm_output_c_attributes;
+}
Index: gcc/config/arm/t-arm
===================================================================
--- gcc/config/arm/t-arm	(revision 125884)
+++ gcc/config/arm/t-arm	(working copy)
@@ -21,3 +21,8 @@ $(srcdir)/config/arm/arm-tune.md: $(srcd
 	$(SHELL) $(srcdir)/config/arm/gentune.sh \
 		$(srcdir)/config/arm/arm-cores.def > \
 		$(srcdir)/config/arm/arm-tune.md
+
+arm-c.o: $(srcdir)/config/arm/arm-c.c $(CONFIG_H) $(SYSTEM_H) \
+    coretypes.h $(TM_H) $(TREE_H) output.h $(C_COMMON_H)
+	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/arm/arm-c.c
+

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