blob: 13c3ccd95d570270703b24db9f5ea789aabc9d1f [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From 9a4253a92a5e1811693ea1707b5fc272908ec556 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
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 16/58] [Patch, microblaze]: Add INIT_PRIORITY support
5
6Added TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros.
Brad Bishop286d45c2018-10-02 15:21:57 -04007
8These macros allows users to control the order of initialization
9of objects defined at namespace scope with the init_priority
10attribute by specifying a relative priority, a constant integral
11expression currently bounded between 101 and 65535 inclusive.
12
13Lower numbers indicate a higher priority.
14
15Changelog
16
172013-11-26 Nagaraju Mekala <nagaraju.mekala@xilinx.com>
18
19 * gcc/config/microblaze/microblaze.c: Add microblaze_asm_constructor,
20 microblaze_asm_destructor. Define TARGET_ASM_CONSTRUCTOR and
21 TARGET_ASM_DESTRUCTOR.
22
Brad Bishop26bdd442019-08-16 17:08:17 -040023Signed-off-by:nagaraju <nmekala@xilix.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040024Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040025---
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050026 gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++
Brad Bishop286d45c2018-10-02 15:21:57 -040027 1 file changed, 53 insertions(+)
28
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050030index 0186171c04c..9eae5515c60 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040031--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050033@@ -2634,6 +2634,53 @@ print_operand_address (FILE * file, rtx addr)
Brad Bishop286d45c2018-10-02 15:21:57 -040034 }
35 }
36
37+/* Output an element in the table of global constructors. */
38+void
39+microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
40+{
41+ const char *section = ".ctors";
42+ char buf[16];
43+
44+ if (priority != DEFAULT_INIT_PRIORITY)
45+ {
46+ sprintf (buf, ".ctors.%.5u",
47+ /* Invert the numbering so the linker puts us in the proper
48+ order; constructors are run from right to left, and the
49+ linker sorts in increasing order. */
50+ MAX_INIT_PRIORITY - priority);
51+ section = buf;
52+ }
53+
54+ switch_to_section (get_section (section, 0, NULL));
55+ assemble_align (POINTER_SIZE);
56+ fputs ("\t.word\t", asm_out_file);
57+ output_addr_const (asm_out_file, symbol);
58+ fputs ("\n", asm_out_file);
59+}
60+
61+/* Output an element in the table of global destructors. */
62+void
63+microblaze_asm_destructor (rtx symbol, int priority)
64+{
65+ const char *section = ".dtors";
66+ char buf[16];
67+ if (priority != DEFAULT_INIT_PRIORITY)
68+ {
69+ sprintf (buf, ".dtors.%.5u",
70+ /* Invert the numbering so the linker puts us in the proper
71+ order; constructors are run from right to left, and the
72+ linker sorts in increasing order. */
73+ MAX_INIT_PRIORITY - priority);
74+ section = buf;
75+ }
76+
77+ switch_to_section (get_section (section, 0, NULL));
78+ assemble_align (POINTER_SIZE);
79+ fputs ("\t.word\t", asm_out_file);
80+ output_addr_const (asm_out_file, symbol);
81+ fputs ("\n", asm_out_file);
82+}
83+
84 /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
85 is used, so that we don't emit an .extern for it in
86 microblaze_asm_file_end. */
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050087@@ -3975,6 +4022,12 @@ microblaze_starting_frame_offset (void)
Brad Bishop286d45c2018-10-02 15:21:57 -040088 #undef TARGET_ATTRIBUTE_TABLE
89 #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table
90
91+#undef TARGET_ASM_CONSTRUCTOR
92+#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor
93+
94+#undef TARGET_ASM_DESTRUCTOR
95+#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor
96+
97 #undef TARGET_IN_SMALL_DATA_P
98 #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p
99
100--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001012.17.1
Brad Bishop286d45c2018-10-02 15:21:57 -0400102