This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: hooks for versioning symbol manipulation
- To: binutils at sourceware dot cygnus dot com
- Subject: Re: hooks for versioning symbol manipulation
- From: Richard Henderson <rth at cygnus dot com>
- Date: Fri, 18 Feb 2000 01:24:13 -0800
- References: <20000213151522.A24438@cygnus.com>
At Ian's suggestion, I rearranged things to use
the ELF backend data structure instead.
r~
* elf-bfd.h (struct elf_link_hash_table): Remove copy_indirect
and hide_symbol members.
(elf_link_hash_copy_indirect): Remove.
(elf_link_hash_hide_symbol): Remove.
(struct elf_backend_data): Add elf_backend_copy_indirect_symbol
and elf_backend_hide_symbol.
(_bfd_elf_link_hash_copy_indirect): Declare.
(_bfd_elf_link_hash_hide_symbol): Declare.
* elf.c (_bfd_elf_link_hash_copy_indirect): Remove table argument.
(_bfd_elf_link_hash_hide_symbol): Likewise.
(_bfd_elf_link_hash_table_init): Don't init killed members.
* elflink.h (elf_link_add_object_symbols): Use the bed function
pointers not elf_link_hash_{copy_indirect,hide_symbol}.
(elf_link_assign_sym_version): Likewise.
* elfxx-target.h (elf_backend_copy_indirect_symbol): Default.
(elf_backend_hide_symbol): Likewise.
(elfNN_bed): Update for new members.
Index: elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.19
diff -c -p -d -r1.19 elf-bfd.h
*** elf-bfd.h 2000/02/17 00:33:34 1.19
--- elf-bfd.h 2000/02/18 09:17:25
*************** struct elf_link_hash_table
*** 243,254 ****
PTR stab_info;
/* A linked list of local symbols to be added to .dynsym. */
struct elf_link_local_dynamic_entry *dynlocal;
-
- void (*copy_indirect) PARAMS ((struct elf_link_hash_table *,
- struct elf_link_hash_entry *,
- struct elf_link_hash_entry *));
- void (*hide_symbol) PARAMS ((struct elf_link_hash_table *,
- struct elf_link_hash_entry *));
};
/* Look up an entry in an ELF linker hash table. */
--- 243,248 ----
*************** struct elf_link_hash_table
*** 269,284 ****
/* Get the ELF linker hash table from a link_info structure. */
#define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
-
- /* Call the copy_indirect method. */
-
- #define elf_link_hash_copy_indirect(TABLE,DIR,IND) \
- ((*(TABLE)->copy_indirect) ((TABLE), (DIR), (IND)))
-
- /* Call the hide_symbol method. */
-
- #define elf_link_hash_hide_symbol(TABLE,SYM) \
- ((*(TABLE)->hide_symbol) ((TABLE), (SYM)))
/* Constant information held for an ELF backend. */
--- 263,268 ----
*************** struct elf_backend_data
*** 609,614 ****
--- 593,608 ----
boolean (*) PARAMS ((PTR, const char *,
Elf_Internal_Sym *, asection *))));
+ /* Copy any information related to dynamic linking from a pre-existing
+ symbol IND to a newly created symbol DIR. */
+ void (*elf_backend_copy_indirect_symbol)
+ PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+
+ /* Modify any information related to dynamic linking such that the
+ symbol is not exported. */
+ void (*elf_backend_hide_symbol)
+ PARAMS ((struct elf_link_hash_entry *));
+
/* The swapping table to use when dealing with ECOFF information.
Used for the MIPS ELF .mdebug section. */
const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
*************** extern struct bfd_hash_entry *_bfd_elf_l
*** 973,978 ****
--- 967,976 ----
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
PARAMS ((bfd *));
+ extern void _bfd_elf_link_hash_copy_indirect
+ PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
+ extern void _bfd_elf_link_hash_hide_symbol
+ PARAMS ((struct elf_link_hash_entry *));
extern boolean _bfd_elf_link_hash_table_init
PARAMS ((struct elf_link_hash_table *, bfd *,
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.23
diff -c -p -d -r1.23 elf.c
*** elf.c 2000/02/13 23:11:32 1.23
--- elf.c 2000/02/18 09:17:25
*************** _bfd_elf_link_hash_newfunc (entry, table
*** 909,917 ****
/* Copy data from an indirect symbol to its direct symbol, hiding the
old indirect symbol. */
! static void
! _bfd_elf_link_hash_copy_indirect (table, dir, ind)
! struct elf_link_hash_table *table;
struct elf_link_hash_entry *dir, *ind;
{
/* Copy down any references that we may have already seen to the
--- 909,916 ----
/* Copy data from an indirect symbol to its direct symbol, hiding the
old indirect symbol. */
! void
! _bfd_elf_link_hash_copy_indirect (dir, ind)
struct elf_link_hash_entry *dir, *ind;
{
/* Copy down any references that we may have already seen to the
*************** _bfd_elf_link_hash_copy_indirect (table,
*** 950,958 ****
BFD_ASSERT (ind->dynindx == -1);
}
! static void
! _bfd_elf_link_hash_hide_symbol(table, h)
! struct elf_link_hash_table *table;
struct elf_link_hash_entry *h;
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
--- 949,956 ----
BFD_ASSERT (ind->dynindx == -1);
}
! void
! _bfd_elf_link_hash_hide_symbol(h)
struct elf_link_hash_entry *h;
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
*************** _bfd_elf_link_hash_table_init (table, ab
*** 979,986 ****
table->needed = NULL;
table->hgot = NULL;
table->stab_info = NULL;
- table->copy_indirect = _bfd_elf_link_hash_copy_indirect;
- table->hide_symbol = _bfd_elf_link_hash_hide_symbol;
return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
}
--- 977,982 ----
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.45
diff -c -p -d -r1.45 elflink.h
*** elflink.h 2000/02/13 23:11:32 1.45
--- elflink.h 2000/02/18 09:17:26
*************** elf_link_add_object_symbols (abfd, info)
*** 890,898 ****
struct elf_link_hash_entry *weaks;
Elf_External_Sym *esym;
Elf_External_Sym *esymend;
! add_symbol_hook = get_elf_backend_data (abfd)->elf_add_symbol_hook;
! collect = get_elf_backend_data (abfd)->collect;
if ((abfd->flags & DYNAMIC) == 0)
dynamic = false;
--- 890,900 ----
struct elf_link_hash_entry *weaks;
Elf_External_Sym *esym;
Elf_External_Sym *esymend;
+ struct elf_backend_data *bed;
! bed = get_elf_backend_data (abfd);
! add_symbol_hook = bed->elf_add_symbol_hook;
! collect = bed->collect;
if ((abfd->flags & DYNAMIC) == 0)
dynamic = false;
*************** elf_link_add_object_symbols (abfd, info)
*** 1734,1741 ****
== 0);
ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
! elf_link_hash_copy_indirect (elf_hash_table (info),
! ht, hi);
/* See if the new flags lead us to realize that
the symbol must be dynamic. */
--- 1736,1742 ----
== 0);
ht = (struct elf_link_hash_entry *) hi->root.u.i.link;
! (*bed->elf_backend_copy_indirect_symbol) (ht, hi);
/* See if the new flags lead us to realize that
the symbol must be dynamic. */
*************** elf_link_add_object_symbols (abfd, info)
*** 1808,1815 ****
| ELF_LINK_HASH_DEF_REGULAR))
== 0);
! elf_link_hash_copy_indirect (elf_hash_table (info),
! h, hi);
/* See if the new flags lead us to realize
that the symbol must be dynamic. */
--- 1809,1815 ----
| ELF_LINK_HASH_DEF_REGULAR))
== 0);
! (*bed->elf_backend_copy_indirect_symbol) (h, hi);
/* See if the new flags lead us to realize
that the symbol must be dynamic. */
*************** elf_link_assign_sym_version (h, data)
*** 3600,3605 ****
--- 3600,3606 ----
struct elf_assign_sym_version_info *sinfo =
(struct elf_assign_sym_version_info *) data;
struct bfd_link_info *info = sinfo->info;
+ struct elf_backend_data *bed;
struct elf_info_failed eif;
char *p;
*************** elf_link_assign_sym_version (h, data)
*** 3618,3623 ****
--- 3619,3625 ----
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
return true;
+ bed = get_elf_backend_data (sinfo->output_bfd);
p = strchr (h->root.root.string, ELF_VER_CHR);
if (p != NULL && h->verinfo.vertree == NULL)
{
*************** elf_link_assign_sym_version (h, data)
*** 3685,3692 ****
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! elf_link_hash_hide_symbol (elf_hash_table (info),
! h);
/* FIXME: The name of the symbol has
already been recorded in the dynamic
string table section. */
--- 3687,3693 ----
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! (*bed->elf_backend_hide_symbol) (h);
/* FIXME: The name of the symbol has
already been recorded in the dynamic
string table section. */
*************** elf_link_assign_sym_version (h, data)
*** 3798,3804 ****
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! elf_link_hash_hide_symbol (elf_hash_table (info), h);
/* FIXME: The name of the symbol has already
been recorded in the dynamic string table
section. */
--- 3799,3805 ----
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! (*bed->elf_backend_hide_symbol) (h);
/* FIXME: The name of the symbol has already
been recorded in the dynamic string table
section. */
*************** elf_link_assign_sym_version (h, data)
*** 3820,3826 ****
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! elf_link_hash_hide_symbol (elf_hash_table (info), h);
/* FIXME: The name of the symbol has already been
recorded in the dynamic string table section. */
}
--- 3821,3827 ----
&& ! sinfo->export_dynamic)
{
h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
! (*bed->elf_backend_hide_symbol) (h);
/* FIXME: The name of the symbol has already been
recorded in the dynamic string table section. */
}
Index: elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.13
diff -c -p -d -r1.13 elfxx-target.h
*** elfxx-target.h 1999/12/10 18:51:35 1.13
--- elfxx-target.h 2000/02/18 09:17:26
*************** Foundation, Inc., 59 Temple Place - Suit
*** 306,311 ****
--- 306,318 ----
#ifndef elf_backend_output_arch_syms
#define elf_backend_output_arch_syms NULL
#endif
+ #ifndef elf_backend_copy_indirect_symbol
+ #define elf_backend_copy_indirect_symbol _bfd_elf_link_hash_copy_indirect
+ #endif
+ #ifndef elf_backend_hide_symbol
+ #define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol
+ #endif
+
/* Previously, backends could only use SHT_REL or SHT_RELA relocation
sections, but not both. They defined USE_REL to indicate SHT_REL
*************** static CONST struct elf_backend_data elf
*** 383,388 ****
--- 390,397 ----
elf_backend_post_process_headers,
elf_backend_print_symbol_all,
elf_backend_output_arch_syms,
+ elf_backend_copy_indirect_symbol,
+ elf_backend_hide_symbol,
elf_backend_ecoff_debug_swap,
ELF_MACHINE_ALT1,
ELF_MACHINE_ALT2,