Commit 9f296620 by Mark Mitchell Committed by Mark Mitchell

elf.h (TARGET_ASM_DESTRUCTOR): Define.

	* 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.

From-SVN: r123103
parent 22d33984
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> 2007-03-20 Bernd Schmidt <bernd.schmidt@analog.com>
* jump.c (mark_jump_label): Treat SEQUENCE specially. * jump.c (mark_jump_label): Treat SEQUENCE specially.
......
...@@ -150,6 +150,7 @@ static int arm_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, ...@@ -150,6 +150,7 @@ static int arm_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
#ifdef OBJECT_FORMAT_ELF #ifdef OBJECT_FORMAT_ELF
static void arm_elf_asm_constructor (rtx, int); static void arm_elf_asm_constructor (rtx, int);
static void arm_elf_asm_destructor (rtx, int);
#endif #endif
#ifndef ARM_PE #ifndef ARM_PE
static void arm_encode_section_info (tree, rtx, int); static void arm_encode_section_info (tree, rtx, int);
...@@ -12048,17 +12049,16 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p) ...@@ -12048,17 +12049,16 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p)
return default_assemble_integer (x, size, aligned_p); return default_assemble_integer (x, size, aligned_p);
} }
/* Add a function to the list of static constructors. */
static void static void
arm_elf_asm_constructor (rtx symbol, int priority) arm_elf_asm_cdtor (rtx symbol, int priority, bool is_ctor)
{ {
section *s; section *s;
if (!TARGET_AAPCS_BASED) 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; return;
} }
...@@ -12066,11 +12066,15 @@ arm_elf_asm_constructor (rtx symbol, int priority) ...@@ -12066,11 +12066,15 @@ arm_elf_asm_constructor (rtx symbol, int priority)
if (priority != DEFAULT_INIT_PRIORITY) if (priority != DEFAULT_INIT_PRIORITY)
{ {
char buf[18]; 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); s = get_section (buf, SECTION_WRITE, NULL_TREE);
} }
else else if (is_ctor)
s = ctors_section; s = ctors_section;
else
s = dtors_section;
switch_to_section (s); switch_to_section (s);
assemble_align (POINTER_SIZE); assemble_align (POINTER_SIZE);
...@@ -12078,6 +12082,22 @@ arm_elf_asm_constructor (rtx symbol, int priority) ...@@ -12078,6 +12082,22 @@ arm_elf_asm_constructor (rtx symbol, int priority)
output_addr_const (asm_out_file, symbol); output_addr_const (asm_out_file, symbol);
fputs ("(target1)\n", asm_out_file); 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 #endif
/* A finite state machine takes care of noticing whether or not instructions /* A finite state machine takes care of noticing whether or not instructions
......
...@@ -127,6 +127,9 @@ ...@@ -127,6 +127,9 @@
#undef TARGET_ASM_CONSTRUCTOR #undef TARGET_ASM_CONSTRUCTOR
#define TARGET_ASM_CONSTRUCTOR arm_elf_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. */ /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */
#define NEED_PLT_RELOC flag_pic #define NEED_PLT_RELOC flag_pic
#define NEED_GOT_RELOC flag_pic #define NEED_GOT_RELOC flag_pic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment