diff options
author | Ajit Agarwal <ajitkum@xilinx.com> | 2014-08-18 17:04:41 +0000 |
---|---|---|
committer | Michael Eager <eager@gcc.gnu.org> | 2014-08-18 17:04:41 +0000 |
commit | 57fb889f4199e7ffedc756e9d729d62171fb91f9 (patch) | |
tree | fd11b534711aa4836129da2de9aa38901287db59 /gcc | |
parent | f8df6750f4f7a70efd2e502add6f2280ede6e8db (diff) | |
download | gcc-57fb889f4199e7ffedc756e9d729d62171fb91f9.zip gcc-57fb889f4199e7ffedc756e9d729d62171fb91f9.tar.gz gcc-57fb889f4199e7ffedc756e9d729d62171fb91f9.tar.bz2 |
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.
From-SVN: r214110
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/microblaze/microblaze.c | 44 | ||||
-rw-r--r-- | gcc/config/microblaze/microblaze.h | 6 |
3 files changed, 57 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 408974b..629ae5f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-08-18 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. + 2014-08-18 H.J. Lu <hongjiu.lu@intel.com> PR other/62168 diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 0c2aec8..3ae61db 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 edb7d8a..17be22c 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)) |