[1/5] xtensa: fix relaxation of undefined weak references in shared objects

Message ID 20180723181030.11632-2-jcmvbkbc@gmail.com
State New
Headers show
Series
  • xtensa: fix for ld and testsuite improvements
Related show

Commit Message

Max Filippov July 23, 2018, 6:10 p.m.
The change c451bb34ae8b ("xtensa: don't emit dynamic relocation for weak
undefined symbol") didn't properly handled 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.
---
 bfd/elf32-xtensa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.11.0

Comments

augustine.sterling@gmail.com July 23, 2018, 6:58 p.m. | #1
On Mon, Jul 23, 2018 at 11:10 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> The change c451bb34ae8b ("xtensa: don't emit dynamic relocation for weak

> undefined symbol") didn't properly handled 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.

> ---


Approved.

Patch

diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index f7f569d0c086..a4b046e445f1 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -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;