View | Details | Raw Unified | Return to bug 28157
Collapse All | Expand All

(-)a/gas/config/obj-elf.c (-2 / +44 lines)
Lines 2705-2711 elf_frob_symbol (symbolS *symp, int *puntp) Link Here
2705
		S_SET_EXTERNAL (symp2);
2705
		S_SET_EXTERNAL (symp2);
2706
	    }
2706
	    }
2707
2707
2708
	  switch (symbol_get_obj (symp)->visibility)
2708
	  switch (sy_obj->visibility)
2709
	    {
2709
	    {
2710
	    case visibility_unchanged:
2710
	    case visibility_unchanged:
2711
	      break;
2711
	      break;
Lines 2716-2722 elf_frob_symbol (symbolS *symp, int *puntp) Link Here
2716
	      elfsym->internal_elf_sym.st_other |= STV_HIDDEN;
2716
	      elfsym->internal_elf_sym.st_other |= STV_HIDDEN;
2717
	      break;
2717
	      break;
2718
	    case visibility_remove:
2718
	    case visibility_remove:
2719
	      symbol_remove (symp, &symbol_rootP, &symbol_lastP);
2719
	      /* Don't remove the symbol if it is used on relocation and
2720
	         issue an error if the symbol has more than one versioned
2721
		 name.  */
2722
	      if (symbol_used_in_reloc_p (symp) == 0)
2723
		symbol_remove (symp, &symbol_rootP, &symbol_lastP);
2724
	      else if (sy_obj->versioned_name->next != NULL)
2725
		as_bad (_("symbol '%s' with ambiguous version cannot be used on reloc"),
2726
			S_GET_NAME (symp));
2720
	      break;
2727
	      break;
2721
	    case visibility_local:
2728
	    case visibility_local:
2722
	      S_CLEAR_EXTERNAL (symp);
2729
	      S_CLEAR_EXTERNAL (symp);
Lines 2734-2739 elf_frob_symbol (symbolS *symp, int *puntp) Link Here
2734
    }
2741
    }
2735
}
2742
}
2736
2743
2744
/* Return true if SYMP is removed by .symver.  */
2745
2746
bool
2747
elf_removed_symbol_p (symbolS *symp)
2748
{
2749
  return symbol_get_obj (symp)->visibility == visibility_remove;
2750
}
2751
2752
/* Fix up SYMPP if it is removed by .symver.  */
2753
2754
void
2755
elf_fixup_symbol (symbolS **sympp)
2756
{
2757
  symbolS *symp = *sympp;
2758
  struct elf_obj_sy *sy_obj;
2759
2760
  /* Return if there is nothing to fix up.  */
2761
  if (symp == NULL)
2762
    return;
2763
2764
  /* Return if it isn't removed by .symver.  */
2765
  sy_obj = symbol_get_obj (symp);
2766
  if (sy_obj->visibility != visibility_remove)
2767
    return;
2768
2769
  /* There should be one and only one versioned symbol.  */
2770
  if (sy_obj->versioned_name == NULL
2771
      || sy_obj->versioned_name->next != NULL)
2772
    abort ();
2773
2774
  /* Replace the removed symbol with the versioned symbol.  */
2775
  symp = symbol_find (sy_obj->versioned_name->name);
2776
  *sympp = symp;
2777
}
2778
2737
struct group_list
2779
struct group_list
2738
{
2780
{
2739
  asection **head;		/* Section lists.  */
2781
  asection **head;		/* Section lists.  */
(-)a/gas/config/obj-elf.h (+10 lines)
Lines 273-278 extern void elf_frob_symbol (symbolS *, int *); Link Here
273
#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
273
#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
274
#endif
274
#endif
275
275
276
extern void elf_fixup_symbol (symbolS **);
277
#ifndef obj_fixup_symbol
278
#define obj_fixup_symbol(sympp) elf_fixup_symbol (sympp)
279
#endif
280
281
extern bool elf_removed_symbol_p (symbolS *);
282
#ifndef obj_removed_symbol_p
283
#define obj_removed_symbol_p(symp) elf_removed_symbol_p (symp)
284
#endif
285
276
extern void elf_pop_insert (void);
286
extern void elf_pop_insert (void);
277
#ifndef obj_pop_insert
287
#ifndef obj_pop_insert
278
#define obj_pop_insert()	elf_pop_insert()
288
#define obj_pop_insert()	elf_pop_insert()
(-)a/gas/testsuite/gas/symver/symver11.d (-1 / +1 lines)
Lines 1-2 Link Here
1
#name: symver symver11
1
#name: symver symver11
2
#error: .*symbol cannot be used on reloc
2
#error: .*: symbol 'foo' with ambiguous version cannot be used on reloc
(-)a/gas/testsuite/gas/symver/symver16.d (+13 lines)
Line 0 Link Here
1
#name: symver symver16
2
#readelf: -srW
3
4
#...
5
Relocation section .*
6
#...
7
[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+foo@@VERS_1.*
8
#...
9
[0-9a-f]+[ \t]+[0-9a-f]+[ \t]+R_.*[ \t]+[0-9a-f]+[ \t]+bar@VERS_1.*
10
#...
11
 +[0-9]+: 0+ +1 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo@@VERS_1
12
 +[0-9]+: 0+1 +1 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +bar@VERS_1
13
#pass
(-)a/gas/testsuite/gas/symver/symver16.s (+16 lines)
Line 0 Link Here
1
	.data
2
	.type foo,%object
3
foo:
4
	.byte 0
5
	.size foo,.-foo
6
	.globl foo
7
	.symver foo,foo@@VERS_1,remove
8
	.globl bar
9
	.symver bar,bar@VERS_1,remove
10
	.type bar,%object
11
bar:
12
	.byte 0
13
	.size bar,.-bar
14
	.balign 8
15
	.dc.a foo
16
	.dc.a bar
(-)a/gas/write.c (-7 / +17 lines)
Lines 102-107 Link Here
102
#define TC_FX_SIZE_SLACK(FIX) 0
102
#define TC_FX_SIZE_SLACK(FIX) 0
103
#endif
103
#endif
104
104
105
#ifndef obj_removed_symbol_p
106
#define obj_removed_symbol_p(symbp) false
107
#endif
108
105
/* Used to control final evaluation of expressions.  */
109
/* Used to control final evaluation of expressions.  */
106
int finalize_syms = 0;
110
int finalize_syms = 0;
107
111
Lines 1289-1294 write_relocs (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, Link Here
1289
	as_bad_where (fixp->fx_file, fixp->fx_line,
1293
	as_bad_where (fixp->fx_file, fixp->fx_line,
1290
		      _("internal error: fixup not contained within frag"));
1294
		      _("internal error: fixup not contained within frag"));
1291
1295
1296
#ifdef obj_fixup_symbol
1297
      obj_fixup_symbol (&fixp->fx_addsy);
1298
      obj_fixup_symbol (&fixp->fx_subsy);
1299
#endif
1300
1292
#ifndef RELOC_EXPANSION_POSSIBLE
1301
#ifndef RELOC_EXPANSION_POSSIBLE
1293
      *reloc = tc_gen_reloc (sec, fixp);
1302
      *reloc = tc_gen_reloc (sec, fixp);
1294
#else
1303
#else
Lines 1755-1763 set_symtab (void) Link Here
1755
     two.  Generate unused section symbols only if needed.  */
1764
     two.  Generate unused section symbols only if needed.  */
1756
  nsyms = 0;
1765
  nsyms = 0;
1757
  for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1766
  for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1758
    if (bfd_keep_unused_section_symbols (stdoutput)
1767
    if (!obj_removed_symbol_p (symp)
1759
	|| !symbol_section_p (symp)
1768
	&& (bfd_keep_unused_section_symbols (stdoutput)
1760
	|| symbol_used_in_reloc_p (symp))
1769
	    || !symbol_section_p (symp)
1770
	    || symbol_used_in_reloc_p (symp)))
1761
      nsyms++;
1771
      nsyms++;
1762
1772
1763
  if (nsyms)
1773
  if (nsyms)
Lines 1768-1776 set_symtab (void) Link Here
1768
      asympp = (asymbol **) bfd_alloc (stdoutput, amt);
1778
      asympp = (asymbol **) bfd_alloc (stdoutput, amt);
1769
      symp = symbol_rootP;
1779
      symp = symbol_rootP;
1770
      for (i = 0; i < nsyms; symp = symbol_next (symp))
1780
      for (i = 0; i < nsyms; symp = symbol_next (symp))
1771
	if (bfd_keep_unused_section_symbols (stdoutput)
1781
	if (!obj_removed_symbol_p (symp)
1772
	    || !symbol_section_p (symp)
1782
	    && (bfd_keep_unused_section_symbols (stdoutput)
1773
	    || symbol_used_in_reloc_p (symp))
1783
		|| !symbol_section_p (symp)
1784
		|| symbol_used_in_reloc_p (symp)))
1774
	  {
1785
	  {
1775
	    asympp[i] = symbol_get_bfdsym (symp);
1786
	    asympp[i] = symbol_get_bfdsym (symp);
1776
	    if (asympp[i]->flags != BSF_SECTION_SYM
1787
	    if (asympp[i]->flags != BSF_SECTION_SYM
1777
- 

Return to bug 28157