diff options
author | Ajit Agarwal <ajitkum@xilinx.com> | 2014-08-18 17:04:41 +0000 |
---|---|---|
committer | Michael Eager <eager@eagercon.com> | 2014-08-18 17:04:41 +0000 |
commit | 73783d9ffd51a5cd5f999c306d7f2ea75dbd5ed1 (patch) | |
tree | fd11b534711aa4836129da2de9aa38901287db59 /gcc/config/microblaze | |
parent | 9d7d36e74c728219b77b12712928825823af1d4c (diff) |
Add Init_priority support.
Added TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros. These
macros allows users to control the order of initialization of objects
defined at namespace scope with the init_priority attribute by
specifying a relative priority.
ChangeLog:
2014-07-28 Ajit Agarwal <ajitkum@xilinx.com>
* config/microblaze/microblaze.c (microblaze_elf_asm_cdtor): New.
(microblaze_elf_asm_constructor,microblaze_elf_asm_destructor): New.
* config/microblaze/microblaze.h
(TARGET_ASM_CONSTRUCTOR,TARGET_ASM_DESTRUCTOR): New Macros.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@214110 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/microblaze')
-rw-r--r-- | gcc/config/microblaze/microblaze.c | 44 | ||||
-rw-r--r-- | gcc/config/microblaze/microblaze.h | 6 |
2 files changed, 50 insertions, 0 deletions
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 0c2aec84ac2..3ae61db3c4f 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -231,6 +231,9 @@ const struct attribute_spec microblaze_attribute_table[] = { static int microblaze_interrupt_function_p (tree); +static void microblaze_elf_asm_constructor (rtx, int) ATTRIBUTE_UNUSED; +static void microblaze_elf_asm_destructor (rtx, int) ATTRIBUTE_UNUSED; + section *sdata2_section; #ifdef HAVE_AS_TLS @@ -2714,6 +2717,47 @@ microblaze_function_end_prologue (FILE * file) } } +static void +microblaze_elf_asm_cdtor (rtx symbol, int priority, bool is_ctor) +{ + section *s; + + if (priority != DEFAULT_INIT_PRIORITY) + { + char buf[18]; + sprintf (buf, "%s.%.5u", + is_ctor ? ".ctors" : ".dtors", + MAX_INIT_PRIORITY - priority); + s = get_section (buf, SECTION_WRITE, NULL_TREE); + } + else if (is_ctor) + s = ctors_section; + else + s = dtors_section; + + switch_to_section (s); + assemble_align (POINTER_SIZE); + fputs ("\t.word\t", asm_out_file); + output_addr_const (asm_out_file, symbol); + fputs ("\n", asm_out_file); +} + +/* Add a function to the list of static constructors. */ + +static void +microblaze_elf_asm_constructor (rtx symbol, int priority) +{ + microblaze_elf_asm_cdtor (symbol, priority, /*is_ctor=*/true); +} + +/* Add a function to the list of static destructors. */ + +static void +microblaze_elf_asm_destructor (rtx symbol, int priority) +{ + microblaze_elf_asm_cdtor (symbol, priority, /*is_ctor=*/false); +} + /* Expand the prologue into a bunch of separate insns. */ void diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h index edb7d8aaab8..17be22c8027 100644 --- a/gcc/config/microblaze/microblaze.h +++ b/gcc/config/microblaze/microblaze.h @@ -691,6 +691,12 @@ do { \ { \ } +#undef TARGET_ASM_CONSTRUCTOR +#define TARGET_ASM_CONSTRUCTOR microblaze_elf_asm_constructor + +#undef TARGET_ASM_DESTRUCTOR +#define TARGET_ASM_DESTRUCTOR microblaze_elf_asm_destructor + #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM)) |