Skip to contentSkip to conversation

package/binutils: fix xtensa linker relaxation regression in 2.31.1

PATCH New Max Filippov 3 participants 3 messages Jul 23, 2018 – Jul 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/binutils: fix xtensa linker relaxation regression in 2.31.1

Fix the following xtensa ld error observed when building uClibc-ng libthread_db with binutils-2.31:

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

---
 ...relaxation-of-undefined-weak-references-i.patch | 48 ++++++++++++
 ...-dynamic-relocations-sections-consistency.patch | 90 ++++++++++++++++++++++
 2 files changed, 138 insertions(+)
 create mode 100644 package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch
 create mode 100644 package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch
package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch new file +48 -0
new file mode 100644
index 000000000000..660d30c38925
@@ -0,0 +1,48 @@
+From 5d3a462f05cba5b0c0c96de899b84fb84155c760 Mon Sep 17 00:00:00 2001
+From: Max Filippov <[email protected]>
+Date: Sun, 22 Jul 2018 13:52:28 -0700
+Subject: [PATCH] xtensa: fix relaxation of undefined weak references in
+ shared objects
+
+The change c451bb34ae8b ("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  <[email protected]>
+
+	* elf32-xtensa.c (shrink_dynamic_reloc_sections): Shrink dynamic
+	relocations section for dynamic undefined weak symbols when
+	linking a shared object.
+
+Signed-off-by: Max Filippov <[email protected]>
+Backported from: 5d3a462f05cba5b0c0c96de899b84fb84155c760
+---
+ bfd/elf32-xtensa.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+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;
+-- 
+2.11.0
+
package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 package/binutils: fix xtensa linker relaxation regression in 2.31.1

Hi Max,

Le 23/07/2018 ? 21:37, Max Filippov a ?crit?:

Quoted 9 lines

Fix the following xtensa ld error observed when building uClibc-ng libthread_db with binutils-2.31:

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

Thanks for the patch :)

Tested using qemu_xtensa_lx60_defconfig.

Best regards,
Romain

#2 lore raw

PATCH 1/1 package/binutils: fix xtensa linker relaxation regression in 2.31.1

In reply to Max Filippov

Hello,

Quoted 9 lines · Max Filippov

Fix the following xtensa ld error observed when building uClibc-ng libthread_db with binutils-2.31:

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

Quoted 6 lines
---
 ...relaxation-of-undefined-weak-references-i.patch | 48 ++++++++++++
 ...-dynamic-relocations-sections-consistency.patch | 90 ++++++++++++++++++++++
 2 files changed, 138 insertions(+)
 create mode 100644 package/binutils/2.31.1/0010-xtensa-fix-relaxation-of-undefined-weak-references-i.patch
 create mode 100644 package/binutils/2.31.1/0011-xtensa-move-dynamic-relocations-sections-consistency.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com