This is the mail archive of the 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] attribute((init_priority(N))) on ARM EABI.

The patch below implements attribute((init_priority(N))) on ARM EABI based 
targets. The EABI itself doesn't support constructor priorities.  However as 
this is a gcc extension it seems reasonable to have corresponding linker 
extensions to implement it.

Tested on arm-none-eabi.
This is a merge from branches/csl/sourcerygxx-4_1.
Applied to mainline.


2006-11-02  Paul Brook  <>

	* config/arm/arm.c (arm_elf_asm_constructor): Remove ATTRIBUTE_UNUSED
	from priority argument.  Use different section for non-default
	* config/arm/elf.h: Remove definition of SUPPORTS_INIT_PRIORITY.

Index: gcc/config/arm/elf.h
--- gcc/config/arm/elf.h	(revision 118417)
+++ gcc/config/arm/elf.h	(working copy)
@@ -149,5 +149,3 @@
     }							\
   while (0)
-/* The EABI doesn't provide a way of implementing init_priority.  */
Index: gcc/config/arm/arm.c
--- gcc/config/arm/arm.c	(revision 118417)
+++ gcc/config/arm/arm.c	(working copy)
@@ -11349,8 +11349,10 @@ arm_assemble_integer (rtx x, unsigned in
 /* Add a function to the list of static constructors.  */
 static void
-arm_elf_asm_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
+arm_elf_asm_constructor (rtx symbol, int priority)
+  section *s;
       default_named_section_asm_out_constructor (symbol, priority);
@@ -11358,7 +11360,16 @@ arm_elf_asm_constructor (rtx symbol, int
   /* Put these in the .init_array section, using a special relocation.  */
-  switch_to_section (ctors_section);
+  if (priority != DEFAULT_INIT_PRIORITY)
+    {
+      char buf[18];
+      sprintf (buf, ".init_array.%.5u", priority);
+      s = get_section (buf, SECTION_WRITE, NULL_TREE);
+    }
+  else
+    s = ctors_section;
+  switch_to_section (s);
   assemble_align (POINTER_SIZE);
   fputs ("\t.word\t", asm_out_file);
   output_addr_const (asm_out_file, symbol);

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