xtensa: fix relaxation of undefined weak references in shared objects

The change c451bb34ae ("xtensa: don't emit dynamic relocation for weak
undefined symbol") didn't properly handle shrinking of relocation
sections due to coalescing of references to a dynamic undefined weak
symbol in a shared object, which resulted in the following assertion
failure in ld when linking uClibc-ng libthread_db for xtensa:

  BFD (GNU Binutils) 2.31 internal error, aborting at elf32-xtensa.c:3269
  in elf_xtensa_finish_dynamic_sections

Shrink dynamic relocations section for dynamic undefined weak symbols
when linking a shared object.

bfd/
2018-07-23  Max Filippov  <jcmvbkbc@gmail.com>

	* elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
	relocations section for dynamic undefined weak symbols when
	linking a shared object.
This commit is contained in:
Max Filippov 2018-07-22 13:52:28 -07:00
parent 01bcaf636a
commit 5d3a462f05
2 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2018-07-23 Max Filippov <jcmvbkbc@gmail.com>
* elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
relocations section for dynamic undefined weak symbols when
linking a shared object.
2018-07-23 Tom Tromey <tom@tromey.com>
* elf.c (bfd_get_elf_phdrs): Don't call memcpy with size 0.

View File

@ -10022,7 +10022,8 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info,
if ((r_type == R_XTENSA_32 || r_type == R_XTENSA_PLT)
&& (input_section->flags & SEC_ALLOC) != 0
&& (dynamic_symbol || bfd_link_pic (info))
&& (!h || h->root.type != bfd_link_hash_undefweak))
&& (!h || h->root.type != bfd_link_hash_undefweak
|| (dynamic_symbol && bfd_link_dll (info))))
{
asection *srel;
bfd_boolean is_plt = FALSE;