Skip to content

Commit

Permalink
bfd/coff-arm: handle bfd_link_hash_undefweak, allowing undefined weak…
Browse files Browse the repository at this point in the history
… symbols

Copy code from cofflink.c (commits
bc7a577 and
c87db18) to fix linker failures with
C++11 "thread_local" variables.
  • Loading branch information
MaxKellermann committed Mar 20, 2018
1 parent dab7e90 commit db72da0
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bfd/coff-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ coff_arm_relocate_section (bfd *output_bfd,
struct internal_syment * sym;
bfd_vma addend;
bfd_vma val;
asection *sec;
reloc_howto_type * howto;
bfd_reloc_status_type rstat;
bfd_vma h_val;
Expand Down Expand Up @@ -1568,6 +1569,42 @@ coff_arm_relocate_section (bfd *output_bfd,
+ sec->output_offset);
}

else if (h->root.type == bfd_link_hash_undefweak)
{
if (h->symbol_class == C_NT_WEAK && h->numaux == 1)
{
/* See _Microsoft Portable Executable and Common Object
File Format Specification_, section 5.5.3.
Note that weak symbols without aux records are a GNU
extension.
FIXME: All weak externals are treated as having
characteristic IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY (1).
These behave as per SVR4 ABI: A library member
will resolve a weak external only if a normal
external causes the library member to be linked.
See also linker.c: generic_link_check_archive_element. */
struct coff_link_hash_entry *h2 =
h->auxbfd->tdata.coff_obj_data->sym_hashes[
h->aux->x_sym.x_tagndx.l];

if (!h2 || h2->root.type == bfd_link_hash_undefined)
{
sec = bfd_abs_section_ptr;
val = 0;
}
else
{
sec = h2->root.u.def.section;
val = h2->root.u.def.value
+ sec->output_section->vma + sec->output_offset;
}
}
else
/* This is a GNU extension. */
val = 0;
}


else if (! bfd_link_relocatable (info))
(*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd, input_section,
Expand Down

0 comments on commit db72da0

Please sign in to comment.