aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/ChangeLog20
-rw-r--r--bfd/elf-bfd.h8
-rw-r--r--bfd/elf.c19
-rw-r--r--bfd/elf32-cris.c9
-rw-r--r--bfd/elf32-hppa.c31
-rw-r--r--bfd/elf32-mips.c10
-rw-r--r--bfd/elflink.h37
-rw-r--r--bfd/elfxx-ia64.c13
8 files changed, 82 insertions, 65 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2c738ad..bb49ce6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,23 @@
+2002-01-21 Alan Modra <amodra@bigpond.net.au>
+
+ * 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.
+
2002-01-18 Alan Modra <amodra@bigpond.net.au>
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Test for a
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 4a1ee2a..0bd559f 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -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_elf_link_hash_table_create
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 *,
diff --git a/bfd/elf.c b/bfd/elf.c
index 2c14de8..1df8459 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1286,14 +1286,23 @@ _bfd_elf_link_hash_copy_indirect (dir, ind)
}
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. */
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 6ee0d9c..2e3add1 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -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_symbol
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
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 5dfd6f2..0acfb19 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -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, sec, relocs)
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. */
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 41b5909..bdeed28 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -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, string)
}
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++;
diff --git a/bfd/elflink.h b/bfd/elflink.h
index bf63192..47927d3 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -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);
}
}
}
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index ee49f5a..6baf778 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -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_new_elf_hash_entry
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, xind)
}
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;