This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix visibility for MIPS (Re: 2 problems with ELF visibility)
On Wed, Apr 24, 2002 at 11:53:06PM +0930, Alan Modra wrote:
> On Mon, Apr 22, 2002 at 12:44:47PM -0700, H . J . Lu wrote:
> > I am enclosing a patch here. Any comments?
> >
> > * elfxx-mips.c (mips_elf_link_hash_entry): Add forced_local.
> > (mips_elf_link_hash_newfunc): Initialize forced_local to false.
> > (mips_elf_record_global_got_symbol): Call _bfd_mips_elf_hide_symbol
> > to hide a global symbol.
> > (_bfd_mips_elf_hide_symbol): Return if forced_local is true. Set
> > forced_local to true.
>
> The idea seems reasonable, but why can't you use ELF_LINK_FORCED_LOCAL
> instead of using a new flag?
>
Here is a patch which does that.
H.J.
----
2002-04-24 H.J. Lu (hjl@gnu.org)
* elf-bfd.h (elf_backend_data): Add elf_backend_force_local_symbol.
(_bfd_elf_link_hash_force_local_symbol): New. Declared.
* elf.c (_bfd_elf_link_hash_force_local_symbol): New. Defined.
* elf32-mips.c (elf_backend_force_local_symbol): New. Defined.
* elf64-mips.c (elf_backend_force_local_symbol): Likewise.
* elflink.c (_bfd_elf_link_record_dynamic_symbol): Call
elf_backend_force_local_symbol.
* elfxx-mips.c (_bfd_mips_elf_hide_symbol): Do nothing if
ELF_LINK_FORCED_LOCAL is already set.
(_bfd_mips_elf_force_local_symbol): New. Defined.
* elfxx-mips.h (_bfd_mips_elf_force_local_symbol): New. Declared.
* elfxx-target.h (elf_backend_force_local_symbol): New. Defined if
not defined.
(elfNN_bed): Add elf_backend_force_local_symbol.
--- bfd/elf-bfd.h.local Tue Apr 23 15:18:14 2002
+++ bfd/elf-bfd.h Wed Apr 24 09:58:34 2002
@@ -703,6 +703,10 @@ struct elf_backend_data
void (*elf_backend_hide_symbol)
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
+ /* Make a global symbol local. */
+ void (*elf_backend_force_local_symbol)
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+
/* Emit relocations. Overrides default routine for emitting relocs,
except during a relocatable link, or if all relocs are being emitted. */
void (*elf_backend_emit_relocs)
@@ -1214,6 +1218,8 @@ extern void _bfd_elf_link_hash_copy_indi
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 *, boolean));
+extern void _bfd_elf_link_hash_force_local_symbol
+ PARAMS ((struct bfd_link_info *, 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 *,
--- bfd/elf.c.local Tue Apr 23 15:18:16 2002
+++ bfd/elf.c Wed Apr 24 09:52:32 2002
@@ -1320,6 +1320,14 @@ _bfd_elf_link_hash_hide_symbol (info, h,
}
}
+void
+_bfd_elf_link_hash_force_local_symbol (info, h)
+ struct bfd_link_info *info ATTRIBUTE_UNUSED;
+ struct elf_link_hash_entry *h;
+{
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+}
+
/* Initialize an ELF linker hash table. */
boolean
--- bfd/elf32-mips.c.local Tue Apr 23 15:18:18 2002
+++ bfd/elf32-mips.c Wed Apr 24 10:43:08 2002
@@ -2196,6 +2196,7 @@ static const struct ecoff_debug_swap mip
#define elf_backend_copy_indirect_symbol \
_bfd_mips_elf_copy_indirect_symbol
#define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
+#define elf_backend_force_local_symbol _bfd_mips_elf_force_local_symbol
#define elf_backend_grok_prstatus elf32_mips_grok_prstatus
#define elf_backend_grok_psinfo elf32_mips_grok_psinfo
#define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
--- bfd/elf64-mips.c.local Tue Apr 23 15:18:20 2002
+++ bfd/elf64-mips.c Wed Apr 24 10:42:54 2002
@@ -2719,6 +2719,7 @@ const struct elf_size_info mips_elf64_si
#define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
#define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
#define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
+#define elf_backend_force_local_symbol _bfd_mips_elf_force_local_symbol
#define elf_backend_mips_irix_compat elf64_mips_irix_compat
#define elf_backend_mips_rtype_to_howto mips_elf64_rtype_to_howto
#define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
--- bfd/elflink.c.local Tue Apr 23 15:18:22 2002
+++ bfd/elflink.c Wed Apr 24 10:28:13 2002
@@ -247,7 +247,10 @@ _bfd_elf_link_record_dynamic_symbol (inf
if (h->root.type != bfd_link_hash_undefined
&& h->root.type != bfd_link_hash_undefweak)
{
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (h->root.u.def.section->owner);
+ (*bed->elf_backend_force_local_symbol) (info, h);
return true;
}
--- bfd/elfxx-mips.c.local Thu Apr 4 11:53:37 2002
+++ bfd/elfxx-mips.c Wed Apr 24 10:41:49 2002
@@ -6384,7 +6384,11 @@ _bfd_mips_elf_hide_symbol (info, entry,
asection *got;
struct mips_got_info *g;
struct mips_elf_link_hash_entry *h;
+
h = (struct mips_elf_link_hash_entry *) entry;
+ if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ return;
+
dynobj = elf_hash_table (info)->dynobj;
got = bfd_get_section_by_name (dynobj, ".got");
g = (struct mips_got_info *) elf_section_data (got)->tdata;
@@ -6395,6 +6399,14 @@ _bfd_mips_elf_hide_symbol (info, entry,
g->local_gotno++;
got->_raw_size += MIPS_ELF_GOT_SIZE (dynobj);
}
+
+void
+_bfd_mips_elf_force_local_symbol (info, entry)
+ struct bfd_link_info *info;
+ struct elf_link_hash_entry *entry;
+{
+ _bfd_mips_elf_hide_symbol (info, entry, true);
+}
/* MIPS ELF uses a special find_nearest_line routine in order the
handle the ECOFF debugging information. */
--- bfd/elfxx-mips.h.local Wed Apr 3 23:10:00 2002
+++ bfd/elfxx-mips.h Wed Apr 24 10:43:55 2002
@@ -71,6 +71,8 @@ extern void _bfd_mips_elf_copy_indirect_
PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
extern void _bfd_mips_elf_hide_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
+extern void _bfd_mips_elf_force_local_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
extern boolean _bfd_mips_elf_find_nearest_line
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
const char **, unsigned int *));
--- bfd/elfxx-target.h.local Tue Apr 23 15:18:24 2002
+++ bfd/elfxx-target.h Wed Apr 24 09:59:28 2002
@@ -341,6 +341,9 @@ Foundation, Inc., 59 Temple Place - Suit
#ifndef elf_backend_hide_symbol
#define elf_backend_hide_symbol _bfd_elf_link_hash_hide_symbol
#endif
+#ifndef elf_backend_force_local_symbol
+#define elf_backend_force_local_symbol _bfd_elf_link_hash_force_local_symbol
+#endif
#ifndef elf_backend_emit_relocs
#define elf_backend_emit_relocs NULL
#endif
@@ -458,6 +461,7 @@ static const struct elf_backend_data elf
elf_backend_output_arch_syms,
elf_backend_copy_indirect_symbol,
elf_backend_hide_symbol,
+ elf_backend_force_local_symbol,
elf_backend_emit_relocs,
elf_backend_count_relocs,
elf_backend_grok_prstatus,