This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
elf_backend_hide_symbol
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Mon, 21 Jan 2002 20:56:03 +1030
- Subject: elf_backend_hide_symbol
This patch moves the _bfd_elf_strtab_delref call, and setting of
ELF_LINK_FORCED_LOCAL associated with most elf_backend_hide_symbol
calls into the backend routine. mips and ia64 were missing
strtab_delref calls, which is incidentally fixed by this patch.
I've also changed a bfd_alloc call in elflink.h to bfd_malloc, as
bfd_release should be avoided where there is any chance that
intervening functions might want to bfd_alloc.
bfd/ChangeLog
* elf-bfd.h (elf_backend_data <elf_backend_hide_symbol>): Add
boolean param.
(_bfd_elf_link_hash_hide_symbol): Likewise.
* elflink.h (elf_link_add_object_symbols): Adjust call to
elf_backend_hide_symbol.
(elf_fix_symbol_flags): Likewise.
(elf_link_assign_sym_version): Likewise. Use bfd_malloc rather
than bfd_alloc.
* elf.c (_bfd_elf_link_hash_hide_symbol): Add "force_local" param.
Set ELF_LINK_FORCED_LOCAL and call _bfd_elf_strtab_delref.
* elf32-hppa.c (elf32_hppa_hide_symbol): Likewise.
(clobber_millicode_symbols): Adjust to suit new hide_symbol.
* elf32-cris.c (elf_cris_hide_symbol): Add "force_local" param
and adjust to suit.
* elf32-mips.c (_bfd_mips_elf_hide_symbol): Likewise, and call
_bfd_elf_link_hash_hide_symbol rather than duplicating code.
* elfxx-ia64.c (elfNN_ia64_hash_hide_symbol): Likewise.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.65
diff -u -p -r1.65 elf-bfd.h
--- elf-bfd.h 2002/01/17 13:02:40 1.65
+++ elf-bfd.h 2002/01/21 06:14:58
@@ -1,6 +1,6 @@
/* BFD back-end data structures for ELF files.
- Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ 2002 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -693,7 +693,7 @@ struct elf_backend_data
/* Modify any information related to dynamic linking such that the
symbol is not exported. */
void (*elf_backend_hide_symbol)
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
/* Emit relocations. Overrides default routine for emitting relocs,
except during a relocatable link, or if all relocs are being emitted. */
@@ -1197,7 +1197,7 @@ extern struct bfd_link_hash_table *_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 bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
extern boolean _bfd_elf_link_hash_table_init
PARAMS ((struct elf_link_hash_table *, bfd *,
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.140
diff -u -p -r1.140 elflink.h
--- elflink.h 2002/01/16 05:37:10 1.140
+++ elflink.h 2002/01/21 06:15:36
@@ -2056,10 +2056,7 @@ elf_link_add_object_symbols (abfd, info)
{
case STV_INTERNAL:
case STV_HIDDEN:
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- (*bed->elf_backend_hide_symbol) (info, h);
- _bfd_elf_strtab_delref (hash_table->dynstr,
- h->dynstr_index);
+ (*bed->elf_backend_hide_symbol) (info, h, true);
break;
}
@@ -3873,16 +3870,13 @@ elf_fix_symbol_flags (h, eif)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
{
struct elf_backend_data *bed;
+ boolean force_local;
bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
- if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
- || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
- {
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- _bfd_elf_strtab_delref (elf_hash_table (eif->info)->dynstr,
- h->dynstr_index);
- }
- (*bed->elf_backend_hide_symbol) (eif->info, h);
+
+ force_local = (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
+ || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN);
+ (*bed->elf_backend_hide_symbol) (eif->info, h, force_local);
}
/* If this is a weak defined symbol in a dynamic object, and we know
@@ -4233,7 +4227,7 @@ elf_link_assign_sym_version (h, data)
struct bfd_elf_version_expr *d;
len = p - h->root.root.string;
- alc = bfd_alloc (sinfo->output_bfd, (bfd_size_type) len);
+ alc = bfd_malloc ((bfd_size_type) len);
if (alc == NULL)
return false;
strncpy (alc, h->root.root.string, len - 1);
@@ -4264,10 +4258,7 @@ elf_link_assign_sym_version (h, data)
&& info->shared
&& ! info->export_dynamic)
{
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- (*bed->elf_backend_hide_symbol) (info, h);
- _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
- h->dynstr_index);
+ (*bed->elf_backend_hide_symbol) (info, h, true);
}
break;
@@ -4275,7 +4266,7 @@ elf_link_assign_sym_version (h, data)
}
}
- bfd_release (sinfo->output_bfd, alc);
+ free (alc);
break;
}
}
@@ -4379,10 +4370,7 @@ elf_link_assign_sym_version (h, data)
&& info->shared
&& ! info->export_dynamic)
{
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- (*bed->elf_backend_hide_symbol) (info, h);
- _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
- h->dynstr_index);
+ (*bed->elf_backend_hide_symbol) (info, h, true);
}
break;
}
@@ -4400,10 +4388,7 @@ elf_link_assign_sym_version (h, data)
&& info->shared
&& ! info->export_dynamic)
{
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- (*bed->elf_backend_hide_symbol) (info, h);
- _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
- h->dynstr_index);
+ (*bed->elf_backend_hide_symbol) (info, h, true);
}
}
}
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.123
diff -u -p -r1.123 elf.c
--- elf.c 2002/01/17 13:02:40 1.123
+++ elf.c 2002/01/21 06:15:08
@@ -1286,14 +1286,23 @@ _bfd_elf_link_hash_copy_indirect (dir, i
}
void
-_bfd_elf_link_hash_hide_symbol (info, h)
- struct bfd_link_info *info ATTRIBUTE_UNUSED;
+_bfd_elf_link_hash_hide_symbol (info, h, force_local)
+ struct bfd_link_info *info;
struct elf_link_hash_entry *h;
+ boolean force_local;
{
- h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
h->plt.offset = (bfd_vma) -1;
- if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
- h->dynindx = -1;
+ h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+ if (force_local)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ if (h->dynindx != -1)
+ {
+ h->dynindx = -1;
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+ h->dynstr_index);
+ }
+ }
}
/* Initialize an ELF linker hash table. */
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.22
diff -u -p -r1.22 elf32-cris.c
--- elf32-cris.c 2001/12/17 00:52:35 1.22
+++ elf32-cris.c 2002/01/21 06:15:10
@@ -1,5 +1,5 @@
/* CRIS-specific support for 32-bit ELF.
- Copyright 2000, 2001 Free Software Foundation, Inc.
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Axis Communications AB.
Written by Hans-Peter Nilsson, based on elf32-fr30.c
PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
@@ -90,7 +90,7 @@ static boolean elf_cris_finish_dynamic_s
static boolean elf_cris_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static void elf_cris_hide_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
static enum elf_reloc_type_class elf_cris_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
@@ -2028,13 +2028,14 @@ elf_cris_try_fold_plt_to_got (h, p)
entry. */
static void
-elf_cris_hide_symbol (info, h)
+elf_cris_hide_symbol (info, h, force_local)
struct bfd_link_info *info;
struct elf_link_hash_entry *h;
+ boolean force_local;
{
elf_cris_adjust_gotplt_to_got ((struct elf_cris_link_hash_entry *) h, info);
- _bfd_elf_link_hash_hide_symbol (info, h);
+ _bfd_elf_link_hash_hide_symbol (info, h, force_local);
}
/* Adjust a symbol defined by a dynamic object and referenced by a
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.68
diff -u -p -r1.68 elf32-hppa.c
--- elf32-hppa.c 2001/12/17 00:52:34 1.68
+++ elf32-hppa.c 2002/01/21 06:15:14
@@ -1,6 +1,6 @@
/* BFD back-end for HP PA-RISC ELF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
+ 2002 Free Software Foundation, Inc.
Original code by
Center for Software Science
@@ -335,7 +335,7 @@ static boolean elf32_hppa_gc_sweep_hook
asection *, const Elf_Internal_Rela *));
static void elf32_hppa_hide_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
static boolean elf32_hppa_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
@@ -1786,12 +1786,22 @@ elf32_hppa_gc_sweep_hook (abfd, info, se
plabels. */
static void
-elf32_hppa_hide_symbol (info, h)
- struct bfd_link_info *info ATTRIBUTE_UNUSED;
+elf32_hppa_hide_symbol (info, h, force_local)
+ struct bfd_link_info *info;
struct elf_link_hash_entry *h;
+ boolean force_local;
{
- if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
- h->dynindx = -1;
+ if (force_local)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ if (h->dynindx != -1)
+ {
+ h->dynindx = -1;
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+ h->dynstr_index);
+ }
+ }
+
if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel)
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
@@ -2206,12 +2216,7 @@ clobber_millicode_symbols (h, info)
if (h->type == STT_PARISC_MILLI
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
{
- struct elf32_hppa_link_hash_table *htab;
-
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- elf32_hppa_hide_symbol (info, h);
- htab = hppa_link_hash_table (info);
- _bfd_elf_strtab_delref (htab->elf.dynstr, h->dynstr_index);
+ elf32_hppa_hide_symbol (info, h, true);
/* ?!? We only want to remove these from the dynamic symbol table.
Therefore we do not leave ELF_LINK_FORCED_LOCAL set. */
Index: bfd/elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.138
diff -u -p -r1.138 elf32-mips.c
--- elf32-mips.c 2002/01/17 20:06:48 1.138
+++ elf32-mips.c 2002/01/21 06:15:23
@@ -211,7 +211,7 @@ static boolean mips_elf_stub_section_p
static int sort_dynamic_relocs
PARAMS ((const void *, const void *));
static void _bfd_mips_elf_hide_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
static void _bfd_mips_elf_copy_indirect_symbol
PARAMS ((struct elf_link_hash_entry *,
struct elf_link_hash_entry *));
@@ -4503,9 +4503,10 @@ mips_elf_link_hash_newfunc (entry, table
}
static void
-_bfd_mips_elf_hide_symbol (info, entry)
+_bfd_mips_elf_hide_symbol (info, entry, force_local)
struct bfd_link_info *info;
struct elf_link_hash_entry *entry;
+ boolean force_local;
{
bfd *dynobj;
asection *got;
@@ -4516,10 +4517,7 @@ _bfd_mips_elf_hide_symbol (info, entry)
got = bfd_get_section_by_name (dynobj, ".got");
g = (struct mips_got_info *) elf_section_data (got)->tdata;
- h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
- h->root.plt.offset = (bfd_vma) -1;
- if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
- h->root.dynindx = -1;
+ _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
/* FIXME: Do we allocate too much GOT space here? */
g->local_gotno++;
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.41
diff -u -p -r1.41 elfxx-ia64.c
--- elfxx-ia64.c 2002/01/17 13:02:40 1.41
+++ elfxx-ia64.c 2002/01/21 06:15:40
@@ -1,5 +1,5 @@
/* IA-64 support for 64-bit ELF
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of BFD, the Binary File Descriptor library.
@@ -204,7 +204,7 @@ static struct bfd_hash_entry *elfNN_ia64
static void elfNN_ia64_hash_copy_indirect
PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
static void elfNN_ia64_hash_hide_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
static struct bfd_link_hash_table *elfNN_ia64_hash_table_create
PARAMS ((bfd *abfd));
static struct elfNN_ia64_local_hash_entry *elfNN_ia64_local_hash_lookup
@@ -1646,18 +1646,17 @@ elfNN_ia64_hash_copy_indirect (xdir, xin
}
static void
-elfNN_ia64_hash_hide_symbol (info, xh)
- struct bfd_link_info *info ATTRIBUTE_UNUSED;
+elfNN_ia64_hash_hide_symbol (info, xh, force_local)
+ struct bfd_link_info *info;
struct elf_link_hash_entry *xh;
+ boolean force_local;
{
struct elfNN_ia64_link_hash_entry *h;
struct elfNN_ia64_dyn_sym_info *dyn_i;
h = (struct elfNN_ia64_link_hash_entry *)xh;
- h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
- if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
- h->root.dynindx = -1;
+ _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next)
dyn_i->want_plt2 = 0;