blob: 6fb1b32fea6bc15a6a614a8f828bca2127724f8f [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From c0e74b79cc1db2f68dd560154225da1e5ddfd920 Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: Mahesh Bodapati <mbodapat@xilinx.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Tue, 17 Jan 2017 14:41:58 +0530
4Subject: [PATCH 17/54] [Patch, microblaze]: Add INIT_PRIORITY support Added
5 TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros.
Brad Bishop286d45c2018-10-02 15:21:57 -04006
7These macros allows users to control the order of initialization
8of objects defined at namespace scope with the init_priority
9attribute by specifying a relative priority, a constant integral
10expression currently bounded between 101 and 65535 inclusive.
11
12Lower numbers indicate a higher priority.
13
14Changelog
15
162013-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 Bishop26bdd442019-08-16 17:08:17 -040022Signed-off-by:nagaraju <nmekala@xilix.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040023Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040024---
25 gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++++++++++
26 1 file changed, 53 insertions(+)
27
28diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040029index 6f0b4f4..53b44df 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040030--- a/gcc/config/microblaze/microblaze.c
31+++ b/gcc/config/microblaze/microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040032@@ -2554,6 +2554,53 @@ print_operand_address (FILE * file, rtx addr)
Brad Bishop286d45c2018-10-02 15:21:57 -040033 }
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 Bishop26bdd442019-08-16 17:08:17 -040086@@ -3841,6 +3888,12 @@ microblaze_starting_frame_offset (void)
Brad Bishop286d45c2018-10-02 15:21:57 -040087 #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 Bishop26bdd442019-08-16 17:08:17 -04001002.7.4
Brad Bishop286d45c2018-10-02 15:21:57 -0400101