Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 1 | From c0e74b79cc1db2f68dd560154225da1e5ddfd920 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 3 | Date: Tue, 17 Jan 2017 14:41:58 +0530 |
| 4 | Subject: [PATCH 17/54] [Patch, microblaze]: Add INIT_PRIORITY support Added |
| 5 | TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 6 | |
| 7 | These macros allows users to control the order of initialization |
| 8 | of objects defined at namespace scope with the init_priority |
| 9 | attribute by specifying a relative priority, a constant integral |
| 10 | expression currently bounded between 101 and 65535 inclusive. |
| 11 | |
| 12 | Lower numbers indicate a higher priority. |
| 13 | |
| 14 | Changelog |
| 15 | |
| 16 | 2013-11-26 Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
| 17 | |
| 18 | * gcc/config/microblaze/microblaze.c: Add microblaze_asm_constructor, |
| 19 | microblaze_asm_destructor. Define TARGET_ASM_CONSTRUCTOR and |
| 20 | TARGET_ASM_DESTRUCTOR. |
| 21 | |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 22 | Signed-off-by:nagaraju <nmekala@xilix.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 23 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 24 | --- |
| 25 | gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++++++++++ |
| 26 | 1 file changed, 53 insertions(+) |
| 27 | |
| 28 | diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 29 | index 6f0b4f4..53b44df 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 30 | --- a/gcc/config/microblaze/microblaze.c |
| 31 | +++ b/gcc/config/microblaze/microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 32 | @@ -2554,6 +2554,53 @@ print_operand_address (FILE * file, rtx addr) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 33 | } |
| 34 | } |
| 35 | |
| 36 | +/* Output an element in the table of global constructors. */ |
| 37 | +void |
| 38 | +microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority) |
| 39 | +{ |
| 40 | + const char *section = ".ctors"; |
| 41 | + char buf[16]; |
| 42 | + |
| 43 | + if (priority != DEFAULT_INIT_PRIORITY) |
| 44 | + { |
| 45 | + sprintf (buf, ".ctors.%.5u", |
| 46 | + /* Invert the numbering so the linker puts us in the proper |
| 47 | + order; constructors are run from right to left, and the |
| 48 | + linker sorts in increasing order. */ |
| 49 | + MAX_INIT_PRIORITY - priority); |
| 50 | + section = buf; |
| 51 | + } |
| 52 | + |
| 53 | + switch_to_section (get_section (section, 0, NULL)); |
| 54 | + assemble_align (POINTER_SIZE); |
| 55 | + fputs ("\t.word\t", asm_out_file); |
| 56 | + output_addr_const (asm_out_file, symbol); |
| 57 | + fputs ("\n", asm_out_file); |
| 58 | +} |
| 59 | + |
| 60 | +/* Output an element in the table of global destructors. */ |
| 61 | +void |
| 62 | +microblaze_asm_destructor (rtx symbol, int priority) |
| 63 | +{ |
| 64 | + const char *section = ".dtors"; |
| 65 | + char buf[16]; |
| 66 | + if (priority != DEFAULT_INIT_PRIORITY) |
| 67 | + { |
| 68 | + sprintf (buf, ".dtors.%.5u", |
| 69 | + /* Invert the numbering so the linker puts us in the proper |
| 70 | + order; constructors are run from right to left, and the |
| 71 | + linker sorts in increasing order. */ |
| 72 | + MAX_INIT_PRIORITY - priority); |
| 73 | + section = buf; |
| 74 | + } |
| 75 | + |
| 76 | + switch_to_section (get_section (section, 0, NULL)); |
| 77 | + assemble_align (POINTER_SIZE); |
| 78 | + fputs ("\t.word\t", asm_out_file); |
| 79 | + output_addr_const (asm_out_file, symbol); |
| 80 | + fputs ("\n", asm_out_file); |
| 81 | +} |
| 82 | + |
| 83 | /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol |
| 84 | is used, so that we don't emit an .extern for it in |
| 85 | microblaze_asm_file_end. */ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 86 | @@ -3841,6 +3888,12 @@ microblaze_starting_frame_offset (void) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 87 | #undef TARGET_ATTRIBUTE_TABLE |
| 88 | #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table |
| 89 | |
| 90 | +#undef TARGET_ASM_CONSTRUCTOR |
| 91 | +#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor |
| 92 | + |
| 93 | +#undef TARGET_ASM_DESTRUCTOR |
| 94 | +#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor |
| 95 | + |
| 96 | #undef TARGET_IN_SMALL_DATA_P |
| 97 | #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p |
| 98 | |
| 99 | -- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 100 | 2.7.4 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 101 | |