2 config/elfos.h | 14 +++++++++
3 config/i386/i386-protos.h | 1
4 config/i386/i386.c | 7 ++++
5 config/i386/i386.h | 2 -
6 config/rs6000/linux.h | 3 +
7 config/rs6000/linux64.h | 3 +
8 config/rs6000/rs6000.c | 5 +--
11 varasm.c | 70 ++++++++++++++++++++++++++++++++++++++++++++--
12 10 files changed, 114 insertions(+), 8 deletions(-)
14 diff -uNrp trunk/gcc.orig/config/elfos.h trunk/gcc/config/elfos.h
15 --- trunk/gcc.orig/config/elfos.h 2006-03-22 00:17:54.000000000 +0100
16 +++ trunk/gcc/config/elfos.h 2006-03-22 14:28:10.000000000 +0100
17 @@ -489,3 +489,17 @@ Boston, MA 02110-1301, USA. */
18 fprintf ((FILE), "\"\n"); \
22 +/* A C statement (sans semicolon) to output to the stdio stream STREAM
23 + any text necessary for declaring the name of an external symbol
24 + named NAME whch is referenced in this compilation but not defined.
25 + It is needed to properly support non-default visibility. */
27 +#ifndef ASM_OUTPUT_EXTERNAL
28 +#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
29 + default_elf_asm_output_external (FILE, DECL, NAME)
32 +#ifndef TARGET_ASM_FILE_END
33 +#define TARGET_ASM_FILE_END default_elf_asm_file_end
35 diff -uNrp trunk/gcc.orig/config/i386/i386.c trunk/gcc/config/i386/i386.c
36 --- trunk/gcc.orig/config/i386/i386.c 2006-03-22 14:20:45.000000000 +0100
37 +++ trunk/gcc/config/i386/i386.c 2006-03-22 14:28:10.000000000 +0100
38 @@ -4751,6 +4751,13 @@ ix86_file_end (void)
39 file_end_indicate_exec_stack ();
43 +ix86_elf_file_end (void)
46 + default_elf_asm_file_end ();
49 /* Emit code for the SET_GOT patterns. */
52 diff -uNrp trunk/gcc.orig/config/i386/i386.h trunk/gcc/config/i386/i386.h
53 --- trunk/gcc.orig/config/i386/i386.h 2006-03-22 00:17:11.000000000 +0100
54 +++ trunk/gcc/config/i386/i386.h 2006-03-22 14:28:10.000000000 +0100
55 @@ -1438,7 +1438,7 @@ typedef struct ix86_args {
56 #define EXPAND_BUILTIN_VA_START(VALIST, NEXTARG) \
57 ix86_va_start (VALIST, NEXTARG)
59 -#define TARGET_ASM_FILE_END ix86_file_end
60 +#define TARGET_ASM_FILE_END ix86_elf_file_end
61 #define NEED_INDICATE_EXEC_STACK 0
63 /* Output assembler code to FILE to increment profiler label # LABELNO
64 diff -uNrp trunk/gcc.orig/config/i386/i386-protos.h trunk/gcc/config/i386/i386-protos.h
65 --- trunk/gcc.orig/config/i386/i386-protos.h 2006-03-22 00:17:11.000000000 +0100
66 +++ trunk/gcc/config/i386/i386-protos.h 2006-03-22 14:28:10.000000000 +0100
67 @@ -29,6 +29,7 @@ extern int ix86_frame_pointer_required (
68 extern void ix86_setup_frame_addresses (void);
70 extern void ix86_file_end (void);
71 +extern void ix86_elf_file_end (void);
72 extern HOST_WIDE_INT ix86_initial_elimination_offset (int, int);
73 extern void ix86_expand_prologue (void);
74 extern void ix86_expand_epilogue (int);
75 diff -uNrp trunk/gcc.orig/config/rs6000/linux64.h trunk/gcc/config/rs6000/linux64.h
76 --- trunk/gcc.orig/config/rs6000/linux64.h 2006-03-22 00:17:37.000000000 +0100
77 +++ trunk/gcc/config/rs6000/linux64.h 2006-03-22 14:28:10.000000000 +0100
78 @@ -563,7 +563,8 @@ while (0)
79 #undef DRAFT_V4_STRUCT_RET
80 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
82 -#define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
83 +#undef TARGET_ASM_FILE_END
84 +#define TARGET_ASM_FILE_END rs6000_elf_file_end
86 #define TARGET_POSIX_IO
88 diff -uNrp trunk/gcc.orig/config/rs6000/linux.h trunk/gcc/config/rs6000/linux.h
89 --- trunk/gcc.orig/config/rs6000/linux.h 2006-03-22 00:17:37.000000000 +0100
90 +++ trunk/gcc/config/rs6000/linux.h 2006-03-22 14:28:10.000000000 +0100
92 #define RELOCATABLE_NEEDS_FIXUP \
93 (target_flags & target_flags_explicit & MASK_RELOCATABLE)
95 -#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
96 +#undef TARGET_ASM_FILE_END
97 +#define TARGET_ASM_FILE_END rs6000_elf_file_end
99 #define TARGET_POSIX_IO
101 diff -uNrp trunk/gcc.orig/config/rs6000/rs6000.c trunk/gcc/config/rs6000/rs6000.c
102 --- trunk/gcc.orig/config/rs6000/rs6000.c 2006-03-22 00:17:37.000000000 +0100
103 +++ trunk/gcc/config/rs6000/rs6000.c 2006-03-22 14:28:10.000000000 +0100
104 @@ -614,7 +614,7 @@ static void rs6000_file_start (void);
105 static unsigned int rs6000_elf_section_type_flags (tree, const char *, int);
106 static void rs6000_elf_asm_out_constructor (rtx, int);
107 static void rs6000_elf_asm_out_destructor (rtx, int);
108 -static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED;
109 +static void rs6000_elf_file_end (void) ATTRIBUTE_UNUSED;
110 static void rs6000_elf_asm_init_sections (void);
111 static section *rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT);
112 static void rs6000_elf_unique_section (tree, int);
113 @@ -18221,10 +18221,11 @@ rs6000_elf_declare_function_name (FILE *
117 -rs6000_elf_end_indicate_exec_stack (void)
118 +rs6000_elf_file_end (void)
121 file_end_indicate_exec_stack ();
122 + default_elf_asm_file_end ();
126 diff -uNrp trunk/gcc.orig/output.h trunk/gcc/output.h
127 --- trunk/gcc.orig/output.h 2006-03-22 00:17:58.000000000 +0100
128 +++ trunk/gcc/output.h 2006-03-22 14:28:10.000000000 +0100
129 @@ -608,6 +608,12 @@ extern void default_file_start (void);
130 extern void file_end_indicate_exec_stack (void);
131 extern bool default_valid_pointer_mode (enum machine_mode);
133 +extern void default_elf_asm_output_external (FILE *file, tree,
135 +extern void default_elf_asm_output_external_1 (tree);
136 +extern void default_elf_asm_file_end (void);
137 +extern int maybe_assemble_visibility (tree);
139 extern int default_address_cost (rtx);
141 /* dbxout helper functions */
142 diff -uNrp trunk/gcc.orig/tree.h trunk/gcc/tree.h
143 --- trunk/gcc.orig/tree.h 2006-03-22 00:17:58.000000000 +0100
144 +++ trunk/gcc/tree.h 2006-03-22 14:28:10.000000000 +0100
145 @@ -4388,6 +4388,17 @@ extern void process_pending_assemble_ext
146 extern void finish_aliases_1 (void);
147 extern void finish_aliases_2 (void);
149 +/* Linked list of all external symbols that are to be emitted by
152 +struct extern_symbol_list GTY(())
154 + struct extern_symbol_list *next;
158 +extern GTY(()) struct extern_symbol_list *extern_symbol_head;
161 extern void expand_computed_goto (tree);
162 extern bool parse_output_constraint (const char **, int, int, int,
163 diff -uNrp trunk/gcc.orig/varasm.c trunk/gcc/varasm.c
164 --- trunk/gcc.orig/varasm.c 2006-03-22 00:17:58.000000000 +0100
165 +++ trunk/gcc/varasm.c 2006-03-22 14:28:10.000000000 +0100
166 @@ -126,7 +126,6 @@ static unsigned HOST_WIDE_INT array_size
167 static unsigned min_align (unsigned, unsigned);
168 static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int);
169 static void globalize_decl (tree);
170 -static void maybe_assemble_visibility (tree);
171 #ifdef BSS_SECTION_ASM_OP
172 #ifdef ASM_OUTPUT_BSS
173 static void asm_output_bss (FILE *, tree, const char *,
174 @@ -5039,13 +5038,18 @@ default_assemble_visibility (tree decl,
176 /* A helper function to call assemble_visibility when needed for a decl. */
180 maybe_assemble_visibility (tree decl)
182 enum symbol_visibility vis = DECL_VISIBILITY (decl);
184 if (vis != VISIBILITY_DEFAULT)
185 - targetm.asm_out.visibility (decl, vis);
187 + targetm.asm_out.visibility (decl, vis);
194 /* Returns 1 if the target configuration supports defining public symbols
195 @@ -6194,4 +6198,64 @@ output_object_blocks (void)
196 htab_traverse (object_block_htab, output_object_block_htab, NULL);
199 +struct extern_symbol_list *extern_symbol_head;
202 +default_elf_asm_output_external_1 (tree decl)
204 + struct extern_symbol_list *p
205 + = ggc_alloc (sizeof (struct extern_symbol_list));
208 + p->next = extern_symbol_head;
209 + extern_symbol_head = p;
212 +/* Emit text to declare externally defined symbols. It is needed to
213 + properly support non-default visibility. */
216 +default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
220 + /* Ignore builtin functions. */
221 + if (TREE_CODE (decl) == FUNCTION_DECL
222 + && strstr (name, "__builtin_") == name)
225 + default_elf_asm_output_external_1 (decl);
228 +/* Print out the list of referenced global symbols with non-default
232 +default_elf_asm_file_end (void)
234 + struct extern_symbol_list *p;
236 + for (p = extern_symbol_head; p; p = p->next)
238 + tree decl = p->decl;
239 + tree id = DECL_ASSEMBLER_NAME (decl);
244 + /* We output the name if and only if TREE_SYMBOL_REFERENCED is
245 + set in order to avoid putting out names that are never really
247 + if (targetm.binds_local_p (decl)
248 + && !TREE_ASM_WRITTEN (decl)
249 + && TREE_SYMBOL_REFERENCED (id))
251 + maybe_assemble_visibility (decl);
252 + TREE_ASM_WRITTEN (decl) = 1;
256 + extern_symbol_head = 0;
259 #include "gt-varasm.h"