1 2002-06-04 Richard Henderson <rth@redhat.com>
2 Jakub Jelinek <jakub@redhat.com>
4 * config/i386/i386.c (USE_HIDDEN_LINKONCE): New.
5 (ix86_asm_file_end): If USE_HIDDEN_LINKONCE, emit get_pc thunks
6 into linkonce sections.
7 (load_pic_register): Set up pic_label_name for it.
9 --- gcc/config/i386/i386.c.jj Mon Jun 3 17:24:13 2002
10 +++ gcc/config/i386/i386.c Tue Jun 4 15:49:17 2002
11 @@ -3786,6 +3786,12 @@ ix86_setup_frame_addresses ()
12 cfun->machine->accesses_prev_frame = 1;
15 +#if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
16 +# define USE_HIDDEN_LINKONCE 1
18 +# define USE_HIDDEN_LINKONCE 0
21 static char pic_label_name[32];
23 /* This function generates code for -fpic that loads %ebx with
24 @@ -3800,10 +3806,6 @@ ix86_asm_file_end (file)
25 if (! TARGET_DEEP_BRANCH_PREDICTION || pic_label_name[0] == 0)
28 - /* ??? Binutils 2.10 and earlier has a linkonce elimination bug related
29 - to updating relocations to a section being discarded such that this
30 - doesn't work. Ought to detect this at configure time. */
32 /* The trick here is to create a linkonce section containing the
33 pic label thunk, but to refer to it with an internal label.
34 Because the label is internal, we don't have inter-dso name
35 @@ -3811,28 +3813,27 @@ ix86_asm_file_end (file)
37 In order to use these macros, however, we must create a fake
39 - if (targetm.have_named_sections)
40 + if (USE_HIDDEN_LINKONCE && targetm.have_named_sections)
42 tree decl = build_decl (FUNCTION_DECL,
43 - get_identifier ("i686.get_pc_thunk"),
44 + get_identifier (pic_label_name),
46 + TREE_PUBLIC (decl) = 1;
47 + TREE_STATIC (decl) = 1;
48 DECL_ONE_ONLY (decl) = 1;
49 UNIQUE_SECTION (decl, 0);
50 - named_section (decl, NULL);
51 + named_section (decl, NULL, 0);
52 + ASM_GLOBALIZE_LABEL (file, pic_label_name);
53 + fputs ("\t.hidden\t", file);
54 + assemble_name (file, pic_label_name);
56 + ASM_DECLARE_FUNCTION_NAME (file, pic_label_name, decl);
63 - /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
64 - internal (non-global) label that's being emitted, it didn't make
65 - sense to have .type information for local labels. This caused
66 - the SCO OpenServer 5.0.4 ELF assembler grief (why are you giving
67 - me debug info for a label that you're declaring non-global?) this
68 - was changed to call ASM_OUTPUT_LABEL() instead. */
70 - ASM_OUTPUT_LABEL (file, pic_label_name);
73 + ASM_OUTPUT_LABEL (file, pic_label_name);
76 xops[0] = pic_offset_table_rtx;
77 xops[1] = gen_rtx_MEM (SImode, stack_pointer_rtx);
78 @@ -3853,7 +3854,12 @@ load_pic_register ()
79 if (TARGET_DEEP_BRANCH_PREDICTION)
81 if (! pic_label_name[0])
82 - ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
84 + if (USE_HIDDEN_LINKONCE && targetm.have_named_sections)
85 + strcpy (pic_label_name, "__i686.get_pc_thunk.bx");
87 + ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
89 pclab = gen_rtx_MEM (QImode, gen_rtx_SYMBOL_REF (Pmode, pic_label_name));