/* IA-64 support for 64-bit ELF
- Copyright (C) 1998-2020 Free Software Foundation, Inc.
+ Copyright (C) 1998-2021 Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of BFD, the Binary File Descriptor library.
&& !strcmp (name, ELF_STRING_ia64_unwind_hdr))
return FALSE;
- return ((CONST_STRNEQ (name, ELF_STRING_ia64_unwind)
- && ! CONST_STRNEQ (name, ELF_STRING_ia64_unwind_info))
- || CONST_STRNEQ (name, ELF_STRING_ia64_unwind_once));
+ return ((startswith (name, ELF_STRING_ia64_unwind)
+ && ! startswith (name, ELF_STRING_ia64_unwind_info))
+ || startswith (name, ELF_STRING_ia64_unwind_once));
}
/* Handle an IA-64 specific section when reading an object file. This
key.addend = addend;
dyn_i = bsearch (&key, info, sorted_count,
sizeof (*info), addend_compare);
-
if (dyn_i)
- {
- return dyn_i;
- }
+ return dyn_i;
}
- /* Do a quick check for the last inserted entry. */
- dyn_i = info + count - 1;
- if (dyn_i->addend == addend)
+ if (count != 0)
{
- return dyn_i;
+ /* Do a quick check for the last inserted entry. */
+ dyn_i = info + count - 1;
+ if (dyn_i->addend == addend)
+ return dyn_i;
}
}
if (size != count)
{
amt = count * sizeof (*info);
- info = bfd_malloc (amt);
- if (info != NULL)
- {
- memcpy (info, *info_p, amt);
- free (*info_p);
- *size_p = count;
- *info_p = info;
- }
+ info = bfd_realloc (info, amt);
+ *size_p = count;
+ if (info == NULL && count != 0)
+ /* realloc should never fail since we are reducing size here,
+ but if it does use the old array. */
+ info = *info_p;
+ else
+ *info_p = info;
}
- key.addend = addend;
- dyn_i = bsearch (&key, info, count,
- sizeof (*info), addend_compare);
+ if (count == 0)
+ dyn_i = NULL;
+ else
+ {
+ key.addend = addend;
+ dyn_i = bsearch (&key, info, count, sizeof (*info), addend_compare);
+ }
}
return dyn_i;
else
h = NULL;
- if (h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
- continue;
-
/* We can only get preliminary data on whether a symbol is
locally or externally defined, as not all of the input files
have yet been processed. Do something with what we know, as
else
h = NULL;
- if (h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
- continue;
-
/* We can only get preliminary data on whether a symbol is
locally or externally defined, as not all of the input files
have yet been processed. Do something with what we know, as
if (!bfd_link_executable (x->info)
&& (!h
- || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
- && !UNDEFWEAK_NO_DYNAMIC_RELOC (x->info, h))
+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| (h->root.type != bfd_link_hash_undefweak
&& h->root.type != bfd_link_hash_undefined)))
{
shared = bfd_link_pic (x->info);
resolved_zero = (dyn_i->h
- && UNDEFWEAK_NO_DYNAMIC_RELOC (x->info,
- dyn_i->h));
+ && ELF_ST_VISIBILITY (dyn_i->h->other)
+ && dyn_i->h->root.type == bfd_link_hash_undefweak);
/* Take care of the GOT and PLT relocations. */
if (strcmp (name, ".got.plt") == 0)
strip = FALSE;
- else if (CONST_STRNEQ (name, ".rel"))
+ else if (startswith (name, ".rel"))
{
if (!strip)
{
/* Install a dynamic relocation if needed. */
if (((bfd_link_pic (info)
&& (!dyn_i->h
- || (ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
- && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, dyn_i->h))
+ || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
|| dyn_i->h->root.type != bfd_link_hash_undefweak)
&& dyn_r_type != R_IA64_DTPREL32LSB
&& dyn_r_type != R_IA64_DTPREL64LSB)
if (!is_plt
&& bfd_link_pic (info)
&& (!dyn_i->h
- || (ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
- && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, dyn_i->h))
+ || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
|| dyn_i->h->root.type != bfd_link_hash_undefweak))
{
unsigned int dyn_r_type;
case R_IA64_DIR64LSB:
/* Install a dynamic relocation for this reloc. */
if ((dynamic_symbol_p || bfd_link_pic (info))
- && !(h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
&& r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0)
{
if (elf_sec_group (sec) == NULL
&& ((sec->flags & (SEC_LINK_ONCE | SEC_CODE | SEC_GROUP))
== (SEC_LINK_ONCE | SEC_CODE))
- && CONST_STRNEQ (sec->name, ".gnu.linkonce.t."))
+ && startswith (sec->name, ".gnu.linkonce.t."))
{
name = sec->name + 16;