]> git.pld-linux.org Git - packages/crossppc-gcc.git/blame - gcc-pr20218.patch
- fix for new gcc
[packages/crossppc-gcc.git] / gcc-pr20218.patch
CommitLineData
6e260766 12006-12-06 H.J. Lu <hongjiu.lu@intel.com>
abe7f82e 2
6e260766
PS
3 PR middle-end/17982
4 PR middle-end/20218
5 * cgraphunit.c (cgraph_optimize): Don't call
6 process_pending_assemble_externals for ELF targets.
abe7f82e 7
6e260766
PS
8 * config/elfos.h (ASM_OUTPUT_EXTERNAL): New.
9
10 * config/ia64/hpux.h (TARGET_ASM_FILE_END): Removed.
11
12 * config/ia64/ia64.c (ia64_asm_output_external): Rewritten.
13 (ia64_hpux_add_extern_decl): Removed.
14 (ia64_hpux_file_end): Likewise.
15 (extern_func_list): Likewise.
16 (extern_func_head): Likewise.
17
18 * output.h (assemble_external): Update comments.
19 (default_elf_asm_output_external): New.
20 (maybe_assemble_visibility): New.
21
22 * varasm.c (maybe_assemble_visibility): Make it extern and
23 return int.
24 (default_elf_asm_output_external): New.
25
26--- gcc/cgraphunit.c.global 2006-12-02 09:32:10.000000000 -0800
27+++ gcc/cgraphunit.c 2006-12-06 06:10:58.000000000 -0800
28@@ -1536,7 +1536,12 @@ cgraph_optimize (void)
29 return;
30 }
31
32+ /* FIXME: For ELF targets, we want to process undefined symbols later
33+ so that we can check if they are referenced or not. Should we do
34+ the same for all targets? */
35+#ifndef OBJECT_FORMAT_ELF
36 process_pending_assemble_externals ();
37+#endif
38
39 /* Frontend may output common variables after the unit has been finalized.
40 It is safe to deal with them here as they are always zero initialized. */
41--- gcc/config/elfos.h.global 2006-12-02 09:32:10.000000000 -0800
42+++ gcc/config/elfos.h 2006-12-05 15:16:22.000000000 -0800
43@@ -499,3 +499,13 @@ Boston, MA 02110-1301, USA. */
2d49f59d
PS
44 fprintf ((FILE), "\"\n"); \
45 } \
46 while (0)
47+
48+/* A C statement (sans semicolon) to output to the stdio stream STREAM
49+ any text necessary for declaring the name of an external symbol
50+ named NAME whch is referenced in this compilation but not defined.
51+ It is needed to properly support non-default visibility. */
52+
53+#ifndef ASM_OUTPUT_EXTERNAL
54+#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
55+ default_elf_asm_output_external (FILE, DECL, NAME)
56+#endif
6e260766
PS
57--- gcc/config/ia64/hpux.h.global 2006-10-27 10:09:07.000000000 -0700
58+++ gcc/config/ia64/hpux.h 2006-12-05 15:16:22.000000000 -0800
59@@ -144,10 +144,6 @@ do { \
60 definitions, so do not use them in gthr-posix.h. */
61 #define GTHREAD_USE_WEAK 0
0fe1531c 62
6e260766
PS
63-/* Put out the needed function declarations at the end. */
64-
65-#define TARGET_ASM_FILE_END ia64_hpux_file_end
66-
67 #undef CTORS_SECTION_ASM_OP
68 #define CTORS_SECTION_ASM_OP "\t.section\t.init_array,\t\"aw\",\"init_array\""
abe7f82e 69
6e260766
PS
70--- gcc/config/ia64/ia64.c.global 2006-11-16 09:57:21.000000000 -0800
71+++ gcc/config/ia64/ia64.c 2006-12-05 15:16:22.000000000 -0800
72@@ -255,10 +255,6 @@ static section *ia64_rwreloc_select_rtx_
73 unsigned HOST_WIDE_INT)
74 ATTRIBUTE_UNUSED;
75 static unsigned int ia64_section_type_flags (tree, const char *, int);
76-static void ia64_hpux_add_extern_decl (tree decl)
77- ATTRIBUTE_UNUSED;
78-static void ia64_hpux_file_end (void)
79- ATTRIBUTE_UNUSED;
80 static void ia64_init_libfuncs (void)
81 ATTRIBUTE_UNUSED;
82 static void ia64_hpux_init_libfuncs (void)
83@@ -5021,49 +5017,6 @@ ia64_secondary_reload_class (enum reg_cl
84 }
0fe1531c 85
6e260766
PS
86 \f
87-/* Emit text to declare externally defined variables and functions, because
88- the Intel assembler does not support undefined externals. */
89-
90-void
91-ia64_asm_output_external (FILE *file, tree decl, const char *name)
92-{
93- int save_referenced;
94-
95- /* GNU as does not need anything here, but the HP linker does need
96- something for external functions. */
97-
98- if (TARGET_GNU_AS
99- && (!TARGET_HPUX_LD
100- || TREE_CODE (decl) != FUNCTION_DECL
101- || strstr (name, "__builtin_") == name))
102- return;
103-
104- /* ??? The Intel assembler creates a reference that needs to be satisfied by
105- the linker when we do this, so we need to be careful not to do this for
106- builtin functions which have no library equivalent. Unfortunately, we
107- can't tell here whether or not a function will actually be called by
108- expand_expr, so we pull in library functions even if we may not need
109- them later. */
110- if (! strcmp (name, "__builtin_next_arg")
111- || ! strcmp (name, "alloca")
112- || ! strcmp (name, "__builtin_constant_p")
113- || ! strcmp (name, "__builtin_args_info"))
114- return;
115-
116- if (TARGET_HPUX_LD)
117- ia64_hpux_add_extern_decl (decl);
118- else
119- {
120- /* assemble_name will set TREE_SYMBOL_REFERENCED, so we must save and
121- restore it. */
122- save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl));
123- if (TREE_CODE (decl) == FUNCTION_DECL)
124- ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
125- (*targetm.asm_out.globalize_label) (file, name);
126- TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = save_referenced;
127- }
128-}
129-\f
130 /* Parse the -mfixed-range= option string. */
0fe1531c 131
6e260766
PS
132 static void
133@@ -9174,55 +9127,33 @@ ia64_hpux_function_arg_padding (enum mac
134 return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
0fe1531c
PS
135 }
136
6e260766
PS
137-/* Linked list of all external functions that are to be emitted by GCC.
138- We output the name if and only if TREE_SYMBOL_REFERENCED is set in
139- order to avoid putting out names that are never really used. */
140-
141-struct extern_func_list GTY(())
142-{
143- struct extern_func_list *next;
144- tree decl;
145-};
146-
147-static GTY(()) struct extern_func_list *extern_func_head;
148-
149-static void
150-ia64_hpux_add_extern_decl (tree decl)
151-{
152- struct extern_func_list *p = ggc_alloc (sizeof (struct extern_func_list));
153-
154- p->decl = decl;
155- p->next = extern_func_head;
156- extern_func_head = p;
157-}
158-
159-/* Print out the list of used global functions. */
160+/* Emit text to declare externally defined variables and functions, because
161+ the Intel assembler does not support undefined externals. */
162
163-static void
164-ia64_hpux_file_end (void)
165+void
166+ia64_asm_output_external (FILE *file, tree decl, const char *name)
0fe1531c 167 {
6e260766
PS
168- struct extern_func_list *p;
169-
170- for (p = extern_func_head; p; p = p->next)
171- {
172- tree decl = p->decl;
173- tree id = DECL_ASSEMBLER_NAME (decl);
174-
175- gcc_assert (id);
176-
177- if (!TREE_ASM_WRITTEN (decl) && TREE_SYMBOL_REFERENCED (id))
178- {
179- const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
180-
181- TREE_ASM_WRITTEN (decl) = 1;
182- (*targetm.asm_out.globalize_label) (asm_out_file, name);
183- fputs (TYPE_ASM_OP, asm_out_file);
184- assemble_name (asm_out_file, name);
185- fprintf (asm_out_file, "," TYPE_OPERAND_FMT "\n", "function");
186- }
187+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
188+ set in order to avoid putting out names that are never really
189+ used. */
190+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
191+ {
192+ /* maybe_assemble_visibility will return 1 if the assembler
193+ visibility directive is outputed. */
194+ int need_visibility = ((*targetm.binds_local_p) (decl)
195+ && maybe_assemble_visibility (decl));
196+
197+ /* GNU as does not need anything here, but the HP linker does
198+ need something for external functions. */
199+ if ((TARGET_HPUX_LD || !TARGET_GNU_AS)
200+ && TREE_CODE (decl) == FUNCTION_DECL)
201+ {
202+ ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
203+ (*targetm.asm_out.globalize_label) (file, name);
204+ }
205+ else if (need_visibility && !TARGET_GNU_AS)
206+ (*targetm.asm_out.globalize_label) (file, name);
207 }
208-
209- extern_func_head = 0;
0fe1531c 210 }
0fe1531c 211
6e260766
PS
212 /* Set SImode div/mod functions, init_integral_libfuncs only initializes
213--- gcc/output.h.global 2006-10-17 07:32:38.000000000 -0700
214+++ gcc/output.h 2006-12-05 15:16:22.000000000 -0800
215@@ -204,9 +204,9 @@ extern void assemble_variable (tree, int
216 DONT_OUTPUT_DATA is from assemble_variable. */
217 extern void align_variable (tree decl, bool dont_output_data);
218
219-/* Output something to declare an external symbol to the assembler.
220- (Most assemblers don't need this, so we normally output nothing.)
221- Do nothing if DECL is not external. */
222+/* Queue for outputing something to declare an external symbol to the
223+ assembler. (Most assemblers don't need this, so we normally output
224+ nothing.) Do nothing if DECL is not external. */
225 extern void assemble_external (tree);
226
227 /* Assemble code to leave SIZE bytes of zeros. */
228@@ -619,6 +619,10 @@ extern void default_file_start (void);
2d49f59d
PS
229 extern void file_end_indicate_exec_stack (void);
230 extern bool default_valid_pointer_mode (enum machine_mode);
231
232+extern void default_elf_asm_output_external (FILE *file, tree,
233+ const char *);
2d49f59d
PS
234+extern int maybe_assemble_visibility (tree);
235+
236 extern int default_address_cost (rtx);
237
238 /* dbxout helper functions */
6e260766
PS
239--- gcc/varasm.c.global 2006-10-17 07:32:38.000000000 -0700
240+++ gcc/varasm.c 2006-12-06 06:05:43.000000000 -0800
2d49f59d
PS
241@@ -126,7 +126,6 @@ static unsigned HOST_WIDE_INT array_size
242 static unsigned min_align (unsigned, unsigned);
243 static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int);
244 static void globalize_decl (tree);
245-static void maybe_assemble_visibility (tree);
abe7f82e
PS
246 #ifdef BSS_SECTION_ASM_OP
247 #ifdef ASM_OUTPUT_BSS
248 static void asm_output_bss (FILE *, tree, const char *,
6e260766 249@@ -5071,13 +5070,18 @@ default_assemble_visibility (tree decl,
2d49f59d
PS
250
251 /* A helper function to call assemble_visibility when needed for a decl. */
252
253-static void
254+int
255 maybe_assemble_visibility (tree decl)
256 {
257 enum symbol_visibility vis = DECL_VISIBILITY (decl);
258
259 if (vis != VISIBILITY_DEFAULT)
260- targetm.asm_out.visibility (decl, vis);
261+ {
262+ targetm.asm_out.visibility (decl, vis);
263+ return 1;
264+ }
265+ else
266+ return 0;
267 }
268
269 /* Returns 1 if the target configuration supports defining public symbols
6e260766 270@@ -6226,4 +6230,19 @@ output_object_blocks (void)
abe7f82e 271 htab_traverse (object_block_htab, output_object_block_htab, NULL);
2d49f59d
PS
272 }
273
2d49f59d
PS
274+/* Emit text to declare externally defined symbols. It is needed to
275+ properly support non-default visibility. */
2d49f59d
PS
276+void
277+default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
278+ tree decl,
6e260766 279+ const char *name ATTRIBUTE_UNUSED)
2d49f59d 280+{
6e260766
PS
281+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
282+ set in order to avoid putting out names that are never really
283+ used. */
284+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
285+ && targetm.binds_local_p (decl))
286+ maybe_assemble_visibility (decl);
2d49f59d
PS
287+}
288+
289 #include "gt-varasm.h"
This page took 0.101587 seconds and 4 git commands to generate.