This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/2] Update _bfd_elf_symbol_refs_local_p/add UNDEFINED_WEAK_RESOLVED_TO_ZERO
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Cc: Alan Modra <amodra at gmail dot com>
- Date: Fri, 6 Oct 2017 17:29:08 -0700
- Subject: [PATCH 1/2] Update _bfd_elf_symbol_refs_local_p/add UNDEFINED_WEAK_RESOLVED_TO_ZERO
- Authentication-results: sourceware.org; auth=none
Update _bfd_elf_symbol_refs_local_p to cache result and handle undefined
weak symbols and check version script.
Add UNDEFINED_WEAK_RESOLVED_TO_ZERO to check if an undefined weak symbol
should be resolved to 0.
PR ld/22269
* elf-bfd.h (elf_link_hash_entry): Add local_ref and
zero_undefweak. Moved from elf_x86_link_hash_entry.
(UNDEFINED_WEAK_RESOLVED_TO_ZERO): New. Moved from elfxx-x86.h.
* elf32-i386.c (elf_i386_convert_load_reloc): Replace
SYMBOL_REFERENCES_LOCAL_P with SYMBOL_REFERENCES_LOCAL.
(elf_i386_check_relocs): Updated access to zero_undefweak.
(elf_i386_relocate_section): Update
UNDEFINED_WEAK_RESOLVED_TO_ZERO. Replace
SYMBOL_REFERENCES_LOCAL_P with SYMBOL_REFERENCES_LOCAL.
(elf_i386_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Replace
SYMBOL_REFERENCES_LOCAL_P with SYMBOL_REFERENCES_LOCAL.
(elf_x86_64_check_reloc): Updated access to zero_undefweak.
(elf_x86_64_relocate_section): Update
UNDEFINED_WEAK_RESOLVED_TO_ZERO. Replace
SYMBOL_REFERENCES_LOCAL_P with SYMBOL_REFERENCES_LOCAL.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elflink.c (_bfd_elf_symbol_refs_local_p): Cache the result
in local_ref. Handle undefined weak symbols and check version
script.
(_bfd_elf_link_hash_newfunc): Initialize zero_undefweak to 1.
(_bfd_elf_link_hash_copy_indirect): Also copy zero_undefweak.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Update
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
(_bfd_x86_elf_link_hash_newfunc): Update zero_undefweak.
(_bfd_x86_elf_link_check_relocs): Update local_ref.
(_bfd_x86_elf_copy_indirect_symbol): Remove zero_undefweak.
(_bfd_x86_elf_fixup_symbol): Update
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
(_bfd_x86_elf_adjust_dynamic_symbol): Check call to undefined
weak function which shouldn't be resolved to 0.
(_bfd_x86_elf_link_symbol_references_local): Removed.
* elfxx-x86.h (SYMBOL_REFERENCES_LOCAL_P): Removed.
(UNDEFINED_WEAK_RESOLVED_TO_ZERO): Likewise.
(_bfd_x86_elf_link_symbol_references_local): Likewise.
(RESOLVED_LOCALLY_P): Replace SYMBOL_REFERENCES_LOCAL_P with
SYMBOL_REFERENCES_LOCAL.
(elf_x86_link_hash_entry): Remove zero_undefweak and local_ref.
---
bfd/elf-bfd.h | 20 ++++++++++++++
bfd/elf32-i386.c | 30 ++++++++++-----------
bfd/elf64-x86-64.c | 32 +++++++++++-----------
bfd/elflink.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++-------
bfd/elfxx-x86.c | 60 +++++------------------------------------
bfd/elfxx-x86.h | 31 +--------------------
6 files changed, 128 insertions(+), 124 deletions(-)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 399e298a8d..491e25d61f 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -216,6 +216,16 @@ struct elf_link_hash_entry
/* Symbol is __start_SECNAME or __stop_SECNAME to mark section
SECNAME. */
unsigned int start_stop : 1;
+ /* 0: Symbol references are unknown.
+ 1: Symbol references aren't local.
+ 2: Symbol references are local.
+ */
+ unsigned int local_ref : 2;
+ /* Bit 0: Symbol has no GOT nor PLT relocations.
+ Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
+ zero_undefweak is initialized to 1 and undefined weak symbol
+ should be resolved to 0 if zero_undefweak > 0. */
+ unsigned int zero_undefweak : 2;
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
@@ -266,6 +276,16 @@ struct elf_link_hash_entry
#define SYMBOL_CALLS_LOCAL(INFO, H) \
_bfd_elf_symbol_refs_local_p (H, INFO, 1)
+/* TRUE if an undefined weak symbol should be resolved to 0. Local
+ undefined weak symbol is always resolved to 0. Reference to an
+ undefined weak symbol is resolved to 0 in executable if undefined
+ weak symbol should be resolved to 0 (zero_undefweak > 0). */
+#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, H) \
+ ((H)->root.type == bfd_link_hash_undefweak \
+ && (SYMBOL_REFERENCES_LOCAL ((INFO), (H)) \
+ || (bfd_link_executable (INFO) \
+ && (H)->zero_undefweak > 0)))
+
/* Common symbols that are turned into definitions don't have the
DEF_REGULAR flag set, so they might appear to be undefined.
Symbols defined in linker scripts also don't have DEF_REGULAR set. */
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index f752de6063..0506d31a0a 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1296,8 +1296,8 @@ elf_i386_convert_load_reloc (bfd *abfd, Elf_Internal_Shdr *symtab_hdr,
goto convert_load;
}
- /* NB: Also set linker_def via SYMBOL_REFERENCES_LOCAL_P. */
- local_ref = SYMBOL_REFERENCES_LOCAL_P (link_info, h);
+ /* NB: Also set linker_def via SYMBOL_REFERENCES_LOCAL. */
+ local_ref = SYMBOL_REFERENCES_LOCAL (link_info, h);
/* Undefined weak symbol is only bound locally in executable
and its reference is resolved as 0. */
@@ -1619,7 +1619,7 @@ elf_i386_check_relocs (bfd *abfd,
if (h == NULL)
continue;
- eh->zero_undefweak &= 0x2;
+ h->zero_undefweak &= 0x2;
h->needs_plt = 1;
h->plt.refcount += 1;
break;
@@ -1745,16 +1745,16 @@ elf_i386_check_relocs (bfd *abfd,
create_got:
if (r_type != R_386_TLS_IE)
{
- if (eh != NULL)
- eh->zero_undefweak &= 0x2;
+ if (h != NULL)
+ h->zero_undefweak &= 0x2;
break;
}
/* Fall through */
case R_386_TLS_LE_32:
case R_386_TLS_LE:
- if (eh != NULL)
- eh->zero_undefweak &= 0x2;
+ if (h != NULL)
+ h->zero_undefweak &= 0x2;
if (bfd_link_executable (info))
break;
info->flags |= DF_STATIC_TLS;
@@ -1762,8 +1762,8 @@ elf_i386_check_relocs (bfd *abfd,
case R_386_32:
case R_386_PC32:
- if (eh != NULL && (sec->flags & SEC_CODE) != 0)
- eh->zero_undefweak |= 0x2;
+ if (h != NULL && (sec->flags & SEC_CODE) != 0)
+ h->zero_undefweak |= 0x2;
do_relocation:
/* We are called after all symbols have been resolved. Only
relocation against STT_GNU_IFUNC symbol must go through
@@ -2438,8 +2438,8 @@ do_ifunc_pointer:
}
}
- resolved_to_zero = (eh != NULL
- && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
+ resolved_to_zero = (h != NULL
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h));
switch (r_type)
{
@@ -2663,7 +2663,7 @@ disallow_got32:
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
- else if (!SYMBOL_REFERENCES_LOCAL_P (info, h)
+ else if (!SYMBOL_REFERENCES_LOCAL (info, h)
&& (h->type == STT_FUNC
|| h->type == STT_OBJECT)
&& ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
@@ -3552,7 +3552,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
/* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
resolved undefined weak symbols in executable so that their
references have value 0 at run-time. */
- local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
+ local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h);
if (h->plt.offset != (bfd_vma) -1)
{
@@ -3835,7 +3835,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
in static executable. */
relgot = htab->elf.irelplt;
}
- if (SYMBOL_REFERENCES_LOCAL_P (info, h))
+ if (SYMBOL_REFERENCES_LOCAL (info, h))
{
info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
h->root.root.string,
@@ -3885,7 +3885,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
}
}
else if (bfd_link_pic (info)
- && SYMBOL_REFERENCES_LOCAL_P (info, h))
+ && SYMBOL_REFERENCES_LOCAL (info, h))
{
BFD_ASSERT((h->got.offset & 1) != 0);
rel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 0b0aa6cb4d..d27e043236 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1541,8 +1541,8 @@ elf_x86_64_convert_load_reloc (bfd *abfd,
bfd_boolean local_ref;
struct elf_x86_link_hash_entry *eh = elf_x86_hash_entry (h);
- /* NB: Also set linker_def via SYMBOL_REFERENCES_LOCAL_P. */
- local_ref = SYMBOL_REFERENCES_LOCAL_P (link_info, h);
+ /* NB: Also set linker_def via SYMBOL_REFERENCES_LOCAL. */
+ local_ref = SYMBOL_REFERENCES_LOCAL (link_info, h);
if ((relocx || opcode == 0x8b)
&& (h->root.type == bfd_link_hash_undefweak
&& !eh->linker_def
@@ -1957,8 +1957,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (!bfd_link_executable (info) && ABI_64_P (abfd))
return elf_x86_64_need_pic (info, abfd, sec, h, symtab_hdr, isym,
&x86_64_elf_howto_table[r_type]);
- if (eh != NULL)
- eh->zero_undefweak &= 0x2;
+ if (h != NULL)
+ h->zero_undefweak &= 0x2;
break;
case R_X86_64_GOTTPOFF:
@@ -2065,8 +2065,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_X86_64_GOTPC32:
case R_X86_64_GOTPC64:
create_got:
- if (eh != NULL)
- eh->zero_undefweak &= 0x2;
+ if (h != NULL)
+ h->zero_undefweak &= 0x2;
break;
case R_X86_64_PLT32:
@@ -2083,7 +2083,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (h == NULL)
continue;
- eh->zero_undefweak &= 0x2;
+ h->zero_undefweak &= 0x2;
h->needs_plt = 1;
h->plt.refcount += 1;
break;
@@ -2133,8 +2133,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
case R_X86_64_PC64:
case R_X86_64_64:
pointer:
- if (eh != NULL && (sec->flags & SEC_CODE) != 0)
- eh->zero_undefweak |= 0x2;
+ if (h != NULL && (sec->flags & SEC_CODE) != 0)
+ h->zero_undefweak |= 0x2;
/* We are called after all symbols have been resolved. Only
relocation against STT_GNU_IFUNC symbol must go through
PLT. */
@@ -2738,8 +2738,8 @@ do_ifunc_pointer:
}
}
- resolved_to_zero = (eh != NULL
- && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
+ resolved_to_zero = (h != NULL
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h));
/* When generating a shared object, the relocations handled here are
copied into the output file to be resolved at run time. */
@@ -2906,7 +2906,7 @@ do_ifunc_pointer:
return FALSE;
}
else if (!bfd_link_executable (info)
- && !SYMBOL_REFERENCES_LOCAL_P (info, h)
+ && !SYMBOL_REFERENCES_LOCAL (info, h)
&& (h->type == STT_FUNC
|| h->type == STT_OBJECT)
&& ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
@@ -3054,7 +3054,7 @@ do_ifunc_pointer:
|| r_type == R_X86_64_PC32_BND)
&& is_32bit_relative_branch (contents, rel->r_offset));
- if (SYMBOL_REFERENCES_LOCAL_P (info, h))
+ if (SYMBOL_REFERENCES_LOCAL (info, h))
{
/* Symbol is referenced locally. Make sure it is
defined locally or for a branch. */
@@ -3912,7 +3912,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
/* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
resolved undefined weak symbols in executable so that their
references have value 0 at run-time. */
- local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
+ local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h);
if (h->plt.offset != (bfd_vma) -1)
{
@@ -4175,7 +4175,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
in static executable. */
relgot = htab->elf.irelplt;
}
- if (SYMBOL_REFERENCES_LOCAL_P (info, h))
+ if (SYMBOL_REFERENCES_LOCAL (info, h))
{
info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
h->root.root.string,
@@ -4224,7 +4224,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
}
}
else if (bfd_link_pic (info)
- && SYMBOL_REFERENCES_LOCAL_P (info, h))
+ && SYMBOL_REFERENCES_LOCAL (info, h))
{
if (!(h->def_regular || ELF_COMMON_DEF_P (h)))
return FALSE;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1a990582cb..6a20ec69af 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3103,14 +3103,52 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
if (h == NULL)
return TRUE;
+ if (h->local_ref > 1)
+ return TRUE;
+
+ if (h->local_ref == 1)
+ return FALSE;
+
/* STV_HIDDEN or STV_INTERNAL ones must be local. */
if (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
|| ELF_ST_VISIBILITY (h->other) == STV_INTERNAL)
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
/* Forced local symbols resolve locally. */
if (h->forced_local)
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
+
+ hash_table = elf_hash_table (info);
+
+ /* Unversioned symbols defined in regular objects can be forced local
+ by linker version script. A weak undefined symbol is forced local
+ if
+ 1. It has non-default visibility. Or
+ 2. When building executable, there is no dynamic linker. Or
+ 3. or "-z nodynamic-undefined-weak" is used.
+ */
+ if ((h->root.type == bfd_link_hash_undefweak
+ && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+ || (bfd_link_executable (info)
+ && (info->nointerp
+ || !is_elf_hash_table (hash_table)
+ || !hash_table->dynamic_sections_created))
+ || info->dynamic_undefined_weak == 0))
+ || ((h->def_regular || ELF_COMMON_DEF_P (h))
+ && h->versioned == unversioned
+ && info->version_info != NULL
+ && bfd_hide_sym_by_version (info->version_info,
+ h->root.root.string)))
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
/* Common symbols that become definitions don't get the DEF_REGULAR
flag set, so test it first, and don't bail out. */
@@ -3119,26 +3157,40 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
/* If we don't have a definition in a regular file, then we can't
resolve locally. The sym is either undefined or dynamic. */
else if (!h->def_regular)
- return FALSE;
+ {
+ h->local_ref = 1;
+ return FALSE;
+ }
/* Non-dynamic symbols resolve locally. */
if (h->dynindx == -1)
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
/* At this point, we know the symbol is defined and dynamic. In an
executable it must resolve locally, likewise when building symbolic
shared libraries. */
if (bfd_link_executable (info) || SYMBOLIC_BIND (info, h))
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
/* Now deal with defined dynamic symbols in shared libraries. Ones
with default visibility might not resolve locally. */
if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
- return FALSE;
+ {
+ h->local_ref = 1;
+ return FALSE;
+ }
- hash_table = elf_hash_table (info);
if (!is_elf_hash_table (hash_table))
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
bed = get_elf_backend_data (hash_table->dynobj);
@@ -3148,13 +3200,19 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
|| (info->extern_protected_data < 0
&& !bed->extern_protected_data))
&& !bed->is_function_type (h->type))
- return TRUE;
+ {
+ h->local_ref = 2;
+ return TRUE;
+ }
/* Function pointer equality tests may require that STV_PROTECTED
symbols be treated as dynamic symbols. If the address of a
function not defined in an executable is set to that function's
plt entry in the executable, then the address of the function in
- a shared library must also be the plt entry in the executable. */
+ a shared library must also be the plt entry in the executable.
+
+ We must leave local_ref as unknown since it depends on
+ local_protected. */
return local_protected;
}
@@ -7245,6 +7303,7 @@ _bfd_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
file. This ensures that a symbol created by a non-ELF symbol
reader will have the flag set correctly. */
ret->non_elf = 1;
+ ret->zero_undefweak = 1;
}
return entry;
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 9d5cfbf7e7..b728773edb 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -107,7 +107,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h,
plt_entry_size = htab->plt.plt_entry_size;
- resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
+ resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h);
/* Clear the reference count of function pointer relocations if
symbol isn't a normal function. */
@@ -673,10 +673,10 @@ _bfd_x86_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
file. This ensures that a symbol created by a non-ELF symbol
reader will have the flag set correctly. */
eh->elf.non_elf = 1;
+ eh->elf.zero_undefweak = 1;
eh->plt_second.offset = (bfd_vma) -1;
eh->plt_got.offset = (bfd_vma) -1;
eh->tlsdesc_got = (bfd_vma) -1;
- eh->zero_undefweak = 1;
}
return entry;
@@ -862,7 +862,7 @@ _bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
|| h->root.type == bfd_link_hash_undefweak
|| h->root.type == bfd_link_hash_common))
{
- elf_x86_hash_entry (h)->local_ref = 2;
+ h->local_ref = 2;
elf_x86_hash_entry (h)->linker_def = 1;
}
}
@@ -1408,8 +1408,6 @@ _bfd_x86_elf_copy_indirect_symbol (struct bfd_link_info *info,
generate a R_386_COPY reloc. */
edir->gotoff_ref |= eind->gotoff_ref;
- edir->zero_undefweak |= eind->zero_undefweak;
-
if (ELIMINATE_COPY_RELOCS
&& ind->root.type != bfd_link_hash_indirect
&& dir->dynamic_adjusted)
@@ -1443,8 +1441,7 @@ bfd_boolean
_bfd_x86_elf_fixup_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
- if (h->dynindx != -1
- && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, elf_x86_hash_entry (h)))
+ if (h->dynindx != -1 && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h))
{
h->dynindx = -1;
_bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
@@ -1538,7 +1535,9 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|| h->needs_plt)
{
if (h->plt.refcount <= 0
- || SYMBOL_CALLS_LOCAL (info, h)
+ || (SYMBOL_CALLS_LOCAL (info, h)
+ && (h->root.type != bfd_link_hash_undefweak
+ || h->zero_undefweak > 0))
|| (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
&& h->root.type == bfd_link_hash_undefweak))
{
@@ -1669,51 +1668,6 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
-/* Return TRUE if a symbol is referenced locally. It is similar to
- SYMBOL_REFERENCES_LOCAL, but it also checks version script. It
- works in check_relocs. */
-
-bfd_boolean
-_bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
-{
- struct elf_x86_link_hash_entry *eh = elf_x86_hash_entry (h);
- struct elf_x86_link_hash_table *htab
- = (struct elf_x86_link_hash_table *) info->hash;
-
- if (eh->local_ref > 1)
- return TRUE;
-
- if (eh->local_ref == 1)
- return FALSE;
-
- /* Unversioned symbols defined in regular objects can be forced local
- by linker version script. A weak undefined symbol is forced local
- if
- 1. It has non-default visibility. Or
- 2. When building executable, there is no dynamic linker. Or
- 3. or "-z nodynamic-undefined-weak" is used.
- */
- if (SYMBOL_REFERENCES_LOCAL (info, h)
- || (h->root.type == bfd_link_hash_undefweak
- && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
- || (bfd_link_executable (info)
- && htab->interp == NULL)
- || info->dynamic_undefined_weak == 0))
- || ((h->def_regular || ELF_COMMON_DEF_P (h))
- && h->versioned == unversioned
- && info->version_info != NULL
- && bfd_hide_sym_by_version (info->version_info,
- h->root.root.string)))
- {
- eh->local_ref = 2;
- return TRUE;
- }
-
- eh->local_ref = 1;
- return FALSE;
-}
-
/* Return the section that should be marked against GC for a given
relocation. */
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index a2f5fc235a..b051ad5001 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -45,20 +45,6 @@
&& elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \
? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL)
-/* Will references to this symbol always be local in this object? */
-#define SYMBOL_REFERENCES_LOCAL_P(INFO, H) \
- _bfd_x86_elf_link_symbol_references_local ((INFO), (H))
-
-/* TRUE if an undefined weak symbol should be resolved to 0. Local
- undefined weak symbol is always resolved to 0. Reference to an
- undefined weak symbol is resolved to 0 in executable if undefined
- weak symbol should be resolved to 0 (zero_undefweak > 0). */
-#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
- ((EH)->elf.root.type == bfd_link_hash_undefweak \
- && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf) \
- || (bfd_link_executable (INFO) \
- && (EH)->zero_undefweak > 0)))
-
/* Should copy relocation be generated for a symbol. Don't generate
copy relocation against a protected symbol defined in a shared
object with GNU_PROPERTY_NO_COPY_ON_PROTECTED. */
@@ -155,7 +141,7 @@
(!WILL_CALL_FINISH_DYNAMIC_SYMBOL ((HTAB)->elf.dynamic_sections_created, \
bfd_link_pic (INFO), (H)) \
|| (bfd_link_pic (INFO) \
- && SYMBOL_REFERENCES_LOCAL_P ((INFO), (H))) \
+ && SYMBOL_REFERENCES_LOCAL ((INFO), (H))) \
|| (ELF_ST_VISIBILITY ((H)->other) \
&& (H)->root.type == bfd_link_hash_undefweak))
@@ -232,12 +218,6 @@ struct elf_x86_link_hash_entry
unsigned char tls_type;
- /* Bit 0: Symbol has no GOT nor PLT relocations.
- Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
- zero_undefweak is initialized to 1 and undefined weak symbol
- should be resolved to 0 if zero_undefweak > 0. */
- unsigned int zero_undefweak : 2;
-
/* Don't call finish_dynamic_symbol on this symbol. */
unsigned int no_finish_dynamic_symbol : 1;
@@ -247,12 +227,6 @@ struct elf_x86_link_hash_entry
/* TRUE if symbol is defined as a protected symbol. */
unsigned int def_protected : 1;
- /* 0: Symbol references are unknown.
- 1: Symbol references aren't local.
- 2: Symbol references are local.
- */
- unsigned int local_ref : 2;
-
/* TRUE if symbol is defined by linker. */
unsigned int linker_def : 1;
@@ -621,9 +595,6 @@ extern bfd_boolean _bfd_x86_elf_hash_symbol
extern bfd_boolean _bfd_x86_elf_adjust_dynamic_symbol
(struct bfd_link_info *, struct elf_link_hash_entry *);
-extern bfd_boolean _bfd_x86_elf_link_symbol_references_local
- (struct bfd_link_info *, struct elf_link_hash_entry *);
-
extern asection * _bfd_x86_elf_gc_mark_hook
(asection *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *);
--
2.13.6