1 diff -uNrp gcc-4_1-branch/gcc.orig/config/elfos.h gcc-4_1-branch/gcc/config/elfos.h
2 --- gcc-4_1-branch/gcc.orig/config/elfos.h 2005-11-30 11:16:19.000000000 +0000
3 +++ gcc-4_1-branch/gcc/config/elfos.h 2005-12-06 17:42:34.002991368 +0000
4 @@ -487,3 +487,17 @@ Boston, MA 02110-1301, USA. */
5 fprintf ((FILE), "\"\n"); \
9 +/* A C statement (sans semicolon) to output to the stdio stream STREAM
10 + any text necessary for declaring the name of an external symbol
11 + named NAME whch is referenced in this compilation but not defined.
12 + It is needed to properly support non-default visibility. */
14 +#ifndef ASM_OUTPUT_EXTERNAL
15 +#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
16 + default_elf_asm_output_external (FILE, DECL, NAME)
19 +#ifndef TARGET_ASM_FILE_END
20 +#define TARGET_ASM_FILE_END default_elf_asm_file_end
22 diff -uNrp gcc-4_1-branch/gcc.orig/config/i386/i386-protos.h gcc-4_1-branch/gcc/config/i386/i386-protos.h
23 --- gcc-4_1-branch/gcc.orig/config/i386/i386-protos.h 2005-11-30 11:15:19.000000000 +0000
24 +++ gcc-4_1-branch/gcc/config/i386/i386-protos.h 2005-12-06 17:42:34.002991368 +0000
25 @@ -28,6 +28,7 @@ extern int ix86_frame_pointer_required (
26 extern void ix86_setup_frame_addresses (void);
28 extern void ix86_file_end (void);
29 +extern void ix86_elf_file_end (void);
30 extern HOST_WIDE_INT ix86_initial_elimination_offset (int, int);
31 extern void ix86_expand_prologue (void);
32 extern void ix86_expand_epilogue (int);
33 diff -uNrp gcc-4_1-branch/gcc.orig/config/i386/i386.c gcc-4_1-branch/gcc/config/i386/i386.c
34 --- gcc-4_1-branch/gcc.orig/config/i386/i386.c 2005-12-06 17:39:59.080543160 +0000
35 +++ gcc-4_1-branch/gcc/config/i386/i386.c 2005-12-06 17:42:34.010990152 +0000
36 @@ -4417,6 +4417,13 @@ ix86_file_end (void)
37 file_end_indicate_exec_stack ();
41 +ix86_elf_file_end (void)
44 + default_elf_asm_file_end ();
47 /* Emit code for the SET_GOT patterns. */
50 diff -uNrp gcc-4_1-branch/gcc.orig/config/i386/i386.h gcc-4_1-branch/gcc/config/i386/i386.h
51 --- gcc-4_1-branch/gcc.orig/config/i386/i386.h 2005-11-30 11:15:19.000000000 +0000
52 +++ gcc-4_1-branch/gcc/config/i386/i386.h 2005-12-06 17:48:04.665722992 +0000
53 @@ -1513,7 +1513,7 @@ typedef struct ix86_args {
54 #define EXPAND_BUILTIN_VA_START(VALIST, NEXTARG) \
55 ix86_va_start (VALIST, NEXTARG)
57 -#define TARGET_ASM_FILE_END ix86_file_end
58 +#define TARGET_ASM_FILE_END ix86_elf_file_end
59 #define NEED_INDICATE_EXEC_STACK 0
61 /* Output assembler code to FILE to increment profiler label # LABELNO
62 diff -uNrp gcc-4_1-branch/gcc.orig/output.h gcc-4_1-branch/gcc/output.h
63 --- gcc-4_1-branch/gcc.orig/output.h 2005-11-30 11:16:27.000000000 +0000
64 +++ gcc-4_1-branch/gcc/output.h 2005-12-06 17:42:34.018988936 +0000
65 @@ -586,6 +586,12 @@ extern void default_file_start (void);
66 extern void file_end_indicate_exec_stack (void);
67 extern bool default_valid_pointer_mode (enum machine_mode);
69 +extern void default_elf_asm_output_external (FILE *file, tree,
71 +extern void default_elf_asm_output_external_1 (tree);
72 +extern void default_elf_asm_file_end (void);
73 +extern int maybe_assemble_visibility (tree);
75 extern int default_address_cost (rtx);
77 /* dbxout helper functions */
78 diff -uNrp gcc-4_1-branch/gcc.orig/tree.h gcc-4_1-branch/gcc/tree.h
79 --- gcc-4_1-branch/gcc.orig/tree.h 2005-11-30 11:16:27.000000000 +0000
80 +++ gcc-4_1-branch/gcc/tree.h 2005-12-06 17:42:34.022988328 +0000
81 @@ -4070,6 +4070,17 @@ extern void process_pending_assemble_ext
82 extern void finish_aliases_1 (void);
83 extern void finish_aliases_2 (void);
85 +/* Linked list of all external symbols that are to be emitted by
88 +struct extern_symbol_list GTY(())
90 + struct extern_symbol_list *next;
94 +extern GTY(()) struct extern_symbol_list *extern_symbol_head;
97 extern void expand_computed_goto (tree);
98 extern bool parse_output_constraint (const char **, int, int, int,
99 diff -uNrp gcc-4_1-branch/gcc.orig/varasm.c gcc-4_1-branch/gcc/varasm.c
100 --- gcc-4_1-branch/gcc.orig/varasm.c 2005-11-30 11:16:27.000000000 +0000
101 +++ gcc-4_1-branch/gcc/varasm.c 2005-12-06 17:42:34.026987720 +0000
102 @@ -126,7 +126,6 @@ static unsigned HOST_WIDE_INT array_size
103 static unsigned min_align (unsigned, unsigned);
104 static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int);
105 static void globalize_decl (tree);
106 -static void maybe_assemble_visibility (tree);
107 static int in_named_entry_eq (const void *, const void *);
108 static hashval_t in_named_entry_hash (const void *);
109 static void initialize_cold_section_name (void);
110 @@ -4952,13 +4951,18 @@ default_assemble_visibility (tree decl,
112 /* A helper function to call assemble_visibility when needed for a decl. */
116 maybe_assemble_visibility (tree decl)
118 enum symbol_visibility vis = DECL_VISIBILITY (decl);
120 if (vis != VISIBILITY_DEFAULT)
121 - targetm.asm_out.visibility (decl, vis);
123 + targetm.asm_out.visibility (decl, vis);
130 /* Returns 1 if the target configuration supports defining public symbols
131 @@ -5725,4 +5729,64 @@ file_end_indicate_exec_stack (void)
132 named_section_flags (".note.GNU-stack", flags);
135 +struct extern_symbol_list *extern_symbol_head;
138 +default_elf_asm_output_external_1 (tree decl)
140 + struct extern_symbol_list *p
141 + = ggc_alloc (sizeof (struct extern_symbol_list));
144 + p->next = extern_symbol_head;
145 + extern_symbol_head = p;
148 +/* Emit text to declare externally defined symbols. It is needed to
149 + properly support non-default visibility. */
152 +default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
156 + /* Ignore builtin functions. */
157 + if (TREE_CODE (decl) == FUNCTION_DECL
158 + && strstr (name, "__builtin_") == name)
161 + default_elf_asm_output_external_1 (decl);
164 +/* Print out the list of referenced global symbols with non-default
168 +default_elf_asm_file_end (void)
170 + struct extern_symbol_list *p;
172 + for (p = extern_symbol_head; p; p = p->next)
174 + tree decl = p->decl;
175 + tree id = DECL_ASSEMBLER_NAME (decl);
180 + /* We output the name if and only if TREE_SYMBOL_REFERENCED is
181 + set in order to avoid putting out names that are never really
183 + if (targetm.binds_local_p (decl)
184 + && !TREE_ASM_WRITTEN (decl)
185 + && TREE_SYMBOL_REFERENCED (id))
187 + maybe_assemble_visibility (decl);
188 + TREE_ASM_WRITTEN (decl) = 1;
192 + extern_symbol_head = 0;
195 #include "gt-varasm.h"