+2007-03-20 Mark Mitchell <mark@codesourcery.com>
+
+ * config/arm/elf.h (TARGET_ASM_DESTRUCTOR): Define.
+ * config/arm/arm.c (arm_elf_asm_cdtor): New function.
+ (arm_elf_asm_constructor): Use it.
+ (arm_elf_asm_destructor): New function.
+
2007-03-20 Bernd Schmidt <bernd.schmidt@analog.com>
* jump.c (mark_jump_label): Treat SEQUENCE specially.
#ifdef OBJECT_FORMAT_ELF
static void arm_elf_asm_constructor (rtx, int);
+static void arm_elf_asm_destructor (rtx, int);
#endif
#ifndef ARM_PE
static void arm_encode_section_info (tree, rtx, int);
return default_assemble_integer (x, size, aligned_p);
}
-
-/* Add a function to the list of static constructors. */
-
static void
-arm_elf_asm_constructor (rtx symbol, int priority)
+arm_elf_asm_cdtor (rtx symbol, int priority, bool is_ctor)
{
section *s;
if (!TARGET_AAPCS_BASED)
{
- default_named_section_asm_out_constructor (symbol, priority);
+ (is_ctor ?
+ default_named_section_asm_out_constructor
+ : default_named_section_asm_out_destructor) (symbol, priority);
return;
}
if (priority != DEFAULT_INIT_PRIORITY)
{
char buf[18];
- sprintf (buf, ".init_array.%.5u", priority);
+ sprintf (buf, "%s.%.5u",
+ is_ctor ? ".init_array" : ".fini_array",
+ priority);
s = get_section (buf, SECTION_WRITE, NULL_TREE);
}
- else
+ else if (is_ctor)
s = ctors_section;
+ else
+ s = dtors_section;
switch_to_section (s);
assemble_align (POINTER_SIZE);
output_addr_const (asm_out_file, symbol);
fputs ("(target1)\n", asm_out_file);
}
+
+/* Add a function to the list of static constructors. */
+
+static void
+arm_elf_asm_constructor (rtx symbol, int priority)
+{
+ arm_elf_asm_cdtor (symbol, priority, /*is_ctor=*/true);
+}
+
+/* Add a function to the list of static destructors. */
+
+static void
+arm_elf_asm_destructor (rtx symbol, int priority)
+{
+ arm_elf_asm_cdtor (symbol, priority, /*is_ctor=*/false);
+}
#endif
\f
/* A finite state machine takes care of noticing whether or not instructions
#undef TARGET_ASM_CONSTRUCTOR
#define TARGET_ASM_CONSTRUCTOR arm_elf_asm_constructor
+#undef TARGET_ASM_DESTRUCTOR
+#define TARGET_ASM_DESTRUCTOR arm_elf_asm_destructor
+
/* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */
#define NEED_PLT_RELOC flag_pic
#define NEED_GOT_RELOC flag_pic