]> git.pld-linux.org Git - packages/gcc.git/blame - gcc-pr16276.patch
- initial.
[packages/gcc.git] / gcc-pr16276.patch
CommitLineData
75c24d94
PS
12004-07-09 H.J. Lu <hongjiu.lu@intel.com>
2
3 PR c++/16276
4 * configure.ac: Check if assembler supports COMDAT group.
5 * configure: Regenerated.
6 * config.in: Likewise.
7
8 * final.c (final_scan_insn): When generating jump table, call
9 readonly_data_section_in_function_group instead of
10 readonly_data_section if HAVE_GAS_COMDAT_GROUP is defined.
11
12 * output.h (elf_comdat_group): New.
13 (readonly_data_section_in_function_group): Likewise.
14
15 * varasm.c (readonly_data_section_in_function_group): New.
16 (elf_comdat_group): Likewise.
17 (default_elf_asm_named_section): Use COMDAT group if
18 HAVE_GAS_COMDAT_GROUP is defined.
19 * config/arm/arm.c (arm_elf_asm_named_section): Likewise.
20
21 * config/sparc/sysv4.h (TARGET_ASM_NAMED_SECTION): Define only
22 if HAVE_GAS_COMDAT_GROUP is not defined.
23
24--- gcc/config.in.comdat 2004-07-09 17:37:29.000000000 -0700
25+++ gcc/config.in 2004-07-09 17:37:29.000000000 -0700
26@@ -252,6 +252,9 @@
27 /* Define if your assembler supports .balign and .p2align. */
28 #undef HAVE_GAS_BALIGN_AND_P2ALIGN
29
30+/* Define 0/1 if your assembler supports COMDAT group. */
31+#undef HAVE_GAS_COMDAT_GROUP
32+
33 /* Define if your assembler uses the new HImode fild and fist notation. */
34 #undef HAVE_GAS_FILDS_FISTS
35
36--- gcc/config/arm/arm.c.comdat 2004-04-30 10:36:39.000000000 -0700
37+++ gcc/config/arm/arm.c 2004-07-09 17:37:29.000000000 -0700
38@@ -13156,12 +13156,15 @@ static void
39 arm_elf_asm_named_section (const char *name, unsigned int flags)
40 {
41 char flagchars[10], *f = flagchars;
42+ const char *section_name = NULL, *group_name = NULL;
43
44+#ifndef HAVE_GAS_COMDAT_GROUP
45 if (! named_section_first_declaration (name))
46 {
47 fprintf (asm_out_file, "\t.section\t%s\n", name);
48 return;
49 }
50+#endif
51
52 if (!(flags & SECTION_DEBUG))
53 *f++ = 'a';
54@@ -13177,9 +13180,17 @@ arm_elf_asm_named_section (const char *n
55 *f++ = 'S';
56 if (flags & SECTION_TLS)
57 *f++ = 'T';
58+#ifdef HAVE_GAS_COMDAT_GROUP
59+ if (elf_comdat_group (name, &section_name, &group_name))
60+ *f++ = 'G';
61+#endif
62 *f = '\0';
63
64- fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
65+ if (section_name)
66+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"", section_name,
67+ flagchars);
68+ else
69+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
70
71 if (!(flags & SECTION_NOTYPE))
72 {
73@@ -13196,6 +13207,9 @@ arm_elf_asm_named_section (const char *n
74 fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
75 }
76
77+ if (group_name)
78+ fprintf (asm_out_file, ",%s,comdat", group_name);
79+
80 putc ('\n', asm_out_file);
81 }
82 #endif
83--- gcc/config/sparc/sysv4.h.comdat 2003-06-17 17:03:32.000000000 -0700
84+++ gcc/config/sparc/sysv4.h 2004-07-09 17:37:29.000000000 -0700
85@@ -150,9 +150,13 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode ==
86 #undef DTORS_SECTION_ASM_OP
87 #define DTORS_SECTION_ASM_OP "\t.section\t\".dtors\",#alloc,#write"
88
89+/* COMDAT group cannot be expressed in SPARC's section attributes
90+ encoding style. */
91+#ifndef HAVE_GAS_COMDAT_GROUP
92 /* Switch into a generic section. */
93 #undef TARGET_ASM_NAMED_SECTION
94 #define TARGET_ASM_NAMED_SECTION sparc_elf_asm_named_section
95+#endif
96
97 #undef ASM_OUTPUT_ALIGNED_BSS
98 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
99--- gcc/configure.ac.comdat 2004-07-09 17:37:29.000000000 -0700
100+++ gcc/configure.ac 2004-07-09 17:37:29.000000000 -0700
101@@ -2070,6 +2070,13 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
102 [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
103 [Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
104
105+gcc_GAS_CHECK_FEATURE(COMDAT group support, gcc_cv_as_comdat_group,
106+ [elf,2,15,91], [--fatal-warnings],
107+ [.section .text,"axG",@progbits,.foo,comdat])
108+AC_DEFINE_UNQUOTED(HAVE_GAS_COMDAT_GROUP,
109+ [`if test $gcc_cv_as_comdat_group = yes; then echo 1; else echo 0; fi`],
110+[Define 0/1 if your assembler supports COMDAT group.])
111+
112 # Thread-local storage - the check is heavily parametrized.
113 conftest_s=
114 tls_first_major=
115--- gcc/final.c.comdat 2004-02-23 13:24:09.000000000 -0800
116+++ gcc/final.c 2004-07-09 17:38:25.000000000 -0700
117@@ -1881,7 +1881,12 @@ final_scan_insn (rtx insn, FILE *file, i
118 {
119 int log_align;
120
121+#ifdef HAVE_GAS_COMDAT_GROUP
122+ readonly_data_section_in_function_group
123+ (current_function_decl);
124+#else
125 readonly_data_section ();
126+#endif
127
128 #ifdef ADDR_VEC_ALIGN
129 log_align = ADDR_VEC_ALIGN (NEXT_INSN (insn));
130--- gcc/output.h.comdat 2004-03-26 09:25:41.000000000 -0800
131+++ gcc/output.h 2004-07-09 17:37:29.771404795 -0700
132@@ -475,6 +475,9 @@ extern void no_asm_to_stream (FILE *);
133 #define SECTION_NOTYPE 0x80000 /* don't output @progbits */
134 #define SECTION_MACH_DEP 0x100000 /* subsequent bits reserved for target */
135
136+extern const char *elf_comdat_group (const char *, const char **,
137+ const char **);
138+extern void readonly_data_section_in_function_group (tree);
139 extern unsigned int get_named_section_flags (const char *);
140 extern bool set_named_section_flags (const char *, unsigned int);
141 extern void named_section_flags (const char *, unsigned int);
142--- gcc/varasm.c.comdat 2004-04-16 16:59:51.000000000 -0700
143+++ gcc/varasm.c 2004-07-09 18:12:27.804157508 -0700
144@@ -259,6 +259,35 @@ data_section (void)
145 }
146 }
147
148+#ifdef HAVE_GAS_COMDAT_GROUP
149+
150+/* Tell assembler to switch to read-only data section in the same
151+ comdat group as DECL. */
152+
153+void
154+readonly_data_section_in_function_group (tree decl)
155+{
156+ if (decl == NULL_TREE || !DECL_P (decl))
157+ abort ();
158+
159+ if (DECL_SECTION_NAME (decl) == NULL_TREE || ! DECL_ONE_ONLY (decl))
160+ readonly_data_section ();
161+ else
162+ {
163+ char *rodata;
164+ const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
165+
166+ if (strncmp (name, ".gnu.linkonce.t.", 16) != 0)
167+ abort ();
168+
169+ rodata = xstrdup (name);
170+ rodata [14] = 'r';
171+ named_section_flags (rodata, 0);
172+ free (rodata);
173+ }
174+}
175+#endif
176+
177 /* Tell assembler to switch to read-only data section. This is normally
178 the text section. */
179
180@@ -4650,16 +4679,97 @@ default_no_named_section (const char *na
181 abort ();
182 }
183
184+/* Extract section name and group name from the linkonce section
185+ name. */
186+
187+const char *
188+elf_comdat_group (const char *name, const char **section,
189+ const char **group)
190+{
191+ const char *p;
192+ const char *sec = NULL;
193+ static const char *one [] =
194+ {
195+ ".bss", /* 'b' */
196+ NULL, /* 'c' */
197+ ".data", /* 'd' */
198+ NULL, /* 'e' */
199+ NULL, /* 'f' */
200+ NULL, /* 'q' */
201+ NULL, /* 'h' */
202+ NULL, /* 'i' */
203+ NULL, /* 'j' */
204+ NULL, /* 'k' */
205+ NULL, /* 'l' */
206+ NULL, /* 'm' */
207+ NULL, /* 'n' */
208+ NULL, /* 'o' */
209+ NULL, /* 'p' */
210+ NULL, /* 'q' */
211+ ".rodata", /* 'r' */
212+ ".sdata", /* 's' */
213+ ".text" /* 't' */
214+ };
215+
216+ if (strncmp (name, ".gnu.linkonce.", 14) != 0)
217+ return sec;
218+
219+ p = name + 14;
220+ if (p [1] == '.')
221+ {
222+ if (p [0] > 'a' && p [0] < 'u')
223+ sec = one [p [0] - 'b'];
224+
225+ if (sec)
226+ *group = p + 1;
227+ }
228+ else if (p [2] == '.')
229+ {
230+ if (p [0] == 's')
231+ {
232+ if (p [1] == '2')
233+ sec = ".sdata2";
234+ else if (p [1] == 'b')
235+ sec = ".sbss";
236+ }
237+ else if (p [0] == 't')
238+ {
239+ if (p [1] == 'b')
240+ sec = ".tbss";
241+ else if (p [1] == 'd')
242+ sec = ".tdata";
243+ }
244+ else if (p [0] == 'w' && p [1] == 'i')
245+ sec = ".debug_info";
246+
247+ if (sec)
248+ *group = p + 2;
249+ }
250+ else if (strncmp (p, "sb2.", 4) == 0)
251+ {
252+ sec = ".sbss2";
253+ *group = p + 3;
254+ }
255+
256+ if (sec)
257+ *section = sec;
258+
259+ return sec;
260+}
261+
262 void
263 default_elf_asm_named_section (const char *name, unsigned int flags)
264 {
265 char flagchars[10], *f = flagchars;
266+ const char *section_name = NULL, *group_name = NULL;
267
268+#ifndef HAVE_GAS_COMDAT_GROUP
269 if (! named_section_first_declaration (name))
270 {
271 fprintf (asm_out_file, "\t.section\t%s\n", name);
272 return;
273 }
274+#endif
275
276 if (!(flags & SECTION_DEBUG))
277 *f++ = 'a';
278@@ -4675,9 +4785,17 @@ default_elf_asm_named_section (const cha
279 *f++ = 'S';
280 if (flags & SECTION_TLS)
281 *f++ = 'T';
282+#ifdef HAVE_GAS_COMDAT_GROUP
283+ if (elf_comdat_group (name, &section_name, &group_name))
284+ *f++ = 'G';
285+#endif
286 *f = '\0';
287
288- fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
289+ if (section_name)
290+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"", section_name,
291+ flagchars);
292+ else
293+ fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
294
295 if (!(flags & SECTION_NOTYPE))
296 {
297@@ -4694,6 +4812,9 @@ default_elf_asm_named_section (const cha
298 fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
299 }
300
301+ if (group_name)
302+ fprintf (asm_out_file, ",%s,comdat", group_name);
303+
304 putc ('\n', asm_out_file);
305 }
306
This page took 0.106939 seconds and 4 git commands to generate.