All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections
@ 2015-05-14  4:38 Max Filippov
  2015-05-14  4:38 ` [Buildroot] [PATCH 1/2] " Max Filippov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Max Filippov @ 2015-05-14  4:38 UTC (permalink / raw)
  To: buildroot

Hi,

this series backports binutils fix for xtensa ld and reverts old workaround
for this bug.

Max Filippov (2):
  binutils: fix xtensa ld bug triggered by --gc-sections
  Revert "kmod: disable --gc-sections ld option when building for
    xtensa"

 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 package/kmod/kmod.mk                               |  5 --
 5 files changed, 228 insertions(+), 5 deletions(-)
 create mode 100644 package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 1/2] binutils: fix xtensa ld bug triggered by --gc-sections
  2015-05-14  4:38 [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Max Filippov
@ 2015-05-14  4:38 ` Max Filippov
  2015-05-14  4:39 ` [Buildroot] [PATCH 2/2] Revert "kmod: disable --gc-sections ld option when building for xtensa" Max Filippov
  2015-05-16 12:24 ` [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2015-05-14  4:38 UTC (permalink / raw)
  To: buildroot

elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
made local, that results in link failure with the following message:

  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
  3372 in elf_xtensa_finish_dynamic_sections

elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
relocation type. Relocation types are not changed when symbol becomes
local, but its PLT references are added to GOT references and
plt.refcount is set to 0. Such symbol cannot be unreferences in the
elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
relocations section size not match number of GOT relocations.

Fix it by treating PLT reference as GOT reference when plt.refcount is
not positive.

Fixes:
  http://autobuild.buildroot.net/results/3e2e24f697e26c93d4d95782b1cb7799fa620a7a/
  http://autobuild.buildroot.org/results/97d4c96d6f6cdc1ed4007456f4ab70be9dfa41b5/

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 ...localized-symbol-refcounting-with-gc-sect.patch | 57 ++++++++++++++++++++++
 4 files changed, 228 insertions(+)
 create mode 100644 package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
 create mode 100644 package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch

diff --git a/package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch b/package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
new file mode 100644
index 0000000..9ad6b3b
--- /dev/null
+++ b/package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
@@ -0,0 +1,57 @@
+From 8ec76b16f62d1bf386fb2c39af5f66c3afddc5cb Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 14 May 2015 05:22:55 +0300
+Subject: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
+
+elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
+made local, that results in link failure with the following message:
+
+  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
+  3372 in elf_xtensa_finish_dynamic_sections
+
+elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
+relocation type. Relocation types are not changed when symbol becomes
+local, but its PLT references are added to GOT references and
+plt.refcount is set to 0. Such symbol cannot be unreferences in the
+elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
+relocations section size not match number of GOT relocations.
+
+Fix it by treating PLT reference as GOT reference when plt.refcount is
+not positive.
+
+2015-05-14  Max Filippov  <jcmvbkbc@gmail.com>
+bfd/
+	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
+	as GOT reference when plt.refcount is not positive.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: e6c9a083ec5ae7a45bd71682b26aae1939849388
+Changes to ChangeLog are dropped.
+
+ bfd/elf32-xtensa.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index 53af1c6..2523670 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
+ 	{
+ 	  if (is_plt)
+ 	    {
++	      /* If the symbol has been localized its plt.refcount got moved
++	         to got.refcount.  Handle it as GOT.  */
+ 	      if (h->plt.refcount > 0)
+ 		h->plt.refcount--;
++	      else
++		is_got = TRUE;
+ 	    }
+-	  else if (is_got)
++	  if (is_got)
+ 	    {
+ 	      if (h->got.refcount > 0)
+ 		h->got.refcount--;
+-- 
+1.8.1.4
+
diff --git a/package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch b/package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
new file mode 100644
index 0000000..9ad6b3b
--- /dev/null
+++ b/package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
@@ -0,0 +1,57 @@
+From 8ec76b16f62d1bf386fb2c39af5f66c3afddc5cb Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 14 May 2015 05:22:55 +0300
+Subject: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
+
+elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
+made local, that results in link failure with the following message:
+
+  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
+  3372 in elf_xtensa_finish_dynamic_sections
+
+elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
+relocation type. Relocation types are not changed when symbol becomes
+local, but its PLT references are added to GOT references and
+plt.refcount is set to 0. Such symbol cannot be unreferences in the
+elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
+relocations section size not match number of GOT relocations.
+
+Fix it by treating PLT reference as GOT reference when plt.refcount is
+not positive.
+
+2015-05-14  Max Filippov  <jcmvbkbc@gmail.com>
+bfd/
+	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
+	as GOT reference when plt.refcount is not positive.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: e6c9a083ec5ae7a45bd71682b26aae1939849388
+Changes to ChangeLog are dropped.
+
+ bfd/elf32-xtensa.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index 53af1c6..2523670 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
+ 	{
+ 	  if (is_plt)
+ 	    {
++	      /* If the symbol has been localized its plt.refcount got moved
++	         to got.refcount.  Handle it as GOT.  */
+ 	      if (h->plt.refcount > 0)
+ 		h->plt.refcount--;
++	      else
++		is_got = TRUE;
+ 	    }
+-	  else if (is_got)
++	  if (is_got)
+ 	    {
+ 	      if (h->got.refcount > 0)
+ 		h->got.refcount--;
+-- 
+1.8.1.4
+
diff --git a/package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch b/package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
new file mode 100644
index 0000000..9ad6b3b
--- /dev/null
+++ b/package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
@@ -0,0 +1,57 @@
+From 8ec76b16f62d1bf386fb2c39af5f66c3afddc5cb Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 14 May 2015 05:22:55 +0300
+Subject: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
+
+elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
+made local, that results in link failure with the following message:
+
+  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
+  3372 in elf_xtensa_finish_dynamic_sections
+
+elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
+relocation type. Relocation types are not changed when symbol becomes
+local, but its PLT references are added to GOT references and
+plt.refcount is set to 0. Such symbol cannot be unreferences in the
+elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
+relocations section size not match number of GOT relocations.
+
+Fix it by treating PLT reference as GOT reference when plt.refcount is
+not positive.
+
+2015-05-14  Max Filippov  <jcmvbkbc@gmail.com>
+bfd/
+	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
+	as GOT reference when plt.refcount is not positive.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: e6c9a083ec5ae7a45bd71682b26aae1939849388
+Changes to ChangeLog are dropped.
+
+ bfd/elf32-xtensa.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index 53af1c6..2523670 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
+ 	{
+ 	  if (is_plt)
+ 	    {
++	      /* If the symbol has been localized its plt.refcount got moved
++	         to got.refcount.  Handle it as GOT.  */
+ 	      if (h->plt.refcount > 0)
+ 		h->plt.refcount--;
++	      else
++		is_got = TRUE;
+ 	    }
+-	  else if (is_got)
++	  if (is_got)
+ 	    {
+ 	      if (h->got.refcount > 0)
+ 		h->got.refcount--;
+-- 
+1.8.1.4
+
diff --git a/package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch b/package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
new file mode 100644
index 0000000..9ad6b3b
--- /dev/null
+++ b/package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch
@@ -0,0 +1,57 @@
+From 8ec76b16f62d1bf386fb2c39af5f66c3afddc5cb Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 14 May 2015 05:22:55 +0300
+Subject: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
+
+elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
+made local, that results in link failure with the following message:
+
+  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
+  3372 in elf_xtensa_finish_dynamic_sections
+
+elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
+relocation type. Relocation types are not changed when symbol becomes
+local, but its PLT references are added to GOT references and
+plt.refcount is set to 0. Such symbol cannot be unreferences in the
+elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
+relocations section size not match number of GOT relocations.
+
+Fix it by treating PLT reference as GOT reference when plt.refcount is
+not positive.
+
+2015-05-14  Max Filippov  <jcmvbkbc@gmail.com>
+bfd/
+	* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
+	as GOT reference when plt.refcount is not positive.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: e6c9a083ec5ae7a45bd71682b26aae1939849388
+Changes to ChangeLog are dropped.
+
+ bfd/elf32-xtensa.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
+index 53af1c6..2523670 100644
+--- a/bfd/elf32-xtensa.c
++++ b/bfd/elf32-xtensa.c
+@@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
+ 	{
+ 	  if (is_plt)
+ 	    {
++	      /* If the symbol has been localized its plt.refcount got moved
++	         to got.refcount.  Handle it as GOT.  */
+ 	      if (h->plt.refcount > 0)
+ 		h->plt.refcount--;
++	      else
++		is_got = TRUE;
+ 	    }
+-	  else if (is_got)
++	  if (is_got)
+ 	    {
+ 	      if (h->got.refcount > 0)
+ 		h->got.refcount--;
+-- 
+1.8.1.4
+
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 2/2] Revert "kmod: disable --gc-sections ld option when building for xtensa"
  2015-05-14  4:38 [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Max Filippov
  2015-05-14  4:38 ` [Buildroot] [PATCH 1/2] " Max Filippov
@ 2015-05-14  4:39 ` Max Filippov
  2015-05-16 12:24 ` [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2015-05-14  4:39 UTC (permalink / raw)
  To: buildroot

This reverts commit 55c83179c4b30c9ec715a75297849abd74a63e05.
Now that binutils bug with --gc-section is fixed this workaroud is no
longer needed.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 package/kmod/kmod.mk | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/package/kmod/kmod.mk b/package/kmod/kmod.mk
index 1ac83ea..98d9998 100644
--- a/package/kmod/kmod.mk
+++ b/package/kmod/kmod.mk
@@ -39,11 +39,6 @@ KMOD_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON),python,python3)
 KMOD_CONF_OPTS += --enable-python
 endif
 
-# --gc-sections triggers a bug in the current Xtensa binutils
-ifeq ($(BR2_xtensa),y)
-KMOD_CONF_ENV += cc_cv_LDFLAGS__Wl___gc_sections=no
-endif
-
 ifeq ($(BR2_PACKAGE_KMOD_TOOLS),y)
 
 # add license info for kmod tools
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections
  2015-05-14  4:38 [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Max Filippov
  2015-05-14  4:38 ` [Buildroot] [PATCH 1/2] " Max Filippov
  2015-05-14  4:39 ` [Buildroot] [PATCH 2/2] Revert "kmod: disable --gc-sections ld option when building for xtensa" Max Filippov
@ 2015-05-16 12:24 ` Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2015-05-16 12:24 UTC (permalink / raw)
  To: buildroot

Dear Max Filippov,

On Thu, 14 May 2015 07:38:58 +0300, Max Filippov wrote:
> Hi,
> 
> this series backports binutils fix for xtensa ld and reverts old workaround
> for this bug.
> 
> Max Filippov (2):
>   binutils: fix xtensa ld bug triggered by --gc-sections
>   Revert "kmod: disable --gc-sections ld option when building for
>     xtensa"

Both patches applied, thanks a lot!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-16 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14  4:38 [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Max Filippov
2015-05-14  4:38 ` [Buildroot] [PATCH 1/2] " Max Filippov
2015-05-14  4:39 ` [Buildroot] [PATCH 2/2] Revert "kmod: disable --gc-sections ld option when building for xtensa" Max Filippov
2015-05-16 12:24 ` [Buildroot] [PATCH 0/2] binutils: fix xtensa ld bug triggered by --gc-sections Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.