1 2006-12-06 H.J. Lu <hongjiu.lu@intel.com>
5 * cgraphunit.c (cgraph_optimize): Don't call
6 process_pending_assemble_externals for ELF targets.
8 * config/elfos.h (ASM_OUTPUT_EXTERNAL): New.
10 * config/ia64/hpux.h (TARGET_ASM_FILE_END): Removed.
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.
18 * output.h (assemble_external): Update comments.
19 (default_elf_asm_output_external): New.
20 (maybe_assemble_visibility): New.
22 * varasm.c (maybe_assemble_visibility): Make it extern and
24 (default_elf_asm_output_external): New.
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)
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 ();
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. */
44 fprintf ((FILE), "\"\n"); \
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. */
53 +#ifndef ASM_OUTPUT_EXTERNAL
54 +#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
55 + default_elf_asm_output_external (FILE, DECL, NAME)
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
63 -/* Put out the needed function declarations at the end. */
65 -#define TARGET_ASM_FILE_END ia64_hpux_file_end
67 #undef CTORS_SECTION_ASM_OP
68 #define CTORS_SECTION_ASM_OP "\t.section\t.init_array,\t\"aw\",\"init_array\""
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)
75 static unsigned int ia64_section_type_flags (tree, const char *, int);
76 -static void ia64_hpux_add_extern_decl (tree decl)
78 -static void ia64_hpux_file_end (void)
80 static void ia64_init_libfuncs (void)
82 static void ia64_hpux_init_libfuncs (void)
83 @@ -5021,49 +5017,6 @@ ia64_secondary_reload_class (enum reg_cl
87 -/* Emit text to declare externally defined variables and functions, because
88 - the Intel assembler does not support undefined externals. */
91 -ia64_asm_output_external (FILE *file, tree decl, const char *name)
93 - int save_referenced;
95 - /* GNU as does not need anything here, but the HP linker does need
96 - something for external functions. */
100 - || TREE_CODE (decl) != FUNCTION_DECL
101 - || strstr (name, "__builtin_") == name))
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
110 - if (! strcmp (name, "__builtin_next_arg")
111 - || ! strcmp (name, "alloca")
112 - || ! strcmp (name, "__builtin_constant_p")
113 - || ! strcmp (name, "__builtin_args_info"))
116 - if (TARGET_HPUX_LD)
117 - ia64_hpux_add_extern_decl (decl);
120 - /* assemble_name will set TREE_SYMBOL_REFERENCED, so we must save and
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;
130 /* Parse the -mfixed-range= option string. */
133 @@ -9174,55 +9127,33 @@ ia64_hpux_function_arg_padding (enum mac
134 return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
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. */
141 -struct extern_func_list GTY(())
143 - struct extern_func_list *next;
147 -static GTY(()) struct extern_func_list *extern_func_head;
150 -ia64_hpux_add_extern_decl (tree decl)
152 - struct extern_func_list *p = ggc_alloc (sizeof (struct extern_func_list));
155 - p->next = extern_func_head;
156 - extern_func_head = p;
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. */
164 -ia64_hpux_file_end (void)
166 +ia64_asm_output_external (FILE *file, tree decl, const char *name)
168 - struct extern_func_list *p;
170 - for (p = extern_func_head; p; p = p->next)
172 - tree decl = p->decl;
173 - tree id = DECL_ASSEMBLER_NAME (decl);
177 - if (!TREE_ASM_WRITTEN (decl) && TREE_SYMBOL_REFERENCED (id))
179 - const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
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");
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
190 + if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
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));
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)
202 + ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
203 + (*targetm.asm_out.globalize_label) (file, name);
205 + else if (need_visibility && !TARGET_GNU_AS)
206 + (*targetm.asm_out.globalize_label) (file, name);
209 - extern_func_head = 0;
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);
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);
227 /* Assemble code to leave SIZE bytes of zeros. */
228 @@ -619,6 +619,10 @@ extern void default_file_start (void);
229 extern void file_end_indicate_exec_stack (void);
230 extern bool default_valid_pointer_mode (enum machine_mode);
232 +extern void default_elf_asm_output_external (FILE *file, tree,
234 +extern int maybe_assemble_visibility (tree);
236 extern int default_address_cost (rtx);
238 /* dbxout helper functions */
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
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);
246 #ifdef BSS_SECTION_ASM_OP
247 #ifdef ASM_OUTPUT_BSS
248 static void asm_output_bss (FILE *, tree, const char *,
249 @@ -5071,13 +5070,18 @@ default_assemble_visibility (tree decl,
251 /* A helper function to call assemble_visibility when needed for a decl. */
255 maybe_assemble_visibility (tree decl)
257 enum symbol_visibility vis = DECL_VISIBILITY (decl);
259 if (vis != VISIBILITY_DEFAULT)
260 - targetm.asm_out.visibility (decl, vis);
262 + targetm.asm_out.visibility (decl, vis);
269 /* Returns 1 if the target configuration supports defining public symbols
270 @@ -6226,4 +6230,19 @@ output_object_blocks (void)
271 htab_traverse (object_block_htab, output_object_block_htab, NULL);
274 +/* Emit text to declare externally defined symbols. It is needed to
275 + properly support non-default visibility. */
277 +default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
279 + const char *name ATTRIBUTE_UNUSED)
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
284 + if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
285 + && targetm.binds_local_p (decl))
286 + maybe_assemble_visibility (decl);
289 #include "gt-varasm.h"