All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it
@ 2021-05-03 11:13 Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 1/9] package/binutils: update or1k patches for plt link version with upstream Giulio Benetti
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

This patchset fixes binutils bug 21464 and fixes libgeos build failure
by introducing the gcc option flag -mcmodel. This is done by adding
upstreamed binutils and gcc patches. Note tha this way buildroot
toolchains can be considered bug binutils 21464 free and the only other
OpenRisc toolchain supported is the external Bootlin one. So this
patchset has to be considered valid once Bootlin updates its OpenRisc
by adding binutils and gcc patches that are added with patches in this
patchset.

Giulio Benetti (9):
  package/binutils: update or1k patches for plt link version with
    upstream
  package/binutils: add upstream backported patches to support
    -mcmodel=large gcc option
  package/gcc: add upstream patches that introduce -mcmodel=large option
    for or1k
  package/libgeos: fix build failure due to missing -mcmodel=large
  package/protobuf: fix build failure due to missing -mcmodel=large
  toolchain: remove binutils bug 21464
  package/libgeos: remove binutils bug 21464 dependency
  package/postgis: remove libgeos binutils bug 21464 inheritance
  package/protobuf: remove binutils bug 21464 dependency

 .../0010-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
 ...ith-plt-link-failure-for-local-calls.patch |  59 +++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
 ...ith-plt-link-failure-for-local-calls.patch |  59 +++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
 ...ith-plt-link-failure-for-local-calls.patch |  59 +++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
 ...ith-plt-link-failure-for-local-calls.patch |  59 +++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 ...-mcmodel-option-to-handle-large-GOTs.patch | 200 +++++++
 ...-cmodel-large-when-building-crtstuff.patch |  60 +++
 ...-mcmodel-option-to-handle-large-GOTs.patch | 201 +++++++
 ...-cmodel-large-when-building-crtstuff.patch |  60 +++
 package/libgeos/Config.in                     |   4 +-
 package/libgeos/libgeos.mk                    |   4 +
 package/postgis/Config.in                     |   4 +-
 package/protobuf/Config.in                    |   1 -
 package/protobuf/protobuf.mk                  |   4 +
 toolchain/Config.in                           |   6 -
 30 files changed, 4035 insertions(+), 153 deletions(-)
 delete mode 100644 package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 create mode 100644 package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 delete mode 100644 package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 create mode 100644 package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 delete mode 100644 package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 create mode 100644 package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 delete mode 100644 package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 create mode 100644 package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 create mode 100644 package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
 create mode 100644 package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch
 create mode 100644 package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
 create mode 100644 package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch

-- 
2.25.1

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

* [Buildroot] [PATCH 1/9] package/binutils: update or1k patches for plt link version with upstream
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Actual patches are stubs suggested but now they are available as upstream.
So let's substitute them since they make part of a or1k patchset and next
patch will add the others.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 .../0010-bfd-elf32-or1k-fix-ld-assert.patch   | 35 -----------
 ...ith-plt-link-failure-for-local-calls.patch | 59 +++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   | 35 -----------
 ...ith-plt-link-failure-for-local-calls.patch | 59 +++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   | 35 -----------
 ...ith-plt-link-failure-for-local-calls.patch | 59 +++++++++++++++++++
 .../0003-bfd-elf32-or1k-fix-ld-assert.patch   | 35 -----------
 ...ith-plt-link-failure-for-local-calls.patch | 59 +++++++++++++++++++
 8 files changed, 236 insertions(+), 140 deletions(-)
 delete mode 100644 package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 delete mode 100644 package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 delete mode 100644 package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
 delete mode 100644 package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch
 create mode 100644 package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch

diff --git a/package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch b/package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch
deleted file mode 100644
index 824c9ce3e5..0000000000
--- a/package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 93cf62b662499e560812145dd989056fcf14f00e Mon Sep 17 00:00:00 2001
-From: Giulio Benetti <giulio.benetti@benettiengineering.com>
-Date: Mon, 22 Mar 2021 13:30:07 +0100
-Subject: [PATCH] bfd/elf32-or1k: fix ld assert
-
-Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27624
-
-Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
----
- bfd/elf32-or1k.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
-index 2f200b197b..ae508540f5 100644
---- a/bfd/elf32-or1k.c
-+++ b/bfd/elf32-or1k.c
-@@ -2535,11 +2535,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
-   if (h->type == STT_FUNC
-       || h->needs_plt)
-     {
--      if (! bfd_link_pic (info)
--	  && !h->def_dynamic
--	  && !h->ref_dynamic
--	  && h->root.type != bfd_link_hash_undefweak
--	  && h->root.type != bfd_link_hash_undefined)
-+      if (h->plt.refcount <= 0
-+         || (SYMBOL_CALLS_LOCAL (info, h)
-+         || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-+             && h->root.type == bfd_link_hash_undefweak)))
- 	{
- 	  /* This case can occur if we saw a PLT reloc in an input
- 	     file, but the symbol was never referred to by a dynamic
--- 
-2.25.1
-
diff --git a/package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch b/package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
new file mode 100644
index 0000000000..fcc2b995fa
--- /dev/null
+++ b/package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
@@ -0,0 +1,59 @@
+From 788cda9f9447e0fe67e582e8fb5adafd678d08b2 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:14 +0900
+Subject: [PATCH 10/13] or1k: Fix issue with plt link failure for local calls
+
+When building protobuf we were seeing the assert failure:
+
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    collect2: error: ld returned 1 exit status
+
+This failure happens while writing out PLT entries, there is a check
+"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
+symbol attributes.  This was failing for symbols that were
+"forced_local" in previous linking code.
+
+The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
+"forced_local" symbols and exclude them from the the PLT.
+
+bfd/ChangeLog:
+
+	PR 27624
+	* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
+	condition used to cleanup plt entries to cleanup forced local
+	entries.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 2f200b197b8..1f2c88b0b3a 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2535,11 +2535,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+   if (h->type == STT_FUNC
+       || h->needs_plt)
+     {
+-      if (! bfd_link_pic (info)
+-	  && !h->def_dynamic
+-	  && !h->ref_dynamic
+-	  && h->root.type != bfd_link_hash_undefweak
+-	  && h->root.type != bfd_link_hash_undefined)
++      if (h->plt.refcount <= 0
++	  || (SYMBOL_CALLS_LOCAL (info, h)
++	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
++	      && h->root.type == bfd_link_hash_undefweak)))
+ 	{
+ 	  /* This case can occur if we saw a PLT reloc in an input
+ 	     file, but the symbol was never referred to by a dynamic
+-- 
+2.25.1
+
diff --git a/package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch b/package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch
deleted file mode 100644
index 756493667f..0000000000
--- a/package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 1659226a96b1daecfd08c057d0d5c39309d207ee Mon Sep 17 00:00:00 2001
-From: Giulio Benetti <giulio.benetti@benettiengineering.com>
-Date: Mon, 22 Mar 2021 13:30:07 +0100
-Subject: [PATCH] bfd/elf32-or1k: fix ld assert
-
-Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27624
-
-Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
----
- bfd/elf32-or1k.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
-index 65938e5137..41908f8938 100644
---- a/bfd/elf32-or1k.c
-+++ b/bfd/elf32-or1k.c
-@@ -2566,11 +2566,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
-   if (h->type == STT_FUNC
-       || h->needs_plt)
-     {
--      if (! bfd_link_pic (info)
--	  && !h->def_dynamic
--	  && !h->ref_dynamic
--	  && h->root.type != bfd_link_hash_undefweak
--	  && h->root.type != bfd_link_hash_undefined)
-+      if (h->plt.refcount <= 0
-+         || (SYMBOL_CALLS_LOCAL (info, h)
-+         || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-+             && h->root.type == bfd_link_hash_undefweak)))
- 	{
- 	  /* This case can occur if we saw a PLT reloc in an input
- 	     file, but the symbol was never referred to by a dynamic
--- 
-2.25.1
-
diff --git a/package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch b/package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
new file mode 100644
index 0000000000..58dbaf9f1f
--- /dev/null
+++ b/package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
@@ -0,0 +1,59 @@
+From 651c3617a04a1d1f78e89623b81be7ba32ff59a5 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:14 +0900
+Subject: [PATCH 3/6] or1k: Fix issue with plt link failure for local calls
+
+When building protobuf we were seeing the assert failure:
+
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    collect2: error: ld returned 1 exit status
+
+This failure happens while writing out PLT entries, there is a check
+"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
+symbol attributes.  This was failing for symbols that were
+"forced_local" in previous linking code.
+
+The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
+"forced_local" symbols and exclude them from the the PLT.
+
+bfd/ChangeLog:
+
+	PR 27624
+	* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
+	condition used to cleanup plt entries to cleanup forced local
+	entries.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 31ef758a926..58246875546 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2535,11 +2535,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+   if (h->type == STT_FUNC
+       || h->needs_plt)
+     {
+-      if (! bfd_link_pic (info)
+-	  && !h->def_dynamic
+-	  && !h->ref_dynamic
+-	  && h->root.type != bfd_link_hash_undefweak
+-	  && h->root.type != bfd_link_hash_undefined)
++      if (h->plt.refcount <= 0
++	  || (SYMBOL_CALLS_LOCAL (info, h)
++	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
++	      && h->root.type == bfd_link_hash_undefweak)))
+ 	{
+ 	  /* This case can occur if we saw a PLT reloc in an input
+ 	     file, but the symbol was never referred to by a dynamic
+-- 
+2.25.1
+
diff --git a/package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch b/package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch
deleted file mode 100644
index 756493667f..0000000000
--- a/package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 1659226a96b1daecfd08c057d0d5c39309d207ee Mon Sep 17 00:00:00 2001
-From: Giulio Benetti <giulio.benetti@benettiengineering.com>
-Date: Mon, 22 Mar 2021 13:30:07 +0100
-Subject: [PATCH] bfd/elf32-or1k: fix ld assert
-
-Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27624
-
-Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
----
- bfd/elf32-or1k.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
-index 65938e5137..41908f8938 100644
---- a/bfd/elf32-or1k.c
-+++ b/bfd/elf32-or1k.c
-@@ -2566,11 +2566,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
-   if (h->type == STT_FUNC
-       || h->needs_plt)
-     {
--      if (! bfd_link_pic (info)
--	  && !h->def_dynamic
--	  && !h->ref_dynamic
--	  && h->root.type != bfd_link_hash_undefweak
--	  && h->root.type != bfd_link_hash_undefined)
-+      if (h->plt.refcount <= 0
-+         || (SYMBOL_CALLS_LOCAL (info, h)
-+         || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-+             && h->root.type == bfd_link_hash_undefweak)))
- 	{
- 	  /* This case can occur if we saw a PLT reloc in an input
- 	     file, but the symbol was never referred to by a dynamic
--- 
-2.25.1
-
diff --git a/package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch b/package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
new file mode 100644
index 0000000000..381d87e4cd
--- /dev/null
+++ b/package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
@@ -0,0 +1,59 @@
+From baf313f84b106a5a29f01796afd857e69abf8b08 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:14 +0900
+Subject: [PATCH 3/6] or1k: Fix issue with plt link failure for local calls
+
+When building protobuf we were seeing the assert failure:
+
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    collect2: error: ld returned 1 exit status
+
+This failure happens while writing out PLT entries, there is a check
+"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
+symbol attributes.  This was failing for symbols that were
+"forced_local" in previous linking code.
+
+The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
+"forced_local" symbols and exclude them from the the PLT.
+
+bfd/ChangeLog:
+
+	PR 27624
+	* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
+	condition used to cleanup plt entries to cleanup forced local
+	entries.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 7c02d004cc7..bbfa2bfe614 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2568,11 +2568,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+   if (h->type == STT_FUNC
+       || h->needs_plt)
+     {
+-      if (! bfd_link_pic (info)
+-	  && !h->def_dynamic
+-	  && !h->ref_dynamic
+-	  && h->root.type != bfd_link_hash_undefweak
+-	  && h->root.type != bfd_link_hash_undefined)
++      if (h->plt.refcount <= 0
++	  || (SYMBOL_CALLS_LOCAL (info, h)
++	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
++	      && h->root.type == bfd_link_hash_undefweak)))
+ 	{
+ 	  /* This case can occur if we saw a PLT reloc in an input
+ 	     file, but the symbol was never referred to by a dynamic
+-- 
+2.25.1
+
diff --git a/package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch b/package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch
deleted file mode 100644
index 756493667f..0000000000
--- a/package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 1659226a96b1daecfd08c057d0d5c39309d207ee Mon Sep 17 00:00:00 2001
-From: Giulio Benetti <giulio.benetti@benettiengineering.com>
-Date: Mon, 22 Mar 2021 13:30:07 +0100
-Subject: [PATCH] bfd/elf32-or1k: fix ld assert
-
-Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27624
-
-Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
----
- bfd/elf32-or1k.c | 9 ++++-----
- 1 file changed, 4 insertions(+), 5 deletions(-)
-
-diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
-index 65938e5137..41908f8938 100644
---- a/bfd/elf32-or1k.c
-+++ b/bfd/elf32-or1k.c
-@@ -2566,11 +2566,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
-   if (h->type == STT_FUNC
-       || h->needs_plt)
-     {
--      if (! bfd_link_pic (info)
--	  && !h->def_dynamic
--	  && !h->ref_dynamic
--	  && h->root.type != bfd_link_hash_undefweak
--	  && h->root.type != bfd_link_hash_undefined)
-+      if (h->plt.refcount <= 0
-+         || (SYMBOL_CALLS_LOCAL (info, h)
-+         || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-+             && h->root.type == bfd_link_hash_undefweak)))
- 	{
- 	  /* This case can occur if we saw a PLT reloc in an input
- 	     file, but the symbol was never referred to by a dynamic
--- 
-2.25.1
-
diff --git a/package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch b/package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
new file mode 100644
index 0000000000..8c968e064b
--- /dev/null
+++ b/package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
@@ -0,0 +1,59 @@
+From b5fdaa85790dff45fd2c3fd15405c16dbc50a074 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:14 +0900
+Subject: [PATCH 3/6] or1k: Fix issue with plt link failure for local calls
+
+When building protobuf we were seeing the assert failure:
+
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
+    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
+    collect2: error: ld returned 1 exit status
+
+This failure happens while writing out PLT entries, there is a check
+"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
+symbol attributes.  This was failing for symbols that were
+"forced_local" in previous linking code.
+
+The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
+"forced_local" symbols and exclude them from the the PLT.
+
+bfd/ChangeLog:
+
+	PR 27624
+	* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
+	condition used to cleanup plt entries to cleanup forced local
+	entries.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 65938e51378..4f82cc4c667 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2566,11 +2566,10 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+   if (h->type == STT_FUNC
+       || h->needs_plt)
+     {
+-      if (! bfd_link_pic (info)
+-	  && !h->def_dynamic
+-	  && !h->ref_dynamic
+-	  && h->root.type != bfd_link_hash_undefweak
+-	  && h->root.type != bfd_link_hash_undefined)
++      if (h->plt.refcount <= 0
++	  || (SYMBOL_CALLS_LOCAL (info, h)
++	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
++	      && h->root.type == bfd_link_hash_undefweak)))
+ 	{
+ 	  /* This case can occur if we saw a PLT reloc in an input
+ 	     file, but the symbol was never referred to by a dynamic
+-- 
+2.25.1
+
-- 
2.25.1

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 1/9] package/binutils: update or1k patches for plt link version with upstream Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-06-08 21:29   ` Romain Naour
  2021-05-03 11:13 ` [Buildroot] [PATCH 3/9] package/gcc: add upstream patches that introduce -mcmodel=large option for or1k Giulio Benetti
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Add upstream backported patches that allows using -mcmodel=large gcc option
that in order allows fixing build failure due to binutils bug 21464:
https://sourceware.org/bugzilla/show_bug.cgi?id=21464

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
 ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
 ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
 12 files changed, 3268 insertions(+)
 create mode 100644 package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 create mode 100644 package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 create mode 100644 package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
 create mode 100644 package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
 create mode 100644 package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
 create mode 100644 package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch

diff --git a/package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch b/package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
new file mode 100644
index 0000000000..2ea3c3e7ac
--- /dev/null
+++ b/package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
@@ -0,0 +1,256 @@
+From b10e6230dea0015bf3b7748580b82c551f9a3a4a Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:15 +0900
+Subject: [PATCH 11/13] or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
+
+The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
+using the -mcmodel=large option.  This relocation is used along with
+got() to generate 32-bit GOT offsets.  This increases the previous GOT
+offset limit from the previous 16-bit (64K) limit.
+
+This is needed on large binaries where the GOT grows larger than 64k.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
+	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
+	(or1k_final_link_relocate, or1k_elf_relocate_section,
+	or1k_elf_check_relocs): Likewise.
+	* libbfd.h (bfd_reloc_code_real_names): Likewise.
+	* reloc.c: Likewise.
+
+cpu/ChangeLog:
+
+	PR 21464
+	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
+	for gotha() relocation.
+
+include/ChangeLog:
+
+	PR 21464
+	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.
+
+opcodes/ChangeLog:
+
+	PR 21464
+	* or1k-asm.c: Regenerate.
+
+gas/ChangeLog:
+
+	PR 21464
+	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
+	* testsuite/gas/or1k/reloc-1.d: Add test result for new
+	relocation.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+
+fixup reloc, add tests
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/bfd-in2.h                    |  1 +
+ bfd/elf32-or1k.c                 | 21 ++++++++++++++++++++-
+ bfd/libbfd.h                     |  1 +
+ bfd/reloc.c                      |  2 ++
+ cpu/or1k.opc                     |  7 ++++++-
+ gas/testsuite/gas/or1k/reloc-1.d |  4 +++-
+ gas/testsuite/gas/or1k/reloc-1.s |  4 ++++
+ include/elf/or1k.h               |  1 +
+ opcodes/or1k-asm.c               |  7 ++++++-
+ 9 files changed, 44 insertions(+), 4 deletions(-)
+
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index e25da50aafb..530a41fca43 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -5517,6 +5517,7 @@ then it may be truncated to 8 bits.  */
+   BFD_RELOC_OR1K_TLS_TPOFF,
+   BFD_RELOC_OR1K_TLS_DTPOFF,
+   BFD_RELOC_OR1K_TLS_DTPMOD,
++  BFD_RELOC_OR1K_GOT_AHI16,
+ 
+ /* H8 elf Relocations.  */
+   BFD_RELOC_H8_DIR16A8,
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 1f2c88b0b3a..a4a64f73b7c 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -808,6 +808,20 @@ static reloc_howto_type or1k_elf_howto_table[] =
+ 	 0,			/* Source Mask.  */
+ 	 0x03ffffff,		/* Dest Mask.  */
+ 	 TRUE),			/* PC relative offset?  */
++
++  HOWTO (R_OR1K_GOT_AHI16,     /* type */
++	16,                    /* rightshift */
++	2,                     /* size (0 = byte, 1 = short, 2 = long) */
++	16,                    /* bitsize */
++	FALSE,                 /* pc_relative */
++	0,                     /* bitpos */
++	complain_overflow_signed, /* complain_on_overflow */
++	bfd_elf_generic_reloc, /* special_function */
++	"R_OR1K_GOT_AHI16",    /* name */
++	FALSE,                 /* partial_inplace */
++	0,                     /* src_mask */
++	0xffff,                /* dst_mask */
++	FALSE),                /* pcrel_offset */
+ };
+ 
+ /* Map BFD reloc types to Or1k ELF reloc types.  */
+@@ -871,6 +885,7 @@ static const struct or1k_reloc_map or1k_reloc_map[] =
+   { BFD_RELOC_OR1K_TLS_IE_LO13,	R_OR1K_TLS_IE_LO13 },
+   { BFD_RELOC_OR1K_SLO13,	R_OR1K_SLO13 },
+   { BFD_RELOC_OR1K_PLTA26,	R_OR1K_PLTA26 },
++  { BFD_RELOC_OR1K_GOT_AHI16,	R_OR1K_GOT_AHI16 },
+ };
+ 
+ #define TLS_UNKNOWN    0
+@@ -1080,6 +1095,7 @@ or1k_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd,
+   switch (howto->type)
+     {
+     case R_OR1K_AHI16:
++    case R_OR1K_GOT_AHI16:
+     case R_OR1K_GOTOFF_AHI16:
+     case R_OR1K_TLS_IE_AHI16:
+     case R_OR1K_TLS_LE_AHI16:
+@@ -1344,6 +1360,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+@@ -1435,7 +1452,8 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    /* The GOT_PG21 and GOT_LO13 relocs are pc-relative,
+ 	       while the GOT16 reloc is GOT relative.  */
+ 	    relocation = got_base + off;
+-	    if (r_type == R_OR1K_GOT16)
++	    if (r_type == R_OR1K_GOT16
++		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
+ 	  /* Addend should be zero.  */
+@@ -1945,6 +1963,7 @@ or1k_elf_check_relocs (bfd *abfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+diff --git a/bfd/libbfd.h b/bfd/libbfd.h
+index 36284d71a9b..6e9e3190bb8 100644
+--- a/bfd/libbfd.h
++++ b/bfd/libbfd.h
+@@ -2702,6 +2702,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+   "BFD_RELOC_OR1K_TLS_TPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPMOD",
++  "BFD_RELOC_OR1K_GOT_AHI16",
+   "BFD_RELOC_H8_DIR16A8",
+   "BFD_RELOC_H8_DIR16R8",
+   "BFD_RELOC_H8_DIR24A8",
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index e6446a78098..b0003ab1175 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -6164,6 +6164,8 @@ ENUMX
+   BFD_RELOC_OR1K_GOTPC_HI16
+ ENUMX
+   BFD_RELOC_OR1K_GOTPC_LO16
++ENUMX
++  BFD_RELOC_OR1K_GOT_AHI16
+ ENUMX
+   BFD_RELOC_OR1K_GOT16
+ ENUMX
+diff --git a/cpu/or1k.opc b/cpu/or1k.opc
+index 5082a30cee1..85163fc96c9 100644
+--- a/cpu/or1k.opc
++++ b/cpu/or1k.opc
+@@ -173,7 +173,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -276,6 +276,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+diff --git a/gas/testsuite/gas/or1k/reloc-1.d b/gas/testsuite/gas/or1k/reloc-1.d
+index d1bcf5608bb..3a001c4ed99 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.d
++++ b/gas/testsuite/gas/or1k/reloc-1.d
+@@ -68,5 +68,7 @@ OFFSET   TYPE              VALUE
+ 000000ec R_OR1K_LO13       x
+ 000000f0 R_OR1K_GOT_LO13   x
+ 000000f4 R_OR1K_SLO13      x
+-
++000000f8 R_OR1K_GOT_AHI16  x
++000000fc R_OR1K_GOT_AHI16  x
++00000100 R_OR1K_GOT_AHI16  x
+ 
+diff --git a/gas/testsuite/gas/or1k/reloc-1.s b/gas/testsuite/gas/or1k/reloc-1.s
+index e76abef6532..562609aa869 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.s
++++ b/gas/testsuite/gas/or1k/reloc-1.s
+@@ -74,3 +74,7 @@
+ 	l.lbz	r5,po(x)(r3)
+ 	l.lbz	r5,gotpo(x)(r3)
+ 	l.sb	po(x)(r3),r6
++
++	l.movhi	r4,gotha(x)
++	l.ori	r3,r4,gotha(x)
++	l.addi	r3,r4,gotha(x)
+diff --git a/include/elf/or1k.h b/include/elf/or1k.h
+index 0abef046202..7db3cad18eb 100644
+--- a/include/elf/or1k.h
++++ b/include/elf/or1k.h
+@@ -77,6 +77,7 @@ START_RELOC_NUMBERS (elf_or1k_reloc_type)
+   RELOC_NUMBER (R_OR1K_TLS_IE_LO13,   51)
+   RELOC_NUMBER (R_OR1K_SLO13,         52)
+   RELOC_NUMBER (R_OR1K_PLTA26,        53)
++  RELOC_NUMBER (R_OR1K_GOT_AHI16,     54)
+ END_RELOC_NUMBERS (R_OR1K_max)
+ 
+ #define EF_OR1K_NODELAY (1UL << 0)
+diff --git a/opcodes/or1k-asm.c b/opcodes/or1k-asm.c
+index 7d058d03f5f..332f4b7a9b5 100644
+--- a/opcodes/or1k-asm.c
++++ b/opcodes/or1k-asm.c
+@@ -177,7 +177,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -280,6 +280,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch b/package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
new file mode 100644
index 0000000000..c481aca5ec
--- /dev/null
+++ b/package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
@@ -0,0 +1,61 @@
+From 0f61f76454a9420f158f626cb09a4fbc08c3709e Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:16 +0900
+Subject: [PATCH 12/13] or1k: Avoid R_OR1K_GOT16 overflow failures in presence
+ of R_OR1K_GOT_AHI16
+
+Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
+overflow validation check if the section has R_OR1K_GOT_AHI16.
+
+We cannot simple disable R_OR1K_GOT16 overflow validation as there will
+still be binaries that will have only R_OR1K_GOT16.  The
+R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
+the option -mcmodel=large.
+
+This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
+is the code pattern that will be emitted by GCC.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
+	overflow check if we have R_OR1K_GOT_AHI16 followed by
+	R_OR1K_GOT16.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index a4a64f73b7c..07fff3602a3 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -1248,6 +1248,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+   asection *sgot, *splt;
+   bfd_vma plt_base, got_base, got_sym_value;
+   bfd_boolean ret_val = TRUE;
++  bfd_boolean saw_gotha = FALSE;
+ 
+   if (htab == NULL)
+     return FALSE;
+@@ -1456,6 +1457,16 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
++	    if (r_type == R_OR1K_GOT_AHI16)
++	      saw_gotha = TRUE;
++
++	    /* If we have a R_OR1K_GOT16 followed by a R_OR1K_GOT_AHI16
++	       relocation we assume the code is doing the right thing to avoid
++	       overflows.  Here we mask the lower 16-bit of the relocation to
++	       avoid overflow validation failures.  */
++	    if (r_type == R_OR1K_GOT16 && saw_gotha)
++	      relocation &= 0xffff;
++
+ 	  /* Addend should be zero.  */
+ 	  if (rel->r_addend != 0)
+ 	    {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch b/package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
new file mode 100644
index 0000000000..fd191221e5
--- /dev/null
+++ b/package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
@@ -0,0 +1,500 @@
+From 36c7de7ef77ab0c30cb33e2c7ea7a6f4e3052c73 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:17 +0900
+Subject: [PATCH 13/13] or1k: Support large plt_relocs when generating plt
+ entries
+
+The current PLT generation code will generate invalid code when the PLT
+relocation offset exceeds 64k.  This fixes the issue by detecting large
+plt_reloc offsets and generare code sequences to create larger plt
+relocations.
+
+The "large" plt code needs 2 extra instructions to create 32-bit offsets.
+
+bfd/ChangeLog:
+
+	PR 27746
+	* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
+	OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
+	(elf_or1k_link_hash_table): New field plt_count.
+	(elf_or1k_link_hash_entry): New field plt_index.
+	(elf_or1k_plt_entry_size): New function.
+	(or1k_write_plt_entry): Update to support variable size PLTs.
+	(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
+	API.
+	(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
+	when needed.
+	(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
+	PLT size.
+
+ld/ChangeLog:
+
+	PR 27746
+	testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
+	along with gotha() relocations.
+	testsuite/ld-or1k/gotha1.dd: New file.
+	testsuite/ld-or1k/gotha1.s: New file.
+	testsuite/ld-or1k/gotha2.dd: New file.
+	testsuite/ld-or1k/gotha2.s: New file
+	testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
+	failure.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c               | 149 ++++++++++++++++++++++++---------
+ ld/testsuite/ld-or1k/gotha1.dd |  34 ++++++++
+ ld/testsuite/ld-or1k/gotha1.s  |  24 ++++++
+ ld/testsuite/ld-or1k/gotha2.dd |  21 +++++
+ ld/testsuite/ld-or1k/gotha2.s  |  22 +++++
+ ld/testsuite/ld-or1k/or1k.exp  |   8 ++
+ ld/testsuite/ld-or1k/pltlib.s  |   1 +
+ 7 files changed, 220 insertions(+), 39 deletions(-)
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.s
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.s
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 07fff3602a3..fcebbe5f23a 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -30,10 +30,14 @@
+ #define N_ONES(X)	(((bfd_vma)2 << (X)) - 1)
+ 
+ #define PLT_ENTRY_SIZE 16
++#define PLT_ENTRY_SIZE_LARGE (6*4)
++#define PLT_MAX_INSN_COUNT 6
+ 
+ #define OR1K_MOVHI(D)		(0x18000000 | (D << 21))
+ #define OR1K_ADRP(D)		(0x08000000 | (D << 21))
+ #define OR1K_LWZ(D,A)		(0x84000000 | (D << 21) | (A << 16))
++#define OR1K_ADD(D,A,B)		(0xE0000000 | (D << 21) | (A << 16) | (B << 11))
++#define OR1K_ORI(D,A)		(0xA8000000 | (D << 21) | (A << 16))
+ #define OR1K_ORI0(D)		(0xA8000000 | (D << 21))
+ #define OR1K_JR(B)		(0x44000000 | (B << 11))
+ #define OR1K_NOP		0x15000000
+@@ -903,6 +907,8 @@ struct elf_or1k_link_hash_entry
+   /* Track dynamic relocs copied for this symbol.  */
+   struct elf_dyn_relocs *dyn_relocs;
+ 
++  /* For calculating PLT size.  */
++  bfd_vma plt_index;
+   /* Track type of TLS access.  */
+   unsigned char tls_type;
+ };
+@@ -930,9 +936,20 @@ struct elf_or1k_link_hash_table
+   /* Small local sym to section mapping cache.  */
+   struct sym_cache sym_sec;
+ 
++  bfd_vma plt_count;
+   bfd_boolean saw_plta;
+ };
+ 
++static size_t
++elf_or1k_plt_entry_size (bfd_vma plt_index)
++{
++  bfd_vma plt_reloc;
++
++  plt_reloc = plt_index * sizeof (Elf32_External_Rela);
++
++  return (plt_reloc > 0xffff) ? PLT_ENTRY_SIZE_LARGE : PLT_ENTRY_SIZE;
++}
++
+ /* Get the ELF linker hash table from a link_info structure.  */
+ #define or1k_elf_hash_table(p) \
+   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+@@ -2176,33 +2193,46 @@ or1k_elf_check_relocs (bfd *abfd,
+ }
+ 
+ static void
+-or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insn1,
+-		      unsigned insn2, unsigned insn3, unsigned insnj)
++or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
++		      unsigned insns[], size_t insn_count)
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+-  unsigned insn4;
++  unsigned output_insns[PLT_MAX_INSN_COUNT];
++
++  /* Copy instructions into the output buffer.  */
++  for (size_t i = 0; i < insn_count; i++)
++    output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+-  if (insn3 == OR1K_NOP)
++  if (insns[insn_count-1] == OR1K_NOP)
+     {
+-      insn4 = insn3;
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn3 = insnj;
++	slot1 = insns[insn_count-2], slot2 = insnj;
+       else
+-	insn3 = insn2, insn2 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-2];
++
++      output_insns[insn_count-2] = slot1;
++      output_insns[insn_count-1] = slot2;
++      output_insns[insn_count]   = OR1K_NOP;
+     }
+   else
+     {
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn4 = insnj;
++	slot1 = insns[insn_count-1], slot2 = insnj;
+       else
+-	insn4 = insn3, insn3 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-1];
++
++      output_insns[insn_count-1] = slot1;
++      output_insns[insn_count]   = slot2;
+     }
+ 
+-  bfd_put_32 (output_bfd, insn1, contents);
+-  bfd_put_32 (output_bfd, insn2, contents + 4);
+-  bfd_put_32 (output_bfd, insn3, contents + 8);
+-  bfd_put_32 (output_bfd, insn4, contents + 12);
++  /* Write out the output buffer.  */
++  for (size_t i = 0; i < (insn_count+1); i++)
++    bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+ /* Finish up the dynamic sections.  */
+@@ -2269,7 +2299,8 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+       splt = htab->root.splt;
+       if (splt && splt->size > 0)
+ 	{
+-	  unsigned plt0, plt1, plt2;
++	  unsigned plt[PLT_MAX_INSN_COUNT];
++	  size_t plt_insn_count = 3;
+ 	  bfd_vma got_addr = sgot->output_section->vma + sgot->output_offset;
+ 
+ 	  /* Note we force 16 byte alignment on the .got, so that
+@@ -2280,27 +2311,27 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+ 	      bfd_vma pc = splt->output_section->vma + splt->output_offset;
+ 	      unsigned pa = ((got_addr >> 13) - (pc >> 13)) & 0x1fffff;
+ 	      unsigned po = got_addr & 0x1fff;
+-	      plt0 = OR1K_ADRP(12) | pa;
+-	      plt1 = OR1K_LWZ(15,12) | (po + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (po + 4);
++	      plt[0] = OR1K_ADRP(12) | pa;
++	      plt[1] = OR1K_LWZ(15,12) | (po + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (po + 4);
+ 	    }
+ 	  else if (bfd_link_pic (info))
+ 	    {
+-	      plt0 = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
+-	      plt1 = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
+-	      plt2 = OR1K_NOP;
++	      plt[0] = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
++	      plt[1] = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
++	      plt[2] = OR1K_NOP;
+ 	    }
+ 	  else
+ 	    {
+ 	      unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	      unsigned lo = got_addr & 0xffff;
+-	      plt0 = OR1K_MOVHI(12) | ha;
+-	      plt1 = OR1K_LWZ(15,12) | (lo + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (lo + 4);
++	      plt[0] = OR1K_MOVHI(12) | ha;
++	      plt[1] = OR1K_LWZ(15,12) | (lo + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (lo + 4);
+ 	    }
+ 
+-	  or1k_write_plt_entry (output_bfd, splt->contents,
+-				plt0, plt1, plt2, OR1K_JR(15));
++	  or1k_write_plt_entry (output_bfd, splt->contents, OR1K_JR(15),
++				plt, plt_insn_count);
+ 
+ 	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ 	}
+@@ -2343,7 +2374,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 
+   if (h->plt.offset != (bfd_vma) -1)
+     {
+-      unsigned int plt0, plt1, plt2;
++      unsigned int plt[PLT_MAX_INSN_COUNT];
++      size_t plt_insn_count = 3;
+       asection *splt;
+       asection *sgot;
+       asection *srela;
+@@ -2355,6 +2387,7 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+       bfd_vma got_offset;
+       bfd_vma got_addr;
+       Elf_Internal_Rela rela;
++      bfd_boolean large_plt_entry;
+ 
+       /* This symbol has an entry in the procedure linkage table.  Set
+ 	 it up.  */
+@@ -2372,10 +2405,13 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	 corresponds to this symbol.  This is the index of this symbol
+ 	 in all the symbols for which we are making plt entries.  The
+ 	 first entry in the procedure linkage table is reserved.  */
+-      plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
++      plt_index = ((struct elf_or1k_link_hash_entry *) h)->plt_index;
+       plt_addr = plt_base_addr + h->plt.offset;
+       plt_reloc = plt_index * sizeof (Elf32_External_Rela);
+ 
++      large_plt_entry = (elf_or1k_plt_entry_size (plt_index)
++			 == PLT_ENTRY_SIZE_LARGE);
++
+       /* Get the offset into the .got table of the entry that
+ 	corresponds to this function.  Each .got entry is 4 bytes.
+ 	The first three are reserved.  */
+@@ -2387,27 +2423,57 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	{
+ 	  unsigned pa = ((got_addr >> 13) - (plt_addr >> 13)) & 0x1fffff;
+ 	  unsigned po = (got_addr & 0x1fff);
+-	  plt0 = OR1K_ADRP(12) | pa;
+-	  plt1 = OR1K_LWZ(12,12) | po;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_ADRP(12) | pa;
++	  plt[1] = OR1K_LWZ(12,12) | po;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
+ 	}
+       else if (bfd_link_pic (info))
+ 	{
+-	  plt0 = OR1K_LWZ(12,16) | got_offset;
+-	  plt1 = OR1K_ORI0(11) | plt_reloc;
+-	  plt2 = OR1K_NOP;
++	  if (large_plt_entry)
++	    {
++	      unsigned gotha = ((got_offset + 0x8000) >> 16) & 0xffff;
++	      unsigned got = got_offset & 0xffff;
++	      unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	      unsigned pltrello = plt_reloc & 0xffff;
++
++	      plt[0] = OR1K_MOVHI(12) | gotha;
++	      plt[1] = OR1K_ADD(12,12,16);
++	      plt[2] = OR1K_LWZ(12,12) | got;
++	      plt[3] = OR1K_MOVHI(11) | pltrelhi;
++	      plt[4] = OR1K_ORI(11,11) | pltrello;
++	      plt_insn_count = 5;
++	    }
++	  else
++	    {
++	      plt[0] = OR1K_LWZ(12,16) | got_offset;
++	      plt[1] = OR1K_ORI0(11) | plt_reloc;
++	      plt[2] = OR1K_NOP;
++	    }
+ 	}
+       else
+ 	{
+ 	  unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	  unsigned lo = got_addr & 0xffff;
+-	  plt0 = OR1K_MOVHI(12) | ha;
+-	  plt1 = OR1K_LWZ(12,12) | lo;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_MOVHI(12) | ha;
++	  plt[1] = OR1K_LWZ(12,12) | lo;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
++	}
++
++      /* For large code model we fixup the non-PIC PLT relocation instructions
++	 here.  */
++      if (large_plt_entry && !bfd_link_pic (info))
++	{
++	  unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	  unsigned pltrello = plt_reloc & 0xffff;
++
++	  plt[2] = OR1K_MOVHI(11) | pltrelhi;
++	  plt[3] = OR1K_ORI(11,11) | pltrello;
++	  plt[4] = OR1K_NOP;
++	  plt_insn_count = 5;
+ 	}
+ 
+       or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset,
+-			    plt0, plt1, plt2, OR1K_JR(12));
++			    OR1K_JR(12), plt, plt_insn_count);
+ 
+       /* Fill in the entry in the global offset table.  */
+       bfd_put_32 (output_bfd, plt_addr, sgot->contents + got_offset);
+@@ -2699,11 +2765,16 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
+ 	{
+ 	  asection *s = htab->root.splt;
++	  bfd_vma plt_index;
++
++	  /* Track the index of our plt entry for use in calculating size.  */
++	  plt_index = htab->plt_count++;
++	  ((struct elf_or1k_link_hash_entry *) h)->plt_index = plt_index;
+ 
+ 	  /* If this is the first .plt entry, make room for the special
+ 	     first entry.  */
+ 	  if (s->size == 0)
+-	    s->size = PLT_ENTRY_SIZE;
++	    s->size = elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  h->plt.offset = s->size;
+ 
+@@ -2720,7 +2791,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+ 	    }
+ 
+ 	  /* Make room for this entry.  */
+-	  s->size += PLT_ENTRY_SIZE;
++	  s->size += elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  /* We also need to make an entry in the .got.plt section, which
+ 	     will be placed in the .got section by the linker script.  */
+diff --git a/ld/testsuite/ld-or1k/gotha1.dd b/ld/testsuite/ld-or1k/gotha1.dd
+new file mode 100644
+index 00000000000..0ad1f8f5399
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.dd
+@@ -0,0 +1,34 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.plt:
++
++[0-9a-f]+ <\.plt>:
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 ec [0-9a-f]+ [0-9a-f]+ 	l\.lwz r15,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 78 00 	l\.jr r15
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 60 00 	l\.jr r12
++ +[0-9a-f]+:	a9 60 00 00 	l\.ori r11,r0,0x0
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <_start>:
++ +[0-9a-f]+:	9c 21 ff fc 	l\.addi r1,r1,-4
++ +[0-9a-f]+:	d4 01 48 00 	l\.sw 0\(r1\),r9
++ +[0-9a-f]+:	04 00 00 02 	l\.jal [0-9a-f]+ <_start\+0x10>
++ +[0-9a-f]+:	1a 60 00 00 	l\.movhi r19,0x0
++ +[0-9a-f]+:	aa 73 [0-9a-f]+ [0-9a-f]+ 	l\.ori r19,r19,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 73 48 00 	l\.add r19,r19,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 98 00 	l\.add r17,r17,r19
++ +[0-9a-f]+:	86 31 00 10 	l\.lwz r17,16\(r17\)
++ +[0-9a-f]+:	84 71 00 00 	l\.lwz r3,0\(r17\)
++ +[0-9a-f]+:	07 ff ff f2 	l\.jal [0-9a-f]+ <\.plt\+0x10>
++ +[0-9a-f]+:	15 00 00 00 	l\.nop 0x0
++ +[0-9a-f]+:	85 21 00 00 	l\.lwz r9,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 04 	l\.addi r1,r1,4
+diff --git a/ld/testsuite/ld-or1k/gotha1.s b/ld/testsuite/ld-or1k/gotha1.s
+new file mode 100644
+index 00000000000..42b16db425c
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.s
+@@ -0,0 +1,24 @@
++	.data
++	.p2align 16
++
++	.text
++	.globl	_start
++_start:
++	l.addi	r1, r1, -4
++	l.sw	0(r1), r9
++
++	l.jal	8
++	 l.movhi	r19, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r19, r19, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r19, r19, r9
++
++	l.movhi	r17, gotha(x)
++	l.add	r17, r17, r19
++	l.lwz	r17, got(x)(r17)
++	l.lwz	r3, 0(r17)
++
++	l.jal	plt(func)
++	 l.nop
++	l.lwz	r9, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 4
+diff --git a/ld/testsuite/ld-or1k/gotha2.dd b/ld/testsuite/ld-or1k/gotha2.dd
+new file mode 100644
+index 00000000000..fe09da5466b
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.dd
+@@ -0,0 +1,21 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <test>:
++ +[0-9a-f]+:	9c 21 ff f8 	l\.addi r1,r1,-8
++ +[0-9a-f]+:	d4 01 80 00 	l\.sw 0\(r1\),r16
++ +[0-9a-f]+:	d4 01 48 04 	l\.sw 4\(r1\),r9
++ +[0-9a-f]+:	04 00 [0-9a-f]+ [0-9a-f]+ 	l\.jal [0-9a-f]+ <test\+0x14>
++ +[0-9a-f]+:	1a 00 00 00 	l\.movhi r16,0x0
++ +[0-9a-f]+:	aa 10 [0-9a-f]+ [0-9a-f]+ 	l\.ori r16,r16,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 10 48 00 	l\.add r16,r16,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 80 00 	l\.add r17,r17,r16
++ +[0-9a-f]+:	86 31 00 0c 	l\.lwz r17,12\(r17\)
++ +[0-9a-f]+:	85 21 00 04 	l\.lwz r9,4\(r1\)
++ +[0-9a-f]+:	86 01 00 00 	l\.lwz r16,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 08 	l\.addi r1,r1,8
+diff --git a/ld/testsuite/ld-or1k/gotha2.s b/ld/testsuite/ld-or1k/gotha2.s
+new file mode 100644
+index 00000000000..164b282f2dd
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.s
+@@ -0,0 +1,22 @@
++	.section	.text
++	.align 4
++	.global	test
++	.type	test, @function
++test:
++	l.addi	r1, r1, -8
++	l.sw	0(r1), r16
++	l.sw	4(r1), r9
++
++	l.jal	8
++	 l.movhi	r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r16, r16, r9
++
++	l.movhi	r17, gotha(i)
++	l.add	r17, r17, r16
++	l.lwz	r17, got(i)(r17)
++
++	l.lwz	r9, 4(r1)
++	l.lwz	r16, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 8
+diff --git a/ld/testsuite/ld-or1k/or1k.exp b/ld/testsuite/ld-or1k/or1k.exp
+index 24cdbe5fbf3..9cebc49b946 100644
+--- a/ld/testsuite/ld-or1k/or1k.exp
++++ b/ld/testsuite/ld-or1k/or1k.exp
+@@ -53,6 +53,14 @@ set or1kplttests {
+      "" {plt1.s}
+      {{objdump -dr plt1.x.dd}}
+      "plt1.x"}
++    {"gotha exec plt" "tmpdir/libpltlib.so" ""
++     "" {gotha1.s}
++     {{objdump -dr gotha1.dd}}
++     "gotha1.x"}
++    {"gotha -fpic -shared" "-fpic -shared" ""
++     "" {gotha2.s}
++     {{objdump -dr gotha2.dd}}
++     "gotha2.x"}
+ }
+ 
+ # Not implemented yet
+diff --git a/ld/testsuite/ld-or1k/pltlib.s b/ld/testsuite/ld-or1k/pltlib.s
+index baf76ca1af7..8b4d7ba48fd 100644
+--- a/ld/testsuite/ld-or1k/pltlib.s
++++ b/ld/testsuite/ld-or1k/pltlib.s
+@@ -1,5 +1,6 @@
+ 	.section .data
+ 	.globl x, y
++	.size x, 4
+ x:	.long 33
+ y:	.long 44
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch b/package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
new file mode 100644
index 0000000000..3a5a426f09
--- /dev/null
+++ b/package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
@@ -0,0 +1,256 @@
+From 5fb945116ba058eb8f032f94ab2e0c71024388ec Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:15 +0900
+Subject: [PATCH 4/6] or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
+
+The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
+using the -mcmodel=large option.  This relocation is used along with
+got() to generate 32-bit GOT offsets.  This increases the previous GOT
+offset limit from the previous 16-bit (64K) limit.
+
+This is needed on large binaries where the GOT grows larger than 64k.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
+	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
+	(or1k_final_link_relocate, or1k_elf_relocate_section,
+	or1k_elf_check_relocs): Likewise.
+	* libbfd.h (bfd_reloc_code_real_names): Likewise.
+	* reloc.c: Likewise.
+
+cpu/ChangeLog:
+
+	PR 21464
+	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
+	for gotha() relocation.
+
+include/ChangeLog:
+
+	PR 21464
+	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.
+
+opcodes/ChangeLog:
+
+	PR 21464
+	* or1k-asm.c: Regenerate.
+
+gas/ChangeLog:
+
+	PR 21464
+	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
+	* testsuite/gas/or1k/reloc-1.d: Add test result for new
+	relocation.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+
+fixup reloc, add tests
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/bfd-in2.h                    |  1 +
+ bfd/elf32-or1k.c                 | 21 ++++++++++++++++++++-
+ bfd/libbfd.h                     |  1 +
+ bfd/reloc.c                      |  2 ++
+ cpu/or1k.opc                     |  7 ++++++-
+ gas/testsuite/gas/or1k/reloc-1.d |  4 +++-
+ gas/testsuite/gas/or1k/reloc-1.s |  4 ++++
+ include/elf/or1k.h               |  1 +
+ opcodes/or1k-asm.c               |  7 ++++++-
+ 9 files changed, 44 insertions(+), 4 deletions(-)
+
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index 7c13bc8c91a..ae1082a67c2 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -5017,6 +5017,7 @@ then it may be truncated to 8 bits.  */
+   BFD_RELOC_OR1K_TLS_TPOFF,
+   BFD_RELOC_OR1K_TLS_DTPOFF,
+   BFD_RELOC_OR1K_TLS_DTPMOD,
++  BFD_RELOC_OR1K_GOT_AHI16,
+ 
+ /* H8 elf Relocations.  */
+   BFD_RELOC_H8_DIR16A8,
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 58246875546..1273fbacb3c 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -808,6 +808,20 @@ static reloc_howto_type or1k_elf_howto_table[] =
+ 	 0,			/* Source Mask.  */
+ 	 0x03ffffff,		/* Dest Mask.  */
+ 	 TRUE),			/* PC relative offset?  */
++
++  HOWTO (R_OR1K_GOT_AHI16,     /* type */
++	16,                    /* rightshift */
++	2,                     /* size (0 = byte, 1 = short, 2 = long) */
++	16,                    /* bitsize */
++	FALSE,                 /* pc_relative */
++	0,                     /* bitpos */
++	complain_overflow_signed, /* complain_on_overflow */
++	bfd_elf_generic_reloc, /* special_function */
++	"R_OR1K_GOT_AHI16",    /* name */
++	FALSE,                 /* partial_inplace */
++	0,                     /* src_mask */
++	0xffff,                /* dst_mask */
++	FALSE),                /* pcrel_offset */
+ };
+ 
+ /* Map BFD reloc types to Or1k ELF reloc types.  */
+@@ -871,6 +885,7 @@ static const struct or1k_reloc_map or1k_reloc_map[] =
+   { BFD_RELOC_OR1K_TLS_IE_LO13,	R_OR1K_TLS_IE_LO13 },
+   { BFD_RELOC_OR1K_SLO13,	R_OR1K_SLO13 },
+   { BFD_RELOC_OR1K_PLTA26,	R_OR1K_PLTA26 },
++  { BFD_RELOC_OR1K_GOT_AHI16,	R_OR1K_GOT_AHI16 },
+ };
+ 
+ #define TLS_UNKNOWN    0
+@@ -1080,6 +1095,7 @@ or1k_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd,
+   switch (howto->type)
+     {
+     case R_OR1K_AHI16:
++    case R_OR1K_GOT_AHI16:
+     case R_OR1K_GOTOFF_AHI16:
+     case R_OR1K_TLS_IE_AHI16:
+     case R_OR1K_TLS_LE_AHI16:
+@@ -1344,6 +1360,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+@@ -1435,7 +1452,8 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    /* The GOT_PG21 and GOT_LO13 relocs are pc-relative,
+ 	       while the GOT16 reloc is GOT relative.  */
+ 	    relocation = got_base + off;
+-	    if (r_type == R_OR1K_GOT16)
++	    if (r_type == R_OR1K_GOT16
++		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
+ 	  /* Addend should be zero.  */
+@@ -1943,6 +1961,7 @@ or1k_elf_check_relocs (bfd *abfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+diff --git a/bfd/libbfd.h b/bfd/libbfd.h
+index d97d4e57a77..9edc71e0558 100644
+--- a/bfd/libbfd.h
++++ b/bfd/libbfd.h
+@@ -2704,6 +2704,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+   "BFD_RELOC_OR1K_TLS_TPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPMOD",
++  "BFD_RELOC_OR1K_GOT_AHI16",
+   "BFD_RELOC_H8_DIR16A8",
+   "BFD_RELOC_H8_DIR16R8",
+   "BFD_RELOC_H8_DIR24A8",
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index 33cd67150cf..f57ad14a501 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -6175,6 +6175,8 @@ ENUMX
+   BFD_RELOC_OR1K_GOTPC_HI16
+ ENUMX
+   BFD_RELOC_OR1K_GOTPC_LO16
++ENUMX
++  BFD_RELOC_OR1K_GOT_AHI16
+ ENUMX
+   BFD_RELOC_OR1K_GOT16
+ ENUMX
+diff --git a/cpu/or1k.opc b/cpu/or1k.opc
+index f0adcbb00a5..5d20a1f33a7 100644
+--- a/cpu/or1k.opc
++++ b/cpu/or1k.opc
+@@ -193,7 +193,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -296,6 +296,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+diff --git a/gas/testsuite/gas/or1k/reloc-1.d b/gas/testsuite/gas/or1k/reloc-1.d
+index d1bcf5608bb..3a001c4ed99 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.d
++++ b/gas/testsuite/gas/or1k/reloc-1.d
+@@ -68,5 +68,7 @@ OFFSET   TYPE              VALUE
+ 000000ec R_OR1K_LO13       x
+ 000000f0 R_OR1K_GOT_LO13   x
+ 000000f4 R_OR1K_SLO13      x
+-
++000000f8 R_OR1K_GOT_AHI16  x
++000000fc R_OR1K_GOT_AHI16  x
++00000100 R_OR1K_GOT_AHI16  x
+ 
+diff --git a/gas/testsuite/gas/or1k/reloc-1.s b/gas/testsuite/gas/or1k/reloc-1.s
+index e76abef6532..562609aa869 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.s
++++ b/gas/testsuite/gas/or1k/reloc-1.s
+@@ -74,3 +74,7 @@
+ 	l.lbz	r5,po(x)(r3)
+ 	l.lbz	r5,gotpo(x)(r3)
+ 	l.sb	po(x)(r3),r6
++
++	l.movhi	r4,gotha(x)
++	l.ori	r3,r4,gotha(x)
++	l.addi	r3,r4,gotha(x)
+diff --git a/include/elf/or1k.h b/include/elf/or1k.h
+index a215ef5c17e..dff37d875f2 100644
+--- a/include/elf/or1k.h
++++ b/include/elf/or1k.h
+@@ -77,6 +77,7 @@ START_RELOC_NUMBERS (elf_or1k_reloc_type)
+   RELOC_NUMBER (R_OR1K_TLS_IE_LO13,   51)
+   RELOC_NUMBER (R_OR1K_SLO13,         52)
+   RELOC_NUMBER (R_OR1K_PLTA26,        53)
++  RELOC_NUMBER (R_OR1K_GOT_AHI16,     54)
+ END_RELOC_NUMBERS (R_OR1K_max)
+ 
+ #define EF_OR1K_NODELAY (1UL << 0)
+diff --git a/opcodes/or1k-asm.c b/opcodes/or1k-asm.c
+index 4715c4f2826..a72a4e85363 100644
+--- a/opcodes/or1k-asm.c
++++ b/opcodes/or1k-asm.c
+@@ -177,7 +177,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -280,6 +280,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch b/package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
new file mode 100644
index 0000000000..9a88d1407c
--- /dev/null
+++ b/package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
@@ -0,0 +1,61 @@
+From d92116c7df340ff40063c5c97d202e7e87400027 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:16 +0900
+Subject: [PATCH 5/6] or1k: Avoid R_OR1K_GOT16 overflow failures in presence of
+ R_OR1K_GOT_AHI16
+
+Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
+overflow validation check if the section has R_OR1K_GOT_AHI16.
+
+We cannot simple disable R_OR1K_GOT16 overflow validation as there will
+still be binaries that will have only R_OR1K_GOT16.  The
+R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
+the option -mcmodel=large.
+
+This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
+is the code pattern that will be emitted by GCC.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
+	overflow check if we have R_OR1K_GOT_AHI16 followed by
+	R_OR1K_GOT16.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 1273fbacb3c..ce2c4fdb3bd 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -1248,6 +1248,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+   asection *sgot, *splt;
+   bfd_vma plt_base, got_base, got_sym_value;
+   bfd_boolean ret_val = TRUE;
++  bfd_boolean saw_gotha = FALSE;
+ 
+   if (htab == NULL)
+     return FALSE;
+@@ -1456,6 +1457,16 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
++	    if (r_type == R_OR1K_GOT_AHI16)
++	      saw_gotha = TRUE;
++
++	    /* If we have a R_OR1K_GOT16 followed by a R_OR1K_GOT_AHI16
++	       relocation we assume the code is doing the right thing to avoid
++	       overflows.  Here we mask the lower 16-bit of the relocation to
++	       avoid overflow validation failures.  */
++	    if (r_type == R_OR1K_GOT16 && saw_gotha)
++	      relocation &= 0xffff;
++
+ 	  /* Addend should be zero.  */
+ 	  if (rel->r_addend != 0)
+ 	    {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch b/package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
new file mode 100644
index 0000000000..4032253ac0
--- /dev/null
+++ b/package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
@@ -0,0 +1,500 @@
+From cba29e387040eaa401c52eb20e7cab5a4401185c Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:17 +0900
+Subject: [PATCH 6/6] or1k: Support large plt_relocs when generating plt
+ entries
+
+The current PLT generation code will generate invalid code when the PLT
+relocation offset exceeds 64k.  This fixes the issue by detecting large
+plt_reloc offsets and generare code sequences to create larger plt
+relocations.
+
+The "large" plt code needs 2 extra instructions to create 32-bit offsets.
+
+bfd/ChangeLog:
+
+	PR 27746
+	* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
+	OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
+	(elf_or1k_link_hash_table): New field plt_count.
+	(elf_or1k_link_hash_entry): New field plt_index.
+	(elf_or1k_plt_entry_size): New function.
+	(or1k_write_plt_entry): Update to support variable size PLTs.
+	(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
+	API.
+	(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
+	when needed.
+	(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
+	PLT size.
+
+ld/ChangeLog:
+
+	PR 27746
+	testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
+	along with gotha() relocations.
+	testsuite/ld-or1k/gotha1.dd: New file.
+	testsuite/ld-or1k/gotha1.s: New file.
+	testsuite/ld-or1k/gotha2.dd: New file.
+	testsuite/ld-or1k/gotha2.s: New file
+	testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
+	failure.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c               | 149 ++++++++++++++++++++++++---------
+ ld/testsuite/ld-or1k/gotha1.dd |  34 ++++++++
+ ld/testsuite/ld-or1k/gotha1.s  |  24 ++++++
+ ld/testsuite/ld-or1k/gotha2.dd |  21 +++++
+ ld/testsuite/ld-or1k/gotha2.s  |  22 +++++
+ ld/testsuite/ld-or1k/or1k.exp  |   8 ++
+ ld/testsuite/ld-or1k/pltlib.s  |   1 +
+ 7 files changed, 220 insertions(+), 39 deletions(-)
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.s
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.s
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index ce2c4fdb3bd..8b021b79d92 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -30,10 +30,14 @@
+ #define N_ONES(X)	(((bfd_vma)2 << (X)) - 1)
+ 
+ #define PLT_ENTRY_SIZE 16
++#define PLT_ENTRY_SIZE_LARGE (6*4)
++#define PLT_MAX_INSN_COUNT 6
+ 
+ #define OR1K_MOVHI(D)		(0x18000000 | (D << 21))
+ #define OR1K_ADRP(D)		(0x08000000 | (D << 21))
+ #define OR1K_LWZ(D,A)		(0x84000000 | (D << 21) | (A << 16))
++#define OR1K_ADD(D,A,B)		(0xE0000000 | (D << 21) | (A << 16) | (B << 11))
++#define OR1K_ORI(D,A)		(0xA8000000 | (D << 21) | (A << 16))
+ #define OR1K_ORI0(D)		(0xA8000000 | (D << 21))
+ #define OR1K_JR(B)		(0x44000000 | (B << 11))
+ #define OR1K_NOP		0x15000000
+@@ -903,6 +907,8 @@ struct elf_or1k_link_hash_entry
+   /* Track dynamic relocs copied for this symbol.  */
+   struct elf_dyn_relocs *dyn_relocs;
+ 
++  /* For calculating PLT size.  */
++  bfd_vma plt_index;
+   /* Track type of TLS access.  */
+   unsigned char tls_type;
+ };
+@@ -930,9 +936,20 @@ struct elf_or1k_link_hash_table
+   /* Small local sym to section mapping cache.  */
+   struct sym_cache sym_sec;
+ 
++  bfd_vma plt_count;
+   bfd_boolean saw_plta;
+ };
+ 
++static size_t
++elf_or1k_plt_entry_size (bfd_vma plt_index)
++{
++  bfd_vma plt_reloc;
++
++  plt_reloc = plt_index * sizeof (Elf32_External_Rela);
++
++  return (plt_reloc > 0xffff) ? PLT_ENTRY_SIZE_LARGE : PLT_ENTRY_SIZE;
++}
++
+ /* Get the ELF linker hash table from a link_info structure.  */
+ #define or1k_elf_hash_table(p) \
+   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+@@ -2173,33 +2190,46 @@ or1k_elf_check_relocs (bfd *abfd,
+ }
+ 
+ static void
+-or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insn1,
+-		      unsigned insn2, unsigned insn3, unsigned insnj)
++or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
++		      unsigned insns[], size_t insn_count)
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+-  unsigned insn4;
++  unsigned output_insns[PLT_MAX_INSN_COUNT];
++
++  /* Copy instructions into the output buffer.  */
++  for (size_t i = 0; i < insn_count; i++)
++    output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+-  if (insn3 == OR1K_NOP)
++  if (insns[insn_count-1] == OR1K_NOP)
+     {
+-      insn4 = insn3;
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn3 = insnj;
++	slot1 = insns[insn_count-2], slot2 = insnj;
+       else
+-	insn3 = insn2, insn2 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-2];
++
++      output_insns[insn_count-2] = slot1;
++      output_insns[insn_count-1] = slot2;
++      output_insns[insn_count]   = OR1K_NOP;
+     }
+   else
+     {
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn4 = insnj;
++	slot1 = insns[insn_count-1], slot2 = insnj;
+       else
+-	insn4 = insn3, insn3 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-1];
++
++      output_insns[insn_count-1] = slot1;
++      output_insns[insn_count]   = slot2;
+     }
+ 
+-  bfd_put_32 (output_bfd, insn1, contents);
+-  bfd_put_32 (output_bfd, insn2, contents + 4);
+-  bfd_put_32 (output_bfd, insn3, contents + 8);
+-  bfd_put_32 (output_bfd, insn4, contents + 12);
++  /* Write out the output buffer.  */
++  for (size_t i = 0; i < (insn_count+1); i++)
++    bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+ /* Finish up the dynamic sections.  */
+@@ -2266,7 +2296,8 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+       splt = htab->root.splt;
+       if (splt && splt->size > 0)
+ 	{
+-	  unsigned plt0, plt1, plt2;
++	  unsigned plt[PLT_MAX_INSN_COUNT];
++	  size_t plt_insn_count = 3;
+ 	  bfd_vma got_addr = sgot->output_section->vma + sgot->output_offset;
+ 
+ 	  /* Note we force 16 byte alignment on the .got, so that
+@@ -2277,27 +2308,27 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+ 	      bfd_vma pc = splt->output_section->vma + splt->output_offset;
+ 	      unsigned pa = ((got_addr >> 13) - (pc >> 13)) & 0x1fffff;
+ 	      unsigned po = got_addr & 0x1fff;
+-	      plt0 = OR1K_ADRP(12) | pa;
+-	      plt1 = OR1K_LWZ(15,12) | (po + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (po + 4);
++	      plt[0] = OR1K_ADRP(12) | pa;
++	      plt[1] = OR1K_LWZ(15,12) | (po + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (po + 4);
+ 	    }
+ 	  else if (bfd_link_pic (info))
+ 	    {
+-	      plt0 = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
+-	      plt1 = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
+-	      plt2 = OR1K_NOP;
++	      plt[0] = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
++	      plt[1] = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
++	      plt[2] = OR1K_NOP;
+ 	    }
+ 	  else
+ 	    {
+ 	      unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	      unsigned lo = got_addr & 0xffff;
+-	      plt0 = OR1K_MOVHI(12) | ha;
+-	      plt1 = OR1K_LWZ(15,12) | (lo + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (lo + 4);
++	      plt[0] = OR1K_MOVHI(12) | ha;
++	      plt[1] = OR1K_LWZ(15,12) | (lo + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (lo + 4);
+ 	    }
+ 
+-	  or1k_write_plt_entry (output_bfd, splt->contents,
+-				plt0, plt1, plt2, OR1K_JR(15));
++	  or1k_write_plt_entry (output_bfd, splt->contents, OR1K_JR(15),
++				plt, plt_insn_count);
+ 
+ 	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ 	}
+@@ -2340,7 +2371,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 
+   if (h->plt.offset != (bfd_vma) -1)
+     {
+-      unsigned int plt0, plt1, plt2;
++      unsigned int plt[PLT_MAX_INSN_COUNT];
++      size_t plt_insn_count = 3;
+       asection *splt;
+       asection *sgot;
+       asection *srela;
+@@ -2352,6 +2384,7 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+       bfd_vma got_offset;
+       bfd_vma got_addr;
+       Elf_Internal_Rela rela;
++      bfd_boolean large_plt_entry;
+ 
+       /* This symbol has an entry in the procedure linkage table.  Set
+ 	 it up.  */
+@@ -2369,10 +2402,13 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	 corresponds to this symbol.  This is the index of this symbol
+ 	 in all the symbols for which we are making plt entries.  The
+ 	 first entry in the procedure linkage table is reserved.  */
+-      plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
++      plt_index = ((struct elf_or1k_link_hash_entry *) h)->plt_index;
+       plt_addr = plt_base_addr + h->plt.offset;
+       plt_reloc = plt_index * sizeof (Elf32_External_Rela);
+ 
++      large_plt_entry = (elf_or1k_plt_entry_size (plt_index)
++			 == PLT_ENTRY_SIZE_LARGE);
++
+       /* Get the offset into the .got table of the entry that
+ 	corresponds to this function.  Each .got entry is 4 bytes.
+ 	The first three are reserved.  */
+@@ -2384,27 +2420,57 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	{
+ 	  unsigned pa = ((got_addr >> 13) - (plt_addr >> 13)) & 0x1fffff;
+ 	  unsigned po = (got_addr & 0x1fff);
+-	  plt0 = OR1K_ADRP(12) | pa;
+-	  plt1 = OR1K_LWZ(12,12) | po;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_ADRP(12) | pa;
++	  plt[1] = OR1K_LWZ(12,12) | po;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
+ 	}
+       else if (bfd_link_pic (info))
+ 	{
+-	  plt0 = OR1K_LWZ(12,16) | got_offset;
+-	  plt1 = OR1K_ORI0(11) | plt_reloc;
+-	  plt2 = OR1K_NOP;
++	  if (large_plt_entry)
++	    {
++	      unsigned gotha = ((got_offset + 0x8000) >> 16) & 0xffff;
++	      unsigned got = got_offset & 0xffff;
++	      unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	      unsigned pltrello = plt_reloc & 0xffff;
++
++	      plt[0] = OR1K_MOVHI(12) | gotha;
++	      plt[1] = OR1K_ADD(12,12,16);
++	      plt[2] = OR1K_LWZ(12,12) | got;
++	      plt[3] = OR1K_MOVHI(11) | pltrelhi;
++	      plt[4] = OR1K_ORI(11,11) | pltrello;
++	      plt_insn_count = 5;
++	    }
++	  else
++	    {
++	      plt[0] = OR1K_LWZ(12,16) | got_offset;
++	      plt[1] = OR1K_ORI0(11) | plt_reloc;
++	      plt[2] = OR1K_NOP;
++	    }
+ 	}
+       else
+ 	{
+ 	  unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	  unsigned lo = got_addr & 0xffff;
+-	  plt0 = OR1K_MOVHI(12) | ha;
+-	  plt1 = OR1K_LWZ(12,12) | lo;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_MOVHI(12) | ha;
++	  plt[1] = OR1K_LWZ(12,12) | lo;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
++	}
++
++      /* For large code model we fixup the non-PIC PLT relocation instructions
++	 here.  */
++      if (large_plt_entry && !bfd_link_pic (info))
++	{
++	  unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	  unsigned pltrello = plt_reloc & 0xffff;
++
++	  plt[2] = OR1K_MOVHI(11) | pltrelhi;
++	  plt[3] = OR1K_ORI(11,11) | pltrello;
++	  plt[4] = OR1K_NOP;
++	  plt_insn_count = 5;
+ 	}
+ 
+       or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset,
+-			    plt0, plt1, plt2, OR1K_JR(12));
++			    OR1K_JR(12), plt, plt_insn_count);
+ 
+       /* Fill in the entry in the global offset table.  We initialize it to
+ 	 point to the top of the plt.  This is done to lazy lookup the actual
+@@ -2699,11 +2765,16 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
+ 	{
+ 	  asection *s = htab->root.splt;
++	  bfd_vma plt_index;
++
++	  /* Track the index of our plt entry for use in calculating size.  */
++	  plt_index = htab->plt_count++;
++	  ((struct elf_or1k_link_hash_entry *) h)->plt_index = plt_index;
+ 
+ 	  /* If this is the first .plt entry, make room for the special
+ 	     first entry.  */
+ 	  if (s->size == 0)
+-	    s->size = PLT_ENTRY_SIZE;
++	    s->size = elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  h->plt.offset = s->size;
+ 
+@@ -2720,7 +2791,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+ 	    }
+ 
+ 	  /* Make room for this entry.  */
+-	  s->size += PLT_ENTRY_SIZE;
++	  s->size += elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  /* We also need to make an entry in the .got.plt section, which
+ 	     will be placed in the .got section by the linker script.  */
+diff --git a/ld/testsuite/ld-or1k/gotha1.dd b/ld/testsuite/ld-or1k/gotha1.dd
+new file mode 100644
+index 00000000000..0ad1f8f5399
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.dd
+@@ -0,0 +1,34 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.plt:
++
++[0-9a-f]+ <\.plt>:
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 ec [0-9a-f]+ [0-9a-f]+ 	l\.lwz r15,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 78 00 	l\.jr r15
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 60 00 	l\.jr r12
++ +[0-9a-f]+:	a9 60 00 00 	l\.ori r11,r0,0x0
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <_start>:
++ +[0-9a-f]+:	9c 21 ff fc 	l\.addi r1,r1,-4
++ +[0-9a-f]+:	d4 01 48 00 	l\.sw 0\(r1\),r9
++ +[0-9a-f]+:	04 00 00 02 	l\.jal [0-9a-f]+ <_start\+0x10>
++ +[0-9a-f]+:	1a 60 00 00 	l\.movhi r19,0x0
++ +[0-9a-f]+:	aa 73 [0-9a-f]+ [0-9a-f]+ 	l\.ori r19,r19,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 73 48 00 	l\.add r19,r19,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 98 00 	l\.add r17,r17,r19
++ +[0-9a-f]+:	86 31 00 10 	l\.lwz r17,16\(r17\)
++ +[0-9a-f]+:	84 71 00 00 	l\.lwz r3,0\(r17\)
++ +[0-9a-f]+:	07 ff ff f2 	l\.jal [0-9a-f]+ <\.plt\+0x10>
++ +[0-9a-f]+:	15 00 00 00 	l\.nop 0x0
++ +[0-9a-f]+:	85 21 00 00 	l\.lwz r9,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 04 	l\.addi r1,r1,4
+diff --git a/ld/testsuite/ld-or1k/gotha1.s b/ld/testsuite/ld-or1k/gotha1.s
+new file mode 100644
+index 00000000000..42b16db425c
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.s
+@@ -0,0 +1,24 @@
++	.data
++	.p2align 16
++
++	.text
++	.globl	_start
++_start:
++	l.addi	r1, r1, -4
++	l.sw	0(r1), r9
++
++	l.jal	8
++	 l.movhi	r19, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r19, r19, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r19, r19, r9
++
++	l.movhi	r17, gotha(x)
++	l.add	r17, r17, r19
++	l.lwz	r17, got(x)(r17)
++	l.lwz	r3, 0(r17)
++
++	l.jal	plt(func)
++	 l.nop
++	l.lwz	r9, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 4
+diff --git a/ld/testsuite/ld-or1k/gotha2.dd b/ld/testsuite/ld-or1k/gotha2.dd
+new file mode 100644
+index 00000000000..fe09da5466b
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.dd
+@@ -0,0 +1,21 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <test>:
++ +[0-9a-f]+:	9c 21 ff f8 	l\.addi r1,r1,-8
++ +[0-9a-f]+:	d4 01 80 00 	l\.sw 0\(r1\),r16
++ +[0-9a-f]+:	d4 01 48 04 	l\.sw 4\(r1\),r9
++ +[0-9a-f]+:	04 00 [0-9a-f]+ [0-9a-f]+ 	l\.jal [0-9a-f]+ <test\+0x14>
++ +[0-9a-f]+:	1a 00 00 00 	l\.movhi r16,0x0
++ +[0-9a-f]+:	aa 10 [0-9a-f]+ [0-9a-f]+ 	l\.ori r16,r16,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 10 48 00 	l\.add r16,r16,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 80 00 	l\.add r17,r17,r16
++ +[0-9a-f]+:	86 31 00 0c 	l\.lwz r17,12\(r17\)
++ +[0-9a-f]+:	85 21 00 04 	l\.lwz r9,4\(r1\)
++ +[0-9a-f]+:	86 01 00 00 	l\.lwz r16,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 08 	l\.addi r1,r1,8
+diff --git a/ld/testsuite/ld-or1k/gotha2.s b/ld/testsuite/ld-or1k/gotha2.s
+new file mode 100644
+index 00000000000..164b282f2dd
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.s
+@@ -0,0 +1,22 @@
++	.section	.text
++	.align 4
++	.global	test
++	.type	test, @function
++test:
++	l.addi	r1, r1, -8
++	l.sw	0(r1), r16
++	l.sw	4(r1), r9
++
++	l.jal	8
++	 l.movhi	r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r16, r16, r9
++
++	l.movhi	r17, gotha(i)
++	l.add	r17, r17, r16
++	l.lwz	r17, got(i)(r17)
++
++	l.lwz	r9, 4(r1)
++	l.lwz	r16, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 8
+diff --git a/ld/testsuite/ld-or1k/or1k.exp b/ld/testsuite/ld-or1k/or1k.exp
+index 7592e8307c1..8e19ec6c31a 100644
+--- a/ld/testsuite/ld-or1k/or1k.exp
++++ b/ld/testsuite/ld-or1k/or1k.exp
+@@ -53,6 +53,14 @@ set or1kplttests {
+      "" {plt1.s}
+      {{objdump -dr plt1.x.dd}}
+      "plt1.x"}
++    {"gotha exec plt" "tmpdir/libpltlib.so" ""
++     "" {gotha1.s}
++     {{objdump -dr gotha1.dd}}
++     "gotha1.x"}
++    {"gotha -fpic -shared" "-fpic -shared" ""
++     "" {gotha2.s}
++     {{objdump -dr gotha2.dd}}
++     "gotha2.x"}
+ }
+ 
+ # Not implemented yet
+diff --git a/ld/testsuite/ld-or1k/pltlib.s b/ld/testsuite/ld-or1k/pltlib.s
+index baf76ca1af7..8b4d7ba48fd 100644
+--- a/ld/testsuite/ld-or1k/pltlib.s
++++ b/ld/testsuite/ld-or1k/pltlib.s
+@@ -1,5 +1,6 @@
+ 	.section .data
+ 	.globl x, y
++	.size x, 4
+ x:	.long 33
+ y:	.long 44
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch b/package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
new file mode 100644
index 0000000000..5c9e8c0617
--- /dev/null
+++ b/package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
@@ -0,0 +1,256 @@
+From c67656e248d6dadaa2729975a17c8dd03afe48d0 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:15 +0900
+Subject: [PATCH 4/6] or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
+
+The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
+using the -mcmodel=large option.  This relocation is used along with
+got() to generate 32-bit GOT offsets.  This increases the previous GOT
+offset limit from the previous 16-bit (64K) limit.
+
+This is needed on large binaries where the GOT grows larger than 64k.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
+	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
+	(or1k_final_link_relocate, or1k_elf_relocate_section,
+	or1k_elf_check_relocs): Likewise.
+	* libbfd.h (bfd_reloc_code_real_names): Likewise.
+	* reloc.c: Likewise.
+
+cpu/ChangeLog:
+
+	PR 21464
+	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
+	for gotha() relocation.
+
+include/ChangeLog:
+
+	PR 21464
+	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.
+
+opcodes/ChangeLog:
+
+	PR 21464
+	* or1k-asm.c: Regenerate.
+
+gas/ChangeLog:
+
+	PR 21464
+	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
+	* testsuite/gas/or1k/reloc-1.d: Add test result for new
+	relocation.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+
+fixup reloc, add tests
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/bfd-in2.h                    |  1 +
+ bfd/elf32-or1k.c                 | 21 ++++++++++++++++++++-
+ bfd/libbfd.h                     |  1 +
+ bfd/reloc.c                      |  2 ++
+ cpu/or1k.opc                     |  7 ++++++-
+ gas/testsuite/gas/or1k/reloc-1.d |  4 +++-
+ gas/testsuite/gas/or1k/reloc-1.s |  4 ++++
+ include/elf/or1k.h               |  1 +
+ opcodes/or1k-asm.c               |  7 ++++++-
+ 9 files changed, 44 insertions(+), 4 deletions(-)
+
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index df6f9f45673..ab861395e93 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -5041,6 +5041,7 @@ then it may be truncated to 8 bits.  */
+   BFD_RELOC_OR1K_TLS_TPOFF,
+   BFD_RELOC_OR1K_TLS_DTPOFF,
+   BFD_RELOC_OR1K_TLS_DTPMOD,
++  BFD_RELOC_OR1K_GOT_AHI16,
+ 
+ /* H8 elf Relocations.  */
+   BFD_RELOC_H8_DIR16A8,
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index bbfa2bfe614..8e395827123 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -808,6 +808,20 @@ static reloc_howto_type or1k_elf_howto_table[] =
+ 	 0,			/* Source Mask.  */
+ 	 0x03ffffff,		/* Dest Mask.  */
+ 	 TRUE),			/* PC relative offset?  */
++
++  HOWTO (R_OR1K_GOT_AHI16,     /* type */
++	16,                    /* rightshift */
++	2,                     /* size (0 = byte, 1 = short, 2 = long) */
++	16,                    /* bitsize */
++	FALSE,                 /* pc_relative */
++	0,                     /* bitpos */
++	complain_overflow_signed, /* complain_on_overflow */
++	bfd_elf_generic_reloc, /* special_function */
++	"R_OR1K_GOT_AHI16",    /* name */
++	FALSE,                 /* partial_inplace */
++	0,                     /* src_mask */
++	0xffff,                /* dst_mask */
++	FALSE),                /* pcrel_offset */
+ };
+ 
+ /* Map BFD reloc types to Or1k ELF reloc types.  */
+@@ -871,6 +885,7 @@ static const struct or1k_reloc_map or1k_reloc_map[] =
+   { BFD_RELOC_OR1K_TLS_IE_LO13,	R_OR1K_TLS_IE_LO13 },
+   { BFD_RELOC_OR1K_SLO13,	R_OR1K_SLO13 },
+   { BFD_RELOC_OR1K_PLTA26,	R_OR1K_PLTA26 },
++  { BFD_RELOC_OR1K_GOT_AHI16,	R_OR1K_GOT_AHI16 },
+ };
+ 
+ /* tls_type is a mask used to track how each symbol is accessed,
+@@ -1113,6 +1128,7 @@ or1k_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd,
+   switch (howto->type)
+     {
+     case R_OR1K_AHI16:
++    case R_OR1K_GOT_AHI16:
+     case R_OR1K_GOTOFF_AHI16:
+     case R_OR1K_TLS_IE_AHI16:
+     case R_OR1K_TLS_LE_AHI16:
+@@ -1375,6 +1391,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+@@ -1466,7 +1483,8 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    /* The GOT_PG21 and GOT_LO13 relocs are pc-relative,
+ 	       while the GOT16 reloc is GOT relative.  */
+ 	    relocation = got_base + off;
+-	    if (r_type == R_OR1K_GOT16)
++	    if (r_type == R_OR1K_GOT16
++		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
+ 	  /* Addend should be zero.  */
+@@ -1992,6 +2010,7 @@ or1k_elf_check_relocs (bfd *abfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+diff --git a/bfd/libbfd.h b/bfd/libbfd.h
+index b97534fc9fe..795c9b9d27f 100644
+--- a/bfd/libbfd.h
++++ b/bfd/libbfd.h
+@@ -2755,6 +2755,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+   "BFD_RELOC_OR1K_TLS_TPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPMOD",
++  "BFD_RELOC_OR1K_GOT_AHI16",
+   "BFD_RELOC_H8_DIR16A8",
+   "BFD_RELOC_H8_DIR16R8",
+   "BFD_RELOC_H8_DIR24A8",
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index 9aba84ca81e..1e021febef2 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -6175,6 +6175,8 @@ ENUMX
+   BFD_RELOC_OR1K_GOTPC_HI16
+ ENUMX
+   BFD_RELOC_OR1K_GOTPC_LO16
++ENUMX
++  BFD_RELOC_OR1K_GOT_AHI16
+ ENUMX
+   BFD_RELOC_OR1K_GOT16
+ ENUMX
+diff --git a/cpu/or1k.opc b/cpu/or1k.opc
+index f0adcbb00a5..5d20a1f33a7 100644
+--- a/cpu/or1k.opc
++++ b/cpu/or1k.opc
+@@ -193,7 +193,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -296,6 +296,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+diff --git a/gas/testsuite/gas/or1k/reloc-1.d b/gas/testsuite/gas/or1k/reloc-1.d
+index d1bcf5608bb..3a001c4ed99 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.d
++++ b/gas/testsuite/gas/or1k/reloc-1.d
+@@ -68,5 +68,7 @@ OFFSET   TYPE              VALUE
+ 000000ec R_OR1K_LO13       x
+ 000000f0 R_OR1K_GOT_LO13   x
+ 000000f4 R_OR1K_SLO13      x
+-
++000000f8 R_OR1K_GOT_AHI16  x
++000000fc R_OR1K_GOT_AHI16  x
++00000100 R_OR1K_GOT_AHI16  x
+ 
+diff --git a/gas/testsuite/gas/or1k/reloc-1.s b/gas/testsuite/gas/or1k/reloc-1.s
+index e76abef6532..562609aa869 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.s
++++ b/gas/testsuite/gas/or1k/reloc-1.s
+@@ -74,3 +74,7 @@
+ 	l.lbz	r5,po(x)(r3)
+ 	l.lbz	r5,gotpo(x)(r3)
+ 	l.sb	po(x)(r3),r6
++
++	l.movhi	r4,gotha(x)
++	l.ori	r3,r4,gotha(x)
++	l.addi	r3,r4,gotha(x)
+diff --git a/include/elf/or1k.h b/include/elf/or1k.h
+index a215ef5c17e..dff37d875f2 100644
+--- a/include/elf/or1k.h
++++ b/include/elf/or1k.h
+@@ -77,6 +77,7 @@ START_RELOC_NUMBERS (elf_or1k_reloc_type)
+   RELOC_NUMBER (R_OR1K_TLS_IE_LO13,   51)
+   RELOC_NUMBER (R_OR1K_SLO13,         52)
+   RELOC_NUMBER (R_OR1K_PLTA26,        53)
++  RELOC_NUMBER (R_OR1K_GOT_AHI16,     54)
+ END_RELOC_NUMBERS (R_OR1K_max)
+ 
+ #define EF_OR1K_NODELAY (1UL << 0)
+diff --git a/opcodes/or1k-asm.c b/opcodes/or1k-asm.c
+index 5f3c6c74b12..e0c49b3b8cd 100644
+--- a/opcodes/or1k-asm.c
++++ b/opcodes/or1k-asm.c
+@@ -177,7 +177,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -280,6 +280,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch b/package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
new file mode 100644
index 0000000000..71baf4c69b
--- /dev/null
+++ b/package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
@@ -0,0 +1,61 @@
+From 097b83a1c9c694a14e6081cee034bf24f16875c1 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:16 +0900
+Subject: [PATCH 5/6] or1k: Avoid R_OR1K_GOT16 overflow failures in presence of
+ R_OR1K_GOT_AHI16
+
+Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
+overflow validation check if the section has R_OR1K_GOT_AHI16.
+
+We cannot simple disable R_OR1K_GOT16 overflow validation as there will
+still be binaries that will have only R_OR1K_GOT16.  The
+R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
+the option -mcmodel=large.
+
+This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
+is the code pattern that will be emitted by GCC.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
+	overflow check if we have R_OR1K_GOT_AHI16 followed by
+	R_OR1K_GOT16.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 8e395827123..9f315bfda99 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -1280,6 +1280,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+   asection *sgot, *splt;
+   bfd_vma plt_base, got_base, got_sym_value;
+   bfd_boolean ret_val = TRUE;
++  bfd_boolean saw_gotha = FALSE;
+ 
+   if (htab == NULL)
+     return FALSE;
+@@ -1487,6 +1488,16 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
++	    if (r_type == R_OR1K_GOT_AHI16)
++	      saw_gotha = TRUE;
++
++	    /* If we have a R_OR1K_GOT16 followed by a R_OR1K_GOT_AHI16
++	       relocation we assume the code is doing the right thing to avoid
++	       overflows.  Here we mask the lower 16-bit of the relocation to
++	       avoid overflow validation failures.  */
++	    if (r_type == R_OR1K_GOT16 && saw_gotha)
++	      relocation &= 0xffff;
++
+ 	  /* Addend should be zero.  */
+ 	  if (rel->r_addend != 0)
+ 	    {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch b/package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
new file mode 100644
index 0000000000..6f5cf3ad4a
--- /dev/null
+++ b/package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
@@ -0,0 +1,500 @@
+From c87692eb894b4b86eced7b7ba205f9bf27c2c213 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:17 +0900
+Subject: [PATCH 6/6] or1k: Support large plt_relocs when generating plt
+ entries
+
+The current PLT generation code will generate invalid code when the PLT
+relocation offset exceeds 64k.  This fixes the issue by detecting large
+plt_reloc offsets and generare code sequences to create larger plt
+relocations.
+
+The "large" plt code needs 2 extra instructions to create 32-bit offsets.
+
+bfd/ChangeLog:
+
+	PR 27746
+	* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
+	OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
+	(elf_or1k_link_hash_table): New field plt_count.
+	(elf_or1k_link_hash_entry): New field plt_index.
+	(elf_or1k_plt_entry_size): New function.
+	(or1k_write_plt_entry): Update to support variable size PLTs.
+	(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
+	API.
+	(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
+	when needed.
+	(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
+	PLT size.
+
+ld/ChangeLog:
+
+	PR 27746
+	testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
+	along with gotha() relocations.
+	testsuite/ld-or1k/gotha1.dd: New file.
+	testsuite/ld-or1k/gotha1.s: New file.
+	testsuite/ld-or1k/gotha2.dd: New file.
+	testsuite/ld-or1k/gotha2.s: New file
+	testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
+	failure.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c               | 149 ++++++++++++++++++++++++---------
+ ld/testsuite/ld-or1k/gotha1.dd |  34 ++++++++
+ ld/testsuite/ld-or1k/gotha1.s  |  24 ++++++
+ ld/testsuite/ld-or1k/gotha2.dd |  21 +++++
+ ld/testsuite/ld-or1k/gotha2.s  |  22 +++++
+ ld/testsuite/ld-or1k/or1k.exp  |   8 ++
+ ld/testsuite/ld-or1k/pltlib.s  |   1 +
+ 7 files changed, 220 insertions(+), 39 deletions(-)
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.s
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.s
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 9f315bfda99..7a14eaa3a46 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -30,10 +30,14 @@
+ #define N_ONES(X)	(((bfd_vma)2 << (X)) - 1)
+ 
+ #define PLT_ENTRY_SIZE 16
++#define PLT_ENTRY_SIZE_LARGE (6*4)
++#define PLT_MAX_INSN_COUNT 6
+ 
+ #define OR1K_MOVHI(D)		(0x18000000 | (D << 21))
+ #define OR1K_ADRP(D)		(0x08000000 | (D << 21))
+ #define OR1K_LWZ(D,A)		(0x84000000 | (D << 21) | (A << 16))
++#define OR1K_ADD(D,A,B)		(0xE0000000 | (D << 21) | (A << 16) | (B << 11))
++#define OR1K_ORI(D,A)		(0xA8000000 | (D << 21) | (A << 16))
+ #define OR1K_ORI0(D)		(0xA8000000 | (D << 21))
+ #define OR1K_JR(B)		(0x44000000 | (B << 11))
+ #define OR1K_NOP		0x15000000
+@@ -907,6 +911,8 @@ struct elf_or1k_link_hash_entry
+ {
+   struct elf_link_hash_entry root;
+ 
++  /* For calculating PLT size.  */
++  bfd_vma plt_index;
+   /* Track type of TLS access.  */
+   unsigned char tls_type;
+ };
+@@ -934,9 +940,20 @@ struct elf_or1k_link_hash_table
+   /* Small local sym to section mapping cache.  */
+   struct sym_cache sym_sec;
+ 
++  bfd_vma plt_count;
+   bfd_boolean saw_plta;
+ };
+ 
++static size_t
++elf_or1k_plt_entry_size (bfd_vma plt_index)
++{
++  bfd_vma plt_reloc;
++
++  plt_reloc = plt_index * sizeof (Elf32_External_Rela);
++
++  return (plt_reloc > 0xffff) ? PLT_ENTRY_SIZE_LARGE : PLT_ENTRY_SIZE;
++}
++
+ /* Get the ELF linker hash table from a link_info structure.  */
+ #define or1k_elf_hash_table(p) \
+   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+@@ -2224,33 +2241,46 @@ or1k_elf_check_relocs (bfd *abfd,
+ }
+ 
+ static void
+-or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insn1,
+-		      unsigned insn2, unsigned insn3, unsigned insnj)
++or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
++		      unsigned insns[], size_t insn_count)
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+-  unsigned insn4;
++  unsigned output_insns[PLT_MAX_INSN_COUNT];
++
++  /* Copy instructions into the output buffer.  */
++  for (size_t i = 0; i < insn_count; i++)
++    output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+-  if (insn3 == OR1K_NOP)
++  if (insns[insn_count-1] == OR1K_NOP)
+     {
+-      insn4 = insn3;
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn3 = insnj;
++	slot1 = insns[insn_count-2], slot2 = insnj;
+       else
+-	insn3 = insn2, insn2 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-2];
++
++      output_insns[insn_count-2] = slot1;
++      output_insns[insn_count-1] = slot2;
++      output_insns[insn_count]   = OR1K_NOP;
+     }
+   else
+     {
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn4 = insnj;
++	slot1 = insns[insn_count-1], slot2 = insnj;
+       else
+-	insn4 = insn3, insn3 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-1];
++
++      output_insns[insn_count-1] = slot1;
++      output_insns[insn_count]   = slot2;
+     }
+ 
+-  bfd_put_32 (output_bfd, insn1, contents);
+-  bfd_put_32 (output_bfd, insn2, contents + 4);
+-  bfd_put_32 (output_bfd, insn3, contents + 8);
+-  bfd_put_32 (output_bfd, insn4, contents + 12);
++  /* Write out the output buffer.  */
++  for (size_t i = 0; i < (insn_count+1); i++)
++    bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+ /* Finish up the dynamic sections.  */
+@@ -2317,7 +2347,8 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+       splt = htab->root.splt;
+       if (splt && splt->size > 0)
+ 	{
+-	  unsigned plt0, plt1, plt2;
++	  unsigned plt[PLT_MAX_INSN_COUNT];
++	  size_t plt_insn_count = 3;
+ 	  bfd_vma got_addr = sgot->output_section->vma + sgot->output_offset;
+ 
+ 	  /* Note we force 16 byte alignment on the .got, so that
+@@ -2328,27 +2359,27 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+ 	      bfd_vma pc = splt->output_section->vma + splt->output_offset;
+ 	      unsigned pa = ((got_addr >> 13) - (pc >> 13)) & 0x1fffff;
+ 	      unsigned po = got_addr & 0x1fff;
+-	      plt0 = OR1K_ADRP(12) | pa;
+-	      plt1 = OR1K_LWZ(15,12) | (po + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (po + 4);
++	      plt[0] = OR1K_ADRP(12) | pa;
++	      plt[1] = OR1K_LWZ(15,12) | (po + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (po + 4);
+ 	    }
+ 	  else if (bfd_link_pic (info))
+ 	    {
+-	      plt0 = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
+-	      plt1 = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
+-	      plt2 = OR1K_NOP;
++	      plt[0] = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
++	      plt[1] = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
++	      plt[2] = OR1K_NOP;
+ 	    }
+ 	  else
+ 	    {
+ 	      unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	      unsigned lo = got_addr & 0xffff;
+-	      plt0 = OR1K_MOVHI(12) | ha;
+-	      plt1 = OR1K_LWZ(15,12) | (lo + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (lo + 4);
++	      plt[0] = OR1K_MOVHI(12) | ha;
++	      plt[1] = OR1K_LWZ(15,12) | (lo + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (lo + 4);
+ 	    }
+ 
+-	  or1k_write_plt_entry (output_bfd, splt->contents,
+-				plt0, plt1, plt2, OR1K_JR(15));
++	  or1k_write_plt_entry (output_bfd, splt->contents, OR1K_JR(15),
++				plt, plt_insn_count);
+ 
+ 	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ 	}
+@@ -2391,7 +2422,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 
+   if (h->plt.offset != (bfd_vma) -1)
+     {
+-      unsigned int plt0, plt1, plt2;
++      unsigned int plt[PLT_MAX_INSN_COUNT];
++      size_t plt_insn_count = 3;
+       asection *splt;
+       asection *sgot;
+       asection *srela;
+@@ -2403,6 +2435,7 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+       bfd_vma got_offset;
+       bfd_vma got_addr;
+       Elf_Internal_Rela rela;
++      bfd_boolean large_plt_entry;
+ 
+       /* This symbol has an entry in the procedure linkage table.  Set
+ 	 it up.  */
+@@ -2420,10 +2453,13 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	 corresponds to this symbol.  This is the index of this symbol
+ 	 in all the symbols for which we are making plt entries.  The
+ 	 first entry in the procedure linkage table is reserved.  */
+-      plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
++      plt_index = ((struct elf_or1k_link_hash_entry *) h)->plt_index;
+       plt_addr = plt_base_addr + h->plt.offset;
+       plt_reloc = plt_index * sizeof (Elf32_External_Rela);
+ 
++      large_plt_entry = (elf_or1k_plt_entry_size (plt_index)
++			 == PLT_ENTRY_SIZE_LARGE);
++
+       /* Get the offset into the .got table of the entry that
+ 	corresponds to this function.  Each .got entry is 4 bytes.
+ 	The first three are reserved.  */
+@@ -2435,27 +2471,57 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	{
+ 	  unsigned pa = ((got_addr >> 13) - (plt_addr >> 13)) & 0x1fffff;
+ 	  unsigned po = (got_addr & 0x1fff);
+-	  plt0 = OR1K_ADRP(12) | pa;
+-	  plt1 = OR1K_LWZ(12,12) | po;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_ADRP(12) | pa;
++	  plt[1] = OR1K_LWZ(12,12) | po;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
+ 	}
+       else if (bfd_link_pic (info))
+ 	{
+-	  plt0 = OR1K_LWZ(12,16) | got_offset;
+-	  plt1 = OR1K_ORI0(11) | plt_reloc;
+-	  plt2 = OR1K_NOP;
++	  if (large_plt_entry)
++	    {
++	      unsigned gotha = ((got_offset + 0x8000) >> 16) & 0xffff;
++	      unsigned got = got_offset & 0xffff;
++	      unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	      unsigned pltrello = plt_reloc & 0xffff;
++
++	      plt[0] = OR1K_MOVHI(12) | gotha;
++	      plt[1] = OR1K_ADD(12,12,16);
++	      plt[2] = OR1K_LWZ(12,12) | got;
++	      plt[3] = OR1K_MOVHI(11) | pltrelhi;
++	      plt[4] = OR1K_ORI(11,11) | pltrello;
++	      plt_insn_count = 5;
++	    }
++	  else
++	    {
++	      plt[0] = OR1K_LWZ(12,16) | got_offset;
++	      plt[1] = OR1K_ORI0(11) | plt_reloc;
++	      plt[2] = OR1K_NOP;
++	    }
+ 	}
+       else
+ 	{
+ 	  unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	  unsigned lo = got_addr & 0xffff;
+-	  plt0 = OR1K_MOVHI(12) | ha;
+-	  plt1 = OR1K_LWZ(12,12) | lo;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_MOVHI(12) | ha;
++	  plt[1] = OR1K_LWZ(12,12) | lo;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
++	}
++
++      /* For large code model we fixup the non-PIC PLT relocation instructions
++	 here.  */
++      if (large_plt_entry && !bfd_link_pic (info))
++	{
++	  unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	  unsigned pltrello = plt_reloc & 0xffff;
++
++	  plt[2] = OR1K_MOVHI(11) | pltrelhi;
++	  plt[3] = OR1K_ORI(11,11) | pltrello;
++	  plt[4] = OR1K_NOP;
++	  plt_insn_count = 5;
+ 	}
+ 
+       or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset,
+-			    plt0, plt1, plt2, OR1K_JR(12));
++			    OR1K_JR(12), plt, plt_insn_count);
+ 
+       /* Fill in the entry in the global offset table.  We initialize it to
+ 	 point to the top of the plt.  This is done to lazy lookup the actual
+@@ -2779,11 +2845,16 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
+ 	{
+ 	  asection *splt = htab->root.splt;
++	  bfd_vma plt_index;
++
++	  /* Track the index of our plt entry for use in calculating size.  */
++	  plt_index = htab->plt_count++;
++	  ((struct elf_or1k_link_hash_entry *) h)->plt_index = plt_index;
+ 
+ 	  /* If this is the first .plt entry, make room for the special
+ 	     first entry.  */
+ 	  if (splt->size == 0)
+-	    splt->size = PLT_ENTRY_SIZE;
++	    splt->size = elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  h->plt.offset = splt->size;
+ 
+@@ -2800,7 +2871,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+ 	    }
+ 
+ 	  /* Make room for this entry.  */
+-	  splt->size += PLT_ENTRY_SIZE;
++	  splt->size += elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  /* We also need to make an entry in the .got.plt section, which
+ 	     will be placed in the .got section by the linker script.  */
+diff --git a/ld/testsuite/ld-or1k/gotha1.dd b/ld/testsuite/ld-or1k/gotha1.dd
+new file mode 100644
+index 00000000000..0ad1f8f5399
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.dd
+@@ -0,0 +1,34 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.plt:
++
++[0-9a-f]+ <\.plt>:
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 ec [0-9a-f]+ [0-9a-f]+ 	l\.lwz r15,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 78 00 	l\.jr r15
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 60 00 	l\.jr r12
++ +[0-9a-f]+:	a9 60 00 00 	l\.ori r11,r0,0x0
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <_start>:
++ +[0-9a-f]+:	9c 21 ff fc 	l\.addi r1,r1,-4
++ +[0-9a-f]+:	d4 01 48 00 	l\.sw 0\(r1\),r9
++ +[0-9a-f]+:	04 00 00 02 	l\.jal [0-9a-f]+ <_start\+0x10>
++ +[0-9a-f]+:	1a 60 00 00 	l\.movhi r19,0x0
++ +[0-9a-f]+:	aa 73 [0-9a-f]+ [0-9a-f]+ 	l\.ori r19,r19,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 73 48 00 	l\.add r19,r19,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 98 00 	l\.add r17,r17,r19
++ +[0-9a-f]+:	86 31 00 10 	l\.lwz r17,16\(r17\)
++ +[0-9a-f]+:	84 71 00 00 	l\.lwz r3,0\(r17\)
++ +[0-9a-f]+:	07 ff ff f2 	l\.jal [0-9a-f]+ <\.plt\+0x10>
++ +[0-9a-f]+:	15 00 00 00 	l\.nop 0x0
++ +[0-9a-f]+:	85 21 00 00 	l\.lwz r9,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 04 	l\.addi r1,r1,4
+diff --git a/ld/testsuite/ld-or1k/gotha1.s b/ld/testsuite/ld-or1k/gotha1.s
+new file mode 100644
+index 00000000000..42b16db425c
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.s
+@@ -0,0 +1,24 @@
++	.data
++	.p2align 16
++
++	.text
++	.globl	_start
++_start:
++	l.addi	r1, r1, -4
++	l.sw	0(r1), r9
++
++	l.jal	8
++	 l.movhi	r19, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r19, r19, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r19, r19, r9
++
++	l.movhi	r17, gotha(x)
++	l.add	r17, r17, r19
++	l.lwz	r17, got(x)(r17)
++	l.lwz	r3, 0(r17)
++
++	l.jal	plt(func)
++	 l.nop
++	l.lwz	r9, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 4
+diff --git a/ld/testsuite/ld-or1k/gotha2.dd b/ld/testsuite/ld-or1k/gotha2.dd
+new file mode 100644
+index 00000000000..fe09da5466b
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.dd
+@@ -0,0 +1,21 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <test>:
++ +[0-9a-f]+:	9c 21 ff f8 	l\.addi r1,r1,-8
++ +[0-9a-f]+:	d4 01 80 00 	l\.sw 0\(r1\),r16
++ +[0-9a-f]+:	d4 01 48 04 	l\.sw 4\(r1\),r9
++ +[0-9a-f]+:	04 00 [0-9a-f]+ [0-9a-f]+ 	l\.jal [0-9a-f]+ <test\+0x14>
++ +[0-9a-f]+:	1a 00 00 00 	l\.movhi r16,0x0
++ +[0-9a-f]+:	aa 10 [0-9a-f]+ [0-9a-f]+ 	l\.ori r16,r16,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 10 48 00 	l\.add r16,r16,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 80 00 	l\.add r17,r17,r16
++ +[0-9a-f]+:	86 31 00 0c 	l\.lwz r17,12\(r17\)
++ +[0-9a-f]+:	85 21 00 04 	l\.lwz r9,4\(r1\)
++ +[0-9a-f]+:	86 01 00 00 	l\.lwz r16,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 08 	l\.addi r1,r1,8
+diff --git a/ld/testsuite/ld-or1k/gotha2.s b/ld/testsuite/ld-or1k/gotha2.s
+new file mode 100644
+index 00000000000..164b282f2dd
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.s
+@@ -0,0 +1,22 @@
++	.section	.text
++	.align 4
++	.global	test
++	.type	test, @function
++test:
++	l.addi	r1, r1, -8
++	l.sw	0(r1), r16
++	l.sw	4(r1), r9
++
++	l.jal	8
++	 l.movhi	r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r16, r16, r9
++
++	l.movhi	r17, gotha(i)
++	l.add	r17, r17, r16
++	l.lwz	r17, got(i)(r17)
++
++	l.lwz	r9, 4(r1)
++	l.lwz	r16, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 8
+diff --git a/ld/testsuite/ld-or1k/or1k.exp b/ld/testsuite/ld-or1k/or1k.exp
+index 7592e8307c1..8e19ec6c31a 100644
+--- a/ld/testsuite/ld-or1k/or1k.exp
++++ b/ld/testsuite/ld-or1k/or1k.exp
+@@ -53,6 +53,14 @@ set or1kplttests {
+      "" {plt1.s}
+      {{objdump -dr plt1.x.dd}}
+      "plt1.x"}
++    {"gotha exec plt" "tmpdir/libpltlib.so" ""
++     "" {gotha1.s}
++     {{objdump -dr gotha1.dd}}
++     "gotha1.x"}
++    {"gotha -fpic -shared" "-fpic -shared" ""
++     "" {gotha2.s}
++     {{objdump -dr gotha2.dd}}
++     "gotha2.x"}
+ }
+ 
+ # Not implemented yet
+diff --git a/ld/testsuite/ld-or1k/pltlib.s b/ld/testsuite/ld-or1k/pltlib.s
+index baf76ca1af7..8b4d7ba48fd 100644
+--- a/ld/testsuite/ld-or1k/pltlib.s
++++ b/ld/testsuite/ld-or1k/pltlib.s
+@@ -1,5 +1,6 @@
+ 	.section .data
+ 	.globl x, y
++	.size x, 4
+ x:	.long 33
+ y:	.long 44
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch b/package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
new file mode 100644
index 0000000000..326e7d7b68
--- /dev/null
+++ b/package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
@@ -0,0 +1,256 @@
+From 141dee7402871c7b3994838c3eddf64a92d67be7 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:15 +0900
+Subject: [PATCH 4/6] or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
+
+The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
+using the -mcmodel=large option.  This relocation is used along with
+got() to generate 32-bit GOT offsets.  This increases the previous GOT
+offset limit from the previous 16-bit (64K) limit.
+
+This is needed on large binaries where the GOT grows larger than 64k.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
+	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
+	(or1k_final_link_relocate, or1k_elf_relocate_section,
+	or1k_elf_check_relocs): Likewise.
+	* libbfd.h (bfd_reloc_code_real_names): Likewise.
+	* reloc.c: Likewise.
+
+cpu/ChangeLog:
+
+	PR 21464
+	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
+	for gotha() relocation.
+
+include/ChangeLog:
+
+	PR 21464
+	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.
+
+opcodes/ChangeLog:
+
+	PR 21464
+	* or1k-asm.c: Regenerate.
+
+gas/ChangeLog:
+
+	PR 21464
+	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
+	* testsuite/gas/or1k/reloc-1.d: Add test result for new
+	relocation.
+
+Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
+
+fixup reloc, add tests
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/bfd-in2.h                    |  1 +
+ bfd/elf32-or1k.c                 | 21 ++++++++++++++++++++-
+ bfd/libbfd.h                     |  1 +
+ bfd/reloc.c                      |  2 ++
+ cpu/or1k.opc                     |  7 ++++++-
+ gas/testsuite/gas/or1k/reloc-1.d |  4 +++-
+ gas/testsuite/gas/or1k/reloc-1.s |  4 ++++
+ include/elf/or1k.h               |  1 +
+ opcodes/or1k-asm.c               |  7 ++++++-
+ 9 files changed, 44 insertions(+), 4 deletions(-)
+
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index 7eff85b7eaa..e76b9e7a319 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -5048,6 +5048,7 @@ then it may be truncated to 8 bits.  */
+   BFD_RELOC_OR1K_TLS_TPOFF,
+   BFD_RELOC_OR1K_TLS_DTPOFF,
+   BFD_RELOC_OR1K_TLS_DTPMOD,
++  BFD_RELOC_OR1K_GOT_AHI16,
+ 
+ /* H8 elf Relocations.  */
+   BFD_RELOC_H8_DIR16A8,
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 4f82cc4c667..48461854a96 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -808,6 +808,20 @@ static reloc_howto_type or1k_elf_howto_table[] =
+ 	 0,			/* Source Mask.  */
+ 	 0x03ffffff,		/* Dest Mask.  */
+ 	 TRUE),			/* PC relative offset?  */
++
++  HOWTO (R_OR1K_GOT_AHI16,     /* type */
++	16,                    /* rightshift */
++	2,                     /* size (0 = byte, 1 = short, 2 = long) */
++	16,                    /* bitsize */
++	FALSE,                 /* pc_relative */
++	0,                     /* bitpos */
++	complain_overflow_signed, /* complain_on_overflow */
++	bfd_elf_generic_reloc, /* special_function */
++	"R_OR1K_GOT_AHI16",    /* name */
++	FALSE,                 /* partial_inplace */
++	0,                     /* src_mask */
++	0xffff,                /* dst_mask */
++	FALSE),                /* pcrel_offset */
+ };
+ 
+ /* Map BFD reloc types to Or1k ELF reloc types.  */
+@@ -871,6 +885,7 @@ static const struct or1k_reloc_map or1k_reloc_map[] =
+   { BFD_RELOC_OR1K_TLS_IE_LO13,	R_OR1K_TLS_IE_LO13 },
+   { BFD_RELOC_OR1K_SLO13,	R_OR1K_SLO13 },
+   { BFD_RELOC_OR1K_PLTA26,	R_OR1K_PLTA26 },
++  { BFD_RELOC_OR1K_GOT_AHI16,	R_OR1K_GOT_AHI16 },
+ };
+ 
+ /* tls_type is a mask used to track how each symbol is accessed,
+@@ -1111,6 +1126,7 @@ or1k_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd,
+   switch (howto->type)
+     {
+     case R_OR1K_AHI16:
++    case R_OR1K_GOT_AHI16:
+     case R_OR1K_GOTOFF_AHI16:
+     case R_OR1K_TLS_IE_AHI16:
+     case R_OR1K_TLS_LE_AHI16:
+@@ -1373,6 +1389,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+@@ -1464,7 +1481,8 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 	    /* The GOT_PG21 and GOT_LO13 relocs are pc-relative,
+ 	       while the GOT16 reloc is GOT relative.  */
+ 	    relocation = got_base + off;
+-	    if (r_type == R_OR1K_GOT16)
++	    if (r_type == R_OR1K_GOT16
++		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
+ 	  /* Addend should be zero.  */
+@@ -1990,6 +2008,7 @@ or1k_elf_check_relocs (bfd *abfd,
+ 	    }
+ 	  break;
+ 
++	case R_OR1K_GOT_AHI16:
+ 	case R_OR1K_GOT16:
+ 	case R_OR1K_GOT_PG21:
+ 	case R_OR1K_GOT_LO13:
+diff --git a/bfd/libbfd.h b/bfd/libbfd.h
+index 7271a2ad5a1..e0ee2dafc07 100644
+--- a/bfd/libbfd.h
++++ b/bfd/libbfd.h
+@@ -2757,6 +2757,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
+   "BFD_RELOC_OR1K_TLS_TPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPOFF",
+   "BFD_RELOC_OR1K_TLS_DTPMOD",
++  "BFD_RELOC_OR1K_GOT_AHI16",
+   "BFD_RELOC_H8_DIR16A8",
+   "BFD_RELOC_H8_DIR16R8",
+   "BFD_RELOC_H8_DIR24A8",
+diff --git a/bfd/reloc.c b/bfd/reloc.c
+index 4f4b95a0b7f..fe94e0d8f91 100644
+--- a/bfd/reloc.c
++++ b/bfd/reloc.c
+@@ -6204,6 +6204,8 @@ ENUMX
+   BFD_RELOC_OR1K_GOTPC_HI16
+ ENUMX
+   BFD_RELOC_OR1K_GOTPC_LO16
++ENUMX
++  BFD_RELOC_OR1K_GOT_AHI16
+ ENUMX
+   BFD_RELOC_OR1K_GOT16
+ ENUMX
+diff --git a/cpu/or1k.opc b/cpu/or1k.opc
+index f0adcbb00a5..5d20a1f33a7 100644
+--- a/cpu/or1k.opc
++++ b/cpu/or1k.opc
+@@ -193,7 +193,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -296,6 +296,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+diff --git a/gas/testsuite/gas/or1k/reloc-1.d b/gas/testsuite/gas/or1k/reloc-1.d
+index d1bcf5608bb..3a001c4ed99 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.d
++++ b/gas/testsuite/gas/or1k/reloc-1.d
+@@ -68,5 +68,7 @@ OFFSET   TYPE              VALUE
+ 000000ec R_OR1K_LO13       x
+ 000000f0 R_OR1K_GOT_LO13   x
+ 000000f4 R_OR1K_SLO13      x
+-
++000000f8 R_OR1K_GOT_AHI16  x
++000000fc R_OR1K_GOT_AHI16  x
++00000100 R_OR1K_GOT_AHI16  x
+ 
+diff --git a/gas/testsuite/gas/or1k/reloc-1.s b/gas/testsuite/gas/or1k/reloc-1.s
+index e76abef6532..562609aa869 100644
+--- a/gas/testsuite/gas/or1k/reloc-1.s
++++ b/gas/testsuite/gas/or1k/reloc-1.s
+@@ -74,3 +74,7 @@
+ 	l.lbz	r5,po(x)(r3)
+ 	l.lbz	r5,gotpo(x)(r3)
+ 	l.sb	po(x)(r3),r6
++
++	l.movhi	r4,gotha(x)
++	l.ori	r3,r4,gotha(x)
++	l.addi	r3,r4,gotha(x)
+diff --git a/include/elf/or1k.h b/include/elf/or1k.h
+index 7f281481061..69ab90584a2 100644
+--- a/include/elf/or1k.h
++++ b/include/elf/or1k.h
+@@ -77,6 +77,7 @@ START_RELOC_NUMBERS (elf_or1k_reloc_type)
+   RELOC_NUMBER (R_OR1K_TLS_IE_LO13,   51)
+   RELOC_NUMBER (R_OR1K_SLO13,         52)
+   RELOC_NUMBER (R_OR1K_PLTA26,        53)
++  RELOC_NUMBER (R_OR1K_GOT_AHI16,     54)
+ END_RELOC_NUMBERS (R_OR1K_max)
+ 
+ #define EF_OR1K_NODELAY (1UL << 0)
+diff --git a/opcodes/or1k-asm.c b/opcodes/or1k-asm.c
+index 045ab6230b6..fdccf67f9e1 100644
+--- a/opcodes/or1k-asm.c
++++ b/opcodes/or1k-asm.c
+@@ -177,7 +177,7 @@ static const bfd_reloc_code_real_type or1k_imm16_relocs[][6] = {
+     BFD_RELOC_OR1K_GOT_LO13,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+-    BFD_RELOC_UNUSED },
++    BFD_RELOC_OR1K_GOT_AHI16 },
+   { BFD_RELOC_OR1K_GOTPC_LO16,
+     BFD_RELOC_UNUSED,
+     BFD_RELOC_UNUSED,
+@@ -280,6 +280,11 @@ parse_reloc (const char **strp)
+ 	str += 5;
+ 	cls = RCLASS_TPOFF;
+       }
++    else if (strncasecmp (str, "got", 3) == 0)
++      {
++	str += 3;
++	cls = RCLASS_GOT;
++      }
+ 
+     if (strncasecmp (str, "hi(", 3) == 0)
+       {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch b/package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
new file mode 100644
index 0000000000..e3f1edf1a6
--- /dev/null
+++ b/package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
@@ -0,0 +1,61 @@
+From de914df5f2ba23a9f6f1fbf6efdc22e1b045901c Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:16 +0900
+Subject: [PATCH 5/6] or1k: Avoid R_OR1K_GOT16 overflow failures in presence of
+ R_OR1K_GOT_AHI16
+
+Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
+overflow validation check if the section has R_OR1K_GOT_AHI16.
+
+We cannot simple disable R_OR1K_GOT16 overflow validation as there will
+still be binaries that will have only R_OR1K_GOT16.  The
+R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
+the option -mcmodel=large.
+
+This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
+is the code pattern that will be emitted by GCC.
+
+bfd/ChangeLog:
+
+	PR 21464
+	* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
+	overflow check if we have R_OR1K_GOT_AHI16 followed by
+	R_OR1K_GOT16.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 48461854a96..44e67f2b84b 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -1278,6 +1278,7 @@ or1k_elf_relocate_section (bfd *output_bfd,
+   asection *sgot, *splt;
+   bfd_vma plt_base, got_base, got_sym_value;
+   bfd_boolean ret_val = TRUE;
++  bfd_boolean saw_gotha = FALSE;
+ 
+   if (htab == NULL)
+     return FALSE;
+@@ -1485,6 +1486,16 @@ or1k_elf_relocate_section (bfd *output_bfd,
+ 		|| r_type == R_OR1K_GOT_AHI16)
+ 	      relocation -= got_sym_value;
+ 
++	    if (r_type == R_OR1K_GOT_AHI16)
++	      saw_gotha = TRUE;
++
++	    /* If we have a R_OR1K_GOT16 followed by a R_OR1K_GOT_AHI16
++	       relocation we assume the code is doing the right thing to avoid
++	       overflows.  Here we mask the lower 16-bit of the relocation to
++	       avoid overflow validation failures.  */
++	    if (r_type == R_OR1K_GOT16 && saw_gotha)
++	      relocation &= 0xffff;
++
+ 	  /* Addend should be zero.  */
+ 	  if (rel->r_addend != 0)
+ 	    {
+-- 
+2.25.1
+
diff --git a/package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch b/package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
new file mode 100644
index 0000000000..70c46662ba
--- /dev/null
+++ b/package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
@@ -0,0 +1,500 @@
+From 4a7b357d0c802685bee7706bafb9702c821286e1 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:02:17 +0900
+Subject: [PATCH 6/6] or1k: Support large plt_relocs when generating plt
+ entries
+
+The current PLT generation code will generate invalid code when the PLT
+relocation offset exceeds 64k.  This fixes the issue by detecting large
+plt_reloc offsets and generare code sequences to create larger plt
+relocations.
+
+The "large" plt code needs 2 extra instructions to create 32-bit offsets.
+
+bfd/ChangeLog:
+
+	PR 27746
+	* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
+	OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
+	(elf_or1k_link_hash_table): New field plt_count.
+	(elf_or1k_link_hash_entry): New field plt_index.
+	(elf_or1k_plt_entry_size): New function.
+	(or1k_write_plt_entry): Update to support variable size PLTs.
+	(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
+	API.
+	(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
+	when needed.
+	(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
+	PLT size.
+
+ld/ChangeLog:
+
+	PR 27746
+	testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
+	along with gotha() relocations.
+	testsuite/ld-or1k/gotha1.dd: New file.
+	testsuite/ld-or1k/gotha1.s: New file.
+	testsuite/ld-or1k/gotha2.dd: New file.
+	testsuite/ld-or1k/gotha2.s: New file
+	testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
+	failure.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c               | 149 ++++++++++++++++++++++++---------
+ ld/testsuite/ld-or1k/gotha1.dd |  34 ++++++++
+ ld/testsuite/ld-or1k/gotha1.s  |  24 ++++++
+ ld/testsuite/ld-or1k/gotha2.dd |  21 +++++
+ ld/testsuite/ld-or1k/gotha2.s  |  22 +++++
+ ld/testsuite/ld-or1k/or1k.exp  |   8 ++
+ ld/testsuite/ld-or1k/pltlib.s  |   1 +
+ 7 files changed, 220 insertions(+), 39 deletions(-)
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha1.s
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.dd
+ create mode 100644 ld/testsuite/ld-or1k/gotha2.s
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 44e67f2b84b..3da68e52425 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -30,10 +30,14 @@
+ #define N_ONES(X)	(((bfd_vma)2 << (X)) - 1)
+ 
+ #define PLT_ENTRY_SIZE 16
++#define PLT_ENTRY_SIZE_LARGE (6*4)
++#define PLT_MAX_INSN_COUNT 6
+ 
+ #define OR1K_MOVHI(D)		(0x18000000 | (D << 21))
+ #define OR1K_ADRP(D)		(0x08000000 | (D << 21))
+ #define OR1K_LWZ(D,A)		(0x84000000 | (D << 21) | (A << 16))
++#define OR1K_ADD(D,A,B)		(0xE0000000 | (D << 21) | (A << 16) | (B << 11))
++#define OR1K_ORI(D,A)		(0xA8000000 | (D << 21) | (A << 16))
+ #define OR1K_ORI0(D)		(0xA8000000 | (D << 21))
+ #define OR1K_JR(B)		(0x44000000 | (B << 11))
+ #define OR1K_NOP		0x15000000
+@@ -907,6 +911,8 @@ struct elf_or1k_link_hash_entry
+ {
+   struct elf_link_hash_entry root;
+ 
++  /* For calculating PLT size.  */
++  bfd_vma plt_index;
+   /* Track type of TLS access.  */
+   unsigned char tls_type;
+ };
+@@ -931,9 +937,20 @@ struct elf_or1k_link_hash_table
+ {
+   struct elf_link_hash_table root;
+ 
++  bfd_vma plt_count;
+   bfd_boolean saw_plta;
+ };
+ 
++static size_t
++elf_or1k_plt_entry_size (bfd_vma plt_index)
++{
++  bfd_vma plt_reloc;
++
++  plt_reloc = plt_index * sizeof (Elf32_External_Rela);
++
++  return (plt_reloc > 0xffff) ? PLT_ENTRY_SIZE_LARGE : PLT_ENTRY_SIZE;
++}
++
+ /* Get the ELF linker hash table from a link_info structure.  */
+ #define or1k_elf_hash_table(p) \
+   ((is_elf_hash_table ((p)->hash)					\
+@@ -2222,33 +2239,46 @@ or1k_elf_check_relocs (bfd *abfd,
+ }
+ 
+ static void
+-or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insn1,
+-		      unsigned insn2, unsigned insn3, unsigned insnj)
++or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
++		      unsigned insns[], size_t insn_count)
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+-  unsigned insn4;
++  unsigned output_insns[PLT_MAX_INSN_COUNT];
++
++  /* Copy instructions into the output buffer.  */
++  for (size_t i = 0; i < insn_count; i++)
++    output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+-  if (insn3 == OR1K_NOP)
++  if (insns[insn_count-1] == OR1K_NOP)
+     {
+-      insn4 = insn3;
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn3 = insnj;
++	slot1 = insns[insn_count-2], slot2 = insnj;
+       else
+-	insn3 = insn2, insn2 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-2];
++
++      output_insns[insn_count-2] = slot1;
++      output_insns[insn_count-1] = slot2;
++      output_insns[insn_count]   = OR1K_NOP;
+     }
+   else
+     {
++      unsigned slot1, slot2;
++
+       if (nodelay)
+-	insn4 = insnj;
++	slot1 = insns[insn_count-1], slot2 = insnj;
+       else
+-	insn4 = insn3, insn3 = insnj;
++	slot1 = insnj, slot2 = insns[insn_count-1];
++
++      output_insns[insn_count-1] = slot1;
++      output_insns[insn_count]   = slot2;
+     }
+ 
+-  bfd_put_32 (output_bfd, insn1, contents);
+-  bfd_put_32 (output_bfd, insn2, contents + 4);
+-  bfd_put_32 (output_bfd, insn3, contents + 8);
+-  bfd_put_32 (output_bfd, insn4, contents + 12);
++  /* Write out the output buffer.  */
++  for (size_t i = 0; i < (insn_count+1); i++)
++    bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+ /* Finish up the dynamic sections.  */
+@@ -2315,7 +2345,8 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+       splt = htab->root.splt;
+       if (splt && splt->size > 0)
+ 	{
+-	  unsigned plt0, plt1, plt2;
++	  unsigned plt[PLT_MAX_INSN_COUNT];
++	  size_t plt_insn_count = 3;
+ 	  bfd_vma got_addr = sgot->output_section->vma + sgot->output_offset;
+ 
+ 	  /* Note we force 16 byte alignment on the .got, so that
+@@ -2326,27 +2357,27 @@ or1k_elf_finish_dynamic_sections (bfd *output_bfd,
+ 	      bfd_vma pc = splt->output_section->vma + splt->output_offset;
+ 	      unsigned pa = ((got_addr >> 13) - (pc >> 13)) & 0x1fffff;
+ 	      unsigned po = got_addr & 0x1fff;
+-	      plt0 = OR1K_ADRP(12) | pa;
+-	      plt1 = OR1K_LWZ(15,12) | (po + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (po + 4);
++	      plt[0] = OR1K_ADRP(12) | pa;
++	      plt[1] = OR1K_LWZ(15,12) | (po + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (po + 4);
+ 	    }
+ 	  else if (bfd_link_pic (info))
+ 	    {
+-	      plt0 = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
+-	      plt1 = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
+-	      plt2 = OR1K_NOP;
++	      plt[0] = OR1K_LWZ(15, 16) | 8;	/* .got+8 */
++	      plt[1] = OR1K_LWZ(12, 16) | 4;	/* .got+4 */
++	      plt[2] = OR1K_NOP;
+ 	    }
+ 	  else
+ 	    {
+ 	      unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	      unsigned lo = got_addr & 0xffff;
+-	      plt0 = OR1K_MOVHI(12) | ha;
+-	      plt1 = OR1K_LWZ(15,12) | (lo + 8);
+-	      plt2 = OR1K_LWZ(12,12) | (lo + 4);
++	      plt[0] = OR1K_MOVHI(12) | ha;
++	      plt[1] = OR1K_LWZ(15,12) | (lo + 8);
++	      plt[2] = OR1K_LWZ(12,12) | (lo + 4);
+ 	    }
+ 
+-	  or1k_write_plt_entry (output_bfd, splt->contents,
+-				plt0, plt1, plt2, OR1K_JR(15));
++	  or1k_write_plt_entry (output_bfd, splt->contents, OR1K_JR(15),
++				plt, plt_insn_count);
+ 
+ 	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+ 	}
+@@ -2389,7 +2420,8 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 
+   if (h->plt.offset != (bfd_vma) -1)
+     {
+-      unsigned int plt0, plt1, plt2;
++      unsigned int plt[PLT_MAX_INSN_COUNT];
++      size_t plt_insn_count = 3;
+       asection *splt;
+       asection *sgot;
+       asection *srela;
+@@ -2401,6 +2433,7 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+       bfd_vma got_offset;
+       bfd_vma got_addr;
+       Elf_Internal_Rela rela;
++      bfd_boolean large_plt_entry;
+ 
+       /* This symbol has an entry in the procedure linkage table.  Set
+ 	 it up.  */
+@@ -2418,10 +2451,13 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	 corresponds to this symbol.  This is the index of this symbol
+ 	 in all the symbols for which we are making plt entries.  The
+ 	 first entry in the procedure linkage table is reserved.  */
+-      plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
++      plt_index = ((struct elf_or1k_link_hash_entry *) h)->plt_index;
+       plt_addr = plt_base_addr + h->plt.offset;
+       plt_reloc = plt_index * sizeof (Elf32_External_Rela);
+ 
++      large_plt_entry = (elf_or1k_plt_entry_size (plt_index)
++			 == PLT_ENTRY_SIZE_LARGE);
++
+       /* Get the offset into the .got table of the entry that
+ 	corresponds to this function.  Each .got entry is 4 bytes.
+ 	The first three are reserved.  */
+@@ -2433,27 +2469,57 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ 	{
+ 	  unsigned pa = ((got_addr >> 13) - (plt_addr >> 13)) & 0x1fffff;
+ 	  unsigned po = (got_addr & 0x1fff);
+-	  plt0 = OR1K_ADRP(12) | pa;
+-	  plt1 = OR1K_LWZ(12,12) | po;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_ADRP(12) | pa;
++	  plt[1] = OR1K_LWZ(12,12) | po;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
+ 	}
+       else if (bfd_link_pic (info))
+ 	{
+-	  plt0 = OR1K_LWZ(12,16) | got_offset;
+-	  plt1 = OR1K_ORI0(11) | plt_reloc;
+-	  plt2 = OR1K_NOP;
++	  if (large_plt_entry)
++	    {
++	      unsigned gotha = ((got_offset + 0x8000) >> 16) & 0xffff;
++	      unsigned got = got_offset & 0xffff;
++	      unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	      unsigned pltrello = plt_reloc & 0xffff;
++
++	      plt[0] = OR1K_MOVHI(12) | gotha;
++	      plt[1] = OR1K_ADD(12,12,16);
++	      plt[2] = OR1K_LWZ(12,12) | got;
++	      plt[3] = OR1K_MOVHI(11) | pltrelhi;
++	      plt[4] = OR1K_ORI(11,11) | pltrello;
++	      plt_insn_count = 5;
++	    }
++	  else
++	    {
++	      plt[0] = OR1K_LWZ(12,16) | got_offset;
++	      plt[1] = OR1K_ORI0(11) | plt_reloc;
++	      plt[2] = OR1K_NOP;
++	    }
+ 	}
+       else
+ 	{
+ 	  unsigned ha = ((got_addr + 0x8000) >> 16) & 0xffff;
+ 	  unsigned lo = got_addr & 0xffff;
+-	  plt0 = OR1K_MOVHI(12) | ha;
+-	  plt1 = OR1K_LWZ(12,12) | lo;
+-	  plt2 = OR1K_ORI0(11) | plt_reloc;
++	  plt[0] = OR1K_MOVHI(12) | ha;
++	  plt[1] = OR1K_LWZ(12,12) | lo;
++	  plt[2] = OR1K_ORI0(11) | plt_reloc;
++	}
++
++      /* For large code model we fixup the non-PIC PLT relocation instructions
++	 here.  */
++      if (large_plt_entry && !bfd_link_pic (info))
++	{
++	  unsigned pltrelhi = (plt_reloc >> 16) & 0xffff;
++	  unsigned pltrello = plt_reloc & 0xffff;
++
++	  plt[2] = OR1K_MOVHI(11) | pltrelhi;
++	  plt[3] = OR1K_ORI(11,11) | pltrello;
++	  plt[4] = OR1K_NOP;
++	  plt_insn_count = 5;
+ 	}
+ 
+       or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset,
+-			    plt0, plt1, plt2, OR1K_JR(12));
++			    OR1K_JR(12), plt, plt_insn_count);
+ 
+       /* Fill in the entry in the global offset table.  We initialize it to
+ 	 point to the top of the plt.  This is done to lazy lookup the actual
+@@ -2777,11 +2843,16 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
+ 	{
+ 	  asection *splt = htab->root.splt;
++	  bfd_vma plt_index;
++
++	  /* Track the index of our plt entry for use in calculating size.  */
++	  plt_index = htab->plt_count++;
++	  ((struct elf_or1k_link_hash_entry *) h)->plt_index = plt_index;
+ 
+ 	  /* If this is the first .plt entry, make room for the special
+ 	     first entry.  */
+ 	  if (splt->size == 0)
+-	    splt->size = PLT_ENTRY_SIZE;
++	    splt->size = elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  h->plt.offset = splt->size;
+ 
+@@ -2798,7 +2869,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+ 	    }
+ 
+ 	  /* Make room for this entry.  */
+-	  splt->size += PLT_ENTRY_SIZE;
++	  splt->size += elf_or1k_plt_entry_size (plt_index);
+ 
+ 	  /* We also need to make an entry in the .got.plt section, which
+ 	     will be placed in the .got section by the linker script.  */
+diff --git a/ld/testsuite/ld-or1k/gotha1.dd b/ld/testsuite/ld-or1k/gotha1.dd
+new file mode 100644
+index 00000000000..0ad1f8f5399
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.dd
+@@ -0,0 +1,34 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.plt:
++
++[0-9a-f]+ <\.plt>:
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 ec [0-9a-f]+ [0-9a-f]+ 	l\.lwz r15,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 78 00 	l\.jr r15
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	19 80 00 00 	l\.movhi r12,0x0
++ +[0-9a-f]+:	85 8c [0-9a-f]+ [0-9a-f]+ 	l\.lwz r12,[0-9]+\(r12\)
++ +[0-9a-f]+:	44 00 60 00 	l\.jr r12
++ +[0-9a-f]+:	a9 60 00 00 	l\.ori r11,r0,0x0
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <_start>:
++ +[0-9a-f]+:	9c 21 ff fc 	l\.addi r1,r1,-4
++ +[0-9a-f]+:	d4 01 48 00 	l\.sw 0\(r1\),r9
++ +[0-9a-f]+:	04 00 00 02 	l\.jal [0-9a-f]+ <_start\+0x10>
++ +[0-9a-f]+:	1a 60 00 00 	l\.movhi r19,0x0
++ +[0-9a-f]+:	aa 73 [0-9a-f]+ [0-9a-f]+ 	l\.ori r19,r19,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 73 48 00 	l\.add r19,r19,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 98 00 	l\.add r17,r17,r19
++ +[0-9a-f]+:	86 31 00 10 	l\.lwz r17,16\(r17\)
++ +[0-9a-f]+:	84 71 00 00 	l\.lwz r3,0\(r17\)
++ +[0-9a-f]+:	07 ff ff f2 	l\.jal [0-9a-f]+ <\.plt\+0x10>
++ +[0-9a-f]+:	15 00 00 00 	l\.nop 0x0
++ +[0-9a-f]+:	85 21 00 00 	l\.lwz r9,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 04 	l\.addi r1,r1,4
+diff --git a/ld/testsuite/ld-or1k/gotha1.s b/ld/testsuite/ld-or1k/gotha1.s
+new file mode 100644
+index 00000000000..42b16db425c
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha1.s
+@@ -0,0 +1,24 @@
++	.data
++	.p2align 16
++
++	.text
++	.globl	_start
++_start:
++	l.addi	r1, r1, -4
++	l.sw	0(r1), r9
++
++	l.jal	8
++	 l.movhi	r19, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r19, r19, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r19, r19, r9
++
++	l.movhi	r17, gotha(x)
++	l.add	r17, r17, r19
++	l.lwz	r17, got(x)(r17)
++	l.lwz	r3, 0(r17)
++
++	l.jal	plt(func)
++	 l.nop
++	l.lwz	r9, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 4
+diff --git a/ld/testsuite/ld-or1k/gotha2.dd b/ld/testsuite/ld-or1k/gotha2.dd
+new file mode 100644
+index 00000000000..fe09da5466b
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.dd
+@@ -0,0 +1,21 @@
++
++.*\.x:     file format elf32-or1k
++
++
++Disassembly of section \.text:
++
++[0-9a-f]+ <test>:
++ +[0-9a-f]+:	9c 21 ff f8 	l\.addi r1,r1,-8
++ +[0-9a-f]+:	d4 01 80 00 	l\.sw 0\(r1\),r16
++ +[0-9a-f]+:	d4 01 48 04 	l\.sw 4\(r1\),r9
++ +[0-9a-f]+:	04 00 [0-9a-f]+ [0-9a-f]+ 	l\.jal [0-9a-f]+ <test\+0x14>
++ +[0-9a-f]+:	1a 00 00 00 	l\.movhi r16,0x0
++ +[0-9a-f]+:	aa 10 [0-9a-f]+ [0-9a-f]+ 	l\.ori r16,r16,0x[0-9a-f]+
++ +[0-9a-f]+:	e2 10 48 00 	l\.add r16,r16,r9
++ +[0-9a-f]+:	1a 20 00 00 	l\.movhi r17,0x0
++ +[0-9a-f]+:	e2 31 80 00 	l\.add r17,r17,r16
++ +[0-9a-f]+:	86 31 00 0c 	l\.lwz r17,12\(r17\)
++ +[0-9a-f]+:	85 21 00 04 	l\.lwz r9,4\(r1\)
++ +[0-9a-f]+:	86 01 00 00 	l\.lwz r16,0\(r1\)
++ +[0-9a-f]+:	44 00 48 00 	l\.jr r9
++ +[0-9a-f]+:	9c 21 00 08 	l\.addi r1,r1,8
+diff --git a/ld/testsuite/ld-or1k/gotha2.s b/ld/testsuite/ld-or1k/gotha2.s
+new file mode 100644
+index 00000000000..164b282f2dd
+--- /dev/null
++++ b/ld/testsuite/ld-or1k/gotha2.s
+@@ -0,0 +1,22 @@
++	.section	.text
++	.align 4
++	.global	test
++	.type	test, @function
++test:
++	l.addi	r1, r1, -8
++	l.sw	0(r1), r16
++	l.sw	4(r1), r9
++
++	l.jal	8
++	 l.movhi	r16, gotpchi(_GLOBAL_OFFSET_TABLE_-4)
++	l.ori	r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+0)
++	l.add	r16, r16, r9
++
++	l.movhi	r17, gotha(i)
++	l.add	r17, r17, r16
++	l.lwz	r17, got(i)(r17)
++
++	l.lwz	r9, 4(r1)
++	l.lwz	r16, 0(r1)
++	l.jr	r9
++	 l.addi	r1, r1, 8
+diff --git a/ld/testsuite/ld-or1k/or1k.exp b/ld/testsuite/ld-or1k/or1k.exp
+index 8bb943aacc9..f10949e89aa 100644
+--- a/ld/testsuite/ld-or1k/or1k.exp
++++ b/ld/testsuite/ld-or1k/or1k.exp
+@@ -53,6 +53,14 @@ set or1kplttests {
+      "" {plt1.s}
+      {{objdump -dr plt1.x.dd}}
+      "plt1.x"}
++    {"gotha exec plt" "tmpdir/libpltlib.so" ""
++     "" {gotha1.s}
++     {{objdump -dr gotha1.dd}}
++     "gotha1.x"}
++    {"gotha -fpic -shared" "-fpic -shared" ""
++     "" {gotha2.s}
++     {{objdump -dr gotha2.dd}}
++     "gotha2.x"}
+ }
+ 
+ # Not implemented yet
+diff --git a/ld/testsuite/ld-or1k/pltlib.s b/ld/testsuite/ld-or1k/pltlib.s
+index baf76ca1af7..8b4d7ba48fd 100644
+--- a/ld/testsuite/ld-or1k/pltlib.s
++++ b/ld/testsuite/ld-or1k/pltlib.s
+@@ -1,5 +1,6 @@
+ 	.section .data
+ 	.globl x, y
++	.size x, 4
+ x:	.long 33
+ y:	.long 44
+ 
+-- 
+2.25.1
+
-- 
2.25.1

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

* [Buildroot] [PATCH 3/9] package/gcc: add upstream patches that introduce -mcmodel=large option for or1k
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 1/9] package/binutils: update or1k patches for plt link version with upstream Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 4/9] package/libgeos: fix build failure due to missing -mcmodel=large Giulio Benetti
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Let's add upstream patches introducing -mcmodel=large or1k gcc option that
works in conjunction with previous binutils patch. That option fix binutils
bug 21464[1] allowing to build libgeos with no problem. This way we can
consider buildroot toolchain binutils bug 21464 free.

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=21464

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 ...-mcmodel-option-to-handle-large-GOTs.patch | 200 +++++++++++++++++
 ...-cmodel-large-when-building-crtstuff.patch |  60 ++++++
 ...-mcmodel-option-to-handle-large-GOTs.patch | 201 ++++++++++++++++++
 ...-cmodel-large-when-building-crtstuff.patch |  60 ++++++
 4 files changed, 521 insertions(+)
 create mode 100644 package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
 create mode 100644 package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch
 create mode 100644 package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
 create mode 100644 package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch

diff --git a/package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch b/package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
new file mode 100644
index 0000000000..c5cd3349cd
--- /dev/null
+++ b/package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
@@ -0,0 +1,200 @@
+From 1dad3f95ffcd1871ca670a13a06fbedb1c3ce509 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:11:44 +0900
+Subject: [PATCH 2/3] or1k: Add mcmodel option to handle large GOTs
+
+When building libgeos we get an error with:
+
+    linux-uclibc/9.3.0/crtbeginS.o: in function `__do_global_dtors_aux':
+    crtstuff.c:(.text+0x118): relocation truncated to fit: R_OR1K_GOT16 against symbol `__cxa_finalize' defined in .text section in
+    /home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.
+
+This is caused by GOT code having a limit of 64k.  In OpenRISC this
+looks to be the only relocation code pattern to be limited to 64k.
+
+This patch allows specifying a new option -mcmodel=large which can be
+used to generate 2 more instructions to construct 32-bit addresses for
+up to 4G GOTs.
+
+gcc/ChangeLog:
+
+	PR 99783
+	* config/or1k/or1k-opts.h: New file.
+	* config/or1k/or1k.c (or1k_legitimize_address_1, print_reloc):
+	Support generating gotha relocations if -mcmodel=large is
+	specified.
+	* config/or1k/or1k.h (TARGET_CMODEL_SMALL, TARGET_CMODEL_LARGE):
+	New macros.
+	* config/or1k/or1k.opt (mcmodel=): New option.
+	* doc/invoke.text (OpenRISC Options): Document mcmodel.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ gcc/config/or1k/or1k-opts.h | 30 ++++++++++++++++++++++++++++++
+ gcc/config/or1k/or1k.c      | 11 +++++++++--
+ gcc/config/or1k/or1k.h      |  7 +++++++
+ gcc/config/or1k/or1k.opt    | 19 +++++++++++++++++++
+ gcc/doc/invoke.texi         | 12 +++++++++++-
+ 5 files changed, 76 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/config/or1k/or1k-opts.h
+
+diff --git a/gcc/config/or1k/or1k-opts.h b/gcc/config/or1k/or1k-opts.h
+new file mode 100644
+index 00000000000..f791b894fdd
+--- /dev/null
++++ b/gcc/config/or1k/or1k-opts.h
+@@ -0,0 +1,30 @@
++/* Definitions for option handling for OpenRISC.
++   Copyright (C) 2021 Free Software Foundation, Inc.
++   Contributed by Stafford Horne.
++
++   This file is part of GCC.
++
++   GCC is free software; you can redistribute it and/or modify it
++   under the terms of the GNU General Public License as published
++   by the Free Software Foundation; either version 3, or (at your
++   option) any later version.
++
++   GCC is distributed in the hope that it will be useful, but WITHOUT
++   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
++   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
++   License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with GCC; see the file COPYING3.  If not see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef GCC_OR1K_OPTS_H
++#define GCC_OR1K_OPTS_H
++
++/* The OpenRISC code generation models available.  */
++enum or1k_cmodel_type {
++  CMODEL_SMALL,
++  CMODEL_LARGE
++};
++
++#endif /* GCC_OR1K_OPTS_H */
+diff --git a/gcc/config/or1k/or1k.c b/gcc/config/or1k/or1k.c
+index 5fa5425aa2b..88613f9596b 100644
+--- a/gcc/config/or1k/or1k.c
++++ b/gcc/config/or1k/or1k.c
+@@ -750,7 +750,14 @@ or1k_legitimize_address_1 (rtx x, rtx scratch)
+ 	    {
+ 	      base = gen_sym_unspec (base, UNSPEC_GOT);
+ 	      crtl->uses_pic_offset_table = 1;
+-	      t2 = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, base);
++	      if (TARGET_CMODEL_LARGE)
++		{
++	          emit_insn (gen_rtx_SET (t1, gen_rtx_HIGH (Pmode, base)));
++	          emit_insn (gen_add3_insn (t1, t1, pic_offset_table_rtx));
++	          t2 = gen_rtx_LO_SUM (Pmode, t1, base);
++		}
++	      else
++	        t2 = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, base);
+ 	      t2 = gen_const_mem (Pmode, t2);
+ 	      emit_insn (gen_rtx_SET (t1, t2));
+ 	      base = t1;
+@@ -1089,7 +1096,7 @@ print_reloc (FILE *stream, rtx x, HOST_WIDE_INT add, reloc_kind kind)
+      no special markup.  */
+   static const char * const relocs[RKIND_MAX][RTYPE_MAX] = {
+     { "lo", "got", "gotofflo", "tpofflo", "gottpofflo", "tlsgdlo" },
+-    { "ha", NULL,  "gotoffha", "tpoffha", "gottpoffha", "tlsgdhi" },
++    { "ha", "gotha", "gotoffha", "tpoffha", "gottpoffha", "tlsgdhi" },
+   };
+   reloc_type type = RTYPE_DIRECT;
+ 
+diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
+index 23db771d8fb..f1646d16dfd 100644
+--- a/gcc/config/or1k/or1k.h
++++ b/gcc/config/or1k/or1k.h
+@@ -21,6 +21,8 @@
+ #ifndef GCC_OR1K_H
+ #define GCC_OR1K_H
+ 
++#include "config/or1k/or1k-opts.h"
++
+ /* Names to predefine in the preprocessor for this target machine.  */
+ #define TARGET_CPU_CPP_BUILTINS()		\
+   do						\
+@@ -35,6 +37,11 @@
+     }						\
+   while (0)
+ 
++#define TARGET_CMODEL_SMALL \
++  (or1k_code_model == CMODEL_SMALL)
++#define TARGET_CMODEL_LARGE \
++  (or1k_code_model == CMODEL_LARGE)
++
+ /* Storage layout.  */
+ 
+ #define DEFAULT_SIGNED_CHAR 1
+diff --git a/gcc/config/or1k/or1k.opt b/gcc/config/or1k/or1k.opt
+index 03c9b8d0bba..8e035075f8a 100644
+--- a/gcc/config/or1k/or1k.opt
++++ b/gcc/config/or1k/or1k.opt
+@@ -21,6 +21,9 @@
+ ; See the GCC internals manual (options.texi) for a description of
+ ; this file's format.
+ 
++HeaderInclude
++config/or1k/or1k-opts.h
++
+ mhard-div
+ Target RejectNegative InverseMask(SOFT_DIV)
+ Enable generation of hardware divide (l.div, l.divu) instructions.  This is the
+@@ -63,6 +66,22 @@ When -mhard-float is selected, enables generation of unordered floating point
+ compare and set flag (lf.sfun*) instructions.  By default functions from libgcc
+ are used to perform unordered floating point compare and set flag operations.
+ 
++mcmodel=
++Target RejectNegative Joined Enum(or1k_cmodel_type) Var(or1k_code_model) Init(CMODEL_SMALL)
++Specify the code model used for accessing memory addresses.  Specifying large
++enables generating binaries with large global offset tables.  By default the
++value is small.
++
++Enum
++Name(or1k_cmodel_type) Type(enum or1k_cmodel_type)
++Known code model types (for use with the -mcmodel= option):
++
++EnumValue
++Enum(or1k_cmodel_type) String(small) Value(CMODEL_SMALL)
++
++EnumValue
++Enum(or1k_cmodel_type) String(large) Value(CMODEL_LARGE)
++
+ mcmov
+ Target RejectNegative Mask(CMOV)
+ Enable generation of conditional move (l.cmov) instructions.  By default the
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index eabeec944e7..eda350c99ec 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -1102,7 +1102,8 @@ Objective-C and Objective-C++ Dialects}.
+ @gccoptlist{-mboard=@var{name}  -mnewlib  -mhard-mul  -mhard-div @gol
+ -msoft-mul  -msoft-div @gol
+ -msoft-float  -mhard-float  -mdouble-float -munordered-float @gol
+--mcmov  -mror  -mrori  -msext  -msfimm  -mshftimm}
++-mcmov  -mror  -mrori  -msext  -msfimm  -mshftimm @gol
++-mcmodel=@var{code-model}}
+ 
+ @emph{PDP-11 Options}
+ @gccoptlist{-mfpu  -msoft-float  -mac0  -mno-ac0  -m40  -m45  -m10 @gol
+@@ -25111,6 +25112,15 @@ Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
+ @code{l.slli}) instructions.  By default extra instructions will be generated
+ to store the immediate to a register first.
+ 
++ at item -mcmodel=small
++ at opindex mcmodel=small
++Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
++the default model.
++
++ at item -mcmodel=large
++ at opindex mcmodel=large
++Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
++
+ 
+ @end table
+ 
+-- 
+2.25.1
+
diff --git a/package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch b/package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch
new file mode 100644
index 0000000000..bc55e8a7e9
--- /dev/null
+++ b/package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch
@@ -0,0 +1,60 @@
+From 0354e007a6235df81e208fa89cbf1571a8b56975 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:11:45 +0900
+Subject: [PATCH 3/3] or1k: Use cmodel=large when building crtstuff
+
+When linking gcc runtime objects into large binaries the link may fail
+with the below errors.  This will happen even if we are building with
+-mcmodel=large.
+
+    /home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o: in function `deregister_tm_clones':
+    crtstuff.c:(.text+0x3c): relocation truncated to fit: R_OR1K_GOT16 against undefined symbol `_ITM_deregisterTMCloneTable'
+    /home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o: in function `register_tm_clones':
+    crtstuff.c:(.text+0xc0): relocation truncated to fit: R_OR1K_GOT16 against undefined symbol `_ITM_registerTMCloneTable'
+
+This patch builds the gcc crtstuff binaries always with the
+-mcmodel=large option to ensure they can be linked into large binaries.
+
+libgcc/ChangeLog:
+
+	PR 99783
+	* config.host (or1k-*, tmake_file): Add or1k/t-crtstuff.
+	* config/or1k/t-crtstuff: New file.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ libgcc/config.host            | 4 ++--
+ libgcc/config/or1k/t-crtstuff | 2 ++
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+ create mode 100644 libgcc/config/or1k/t-crtstuff
+
+diff --git a/libgcc/config.host b/libgcc/config.host
+index c529cc40f0c..ddf0033e28c 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -1127,12 +1127,12 @@ nios2-*-*)
+ 	extra_parts="$extra_parts crti.o crtn.o"
+ 	;;
+ or1k-*-linux*)
+-	tmake_file="$tmake_file or1k/t-or1k"
++	tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff"
+ 	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+ 	md_unwind_header=or1k/linux-unwind.h
+ 	;;
+ or1k-*-*)
+-	tmake_file="$tmake_file or1k/t-or1k"
++	tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff"
+ 	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+ 	;;
+ pdp11-*-*)
+diff --git a/libgcc/config/or1k/t-crtstuff b/libgcc/config/or1k/t-crtstuff
+new file mode 100644
+index 00000000000..dcae7f3498e
+--- /dev/null
++++ b/libgcc/config/or1k/t-crtstuff
+@@ -0,0 +1,2 @@
++# Compile crtbeginS.o and crtendS.o with -mcmodel=large
++CRTSTUFF_T_CFLAGS_S += -mcmodel=large
+-- 
+2.25.1
+
diff --git a/package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch b/package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
new file mode 100644
index 0000000000..caf6cbb1cc
--- /dev/null
+++ b/package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
@@ -0,0 +1,201 @@
+From 1af3ab7fc3e4f2ae835c976486e8af0762674af3 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:11:44 +0900
+Subject: [PATCH 6/7] or1k: Add mcmodel option to handle large GOTs
+
+When building libgeos we get an error with:
+
+    linux-uclibc/9.3.0/crtbeginS.o: in function `__do_global_dtors_aux':
+    crtstuff.c:(.text+0x118): relocation truncated to fit: R_OR1K_GOT16 against symbol `__cxa_finalize' defined in .text section in
+    /home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.
+
+This is caused by GOT code having a limit of 64k.  In OpenRISC this
+looks to be the only relocation code pattern to be limited to 64k.
+
+This patch allows specifying a new option -mcmodel=large which can be
+used to generate 2 more instructions to construct 32-bit addresses for
+up to 4G GOTs.
+
+gcc/ChangeLog:
+
+	PR 99783
+	* config/or1k/or1k-opts.h: New file.
+	* config/or1k/or1k.c (or1k_legitimize_address_1, print_reloc):
+	Support generating gotha relocations if -mcmodel=large is
+	specified.
+	* config/or1k/or1k.h (TARGET_CMODEL_SMALL, TARGET_CMODEL_LARGE):
+	New macros.
+	* config/or1k/or1k.opt (mcmodel=): New option.
+	* doc/invoke.text (OpenRISC Options): Document mcmodel.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ gcc/config/or1k/or1k-opts.h | 30 ++++++++++++++++++++++++++++++
+ gcc/config/or1k/or1k.c      | 11 +++++++++--
+ gcc/config/or1k/or1k.h      |  7 +++++++
+ gcc/config/or1k/or1k.opt    | 19 +++++++++++++++++++
+ gcc/doc/invoke.texi         | 13 ++++++++++++-
+ 5 files changed, 77 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/config/or1k/or1k-opts.h
+
+diff --git a/gcc/config/or1k/or1k-opts.h b/gcc/config/or1k/or1k-opts.h
+new file mode 100644
+index 00000000000..f791b894fdd
+--- /dev/null
++++ b/gcc/config/or1k/or1k-opts.h
+@@ -0,0 +1,30 @@
++/* Definitions for option handling for OpenRISC.
++   Copyright (C) 2021 Free Software Foundation, Inc.
++   Contributed by Stafford Horne.
++
++   This file is part of GCC.
++
++   GCC is free software; you can redistribute it and/or modify it
++   under the terms of the GNU General Public License as published
++   by the Free Software Foundation; either version 3, or (at your
++   option) any later version.
++
++   GCC is distributed in the hope that it will be useful, but WITHOUT
++   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
++   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
++   License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with GCC; see the file COPYING3.  If not see
++   <http://www.gnu.org/licenses/>.  */
++
++#ifndef GCC_OR1K_OPTS_H
++#define GCC_OR1K_OPTS_H
++
++/* The OpenRISC code generation models available.  */
++enum or1k_cmodel_type {
++  CMODEL_SMALL,
++  CMODEL_LARGE
++};
++
++#endif /* GCC_OR1K_OPTS_H */
+diff --git a/gcc/config/or1k/or1k.c b/gcc/config/or1k/or1k.c
+index fc10fcfabde..df67d72b139 100644
+--- a/gcc/config/or1k/or1k.c
++++ b/gcc/config/or1k/or1k.c
+@@ -750,7 +750,14 @@ or1k_legitimize_address_1 (rtx x, rtx scratch)
+ 	    {
+ 	      base = gen_sym_unspec (base, UNSPEC_GOT);
+ 	      crtl->uses_pic_offset_table = 1;
+-	      t2 = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, base);
++	      if (TARGET_CMODEL_LARGE)
++		{
++	          emit_insn (gen_rtx_SET (t1, gen_rtx_HIGH (Pmode, base)));
++	          emit_insn (gen_add3_insn (t1, t1, pic_offset_table_rtx));
++	          t2 = gen_rtx_LO_SUM (Pmode, t1, base);
++		}
++	      else
++	        t2 = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, base);
+ 	      t2 = gen_const_mem (Pmode, t2);
+ 	      emit_insn (gen_rtx_SET (t1, t2));
+ 	      base = t1;
+@@ -1097,7 +1104,7 @@ print_reloc (FILE *stream, rtx x, HOST_WIDE_INT add, reloc_kind kind)
+      no special markup.  */
+   static const char * const relocs[RKIND_MAX][RTYPE_MAX] = {
+     { "lo", "got", "gotofflo", "tpofflo", "gottpofflo", "tlsgdlo" },
+-    { "ha", NULL,  "gotoffha", "tpoffha", "gottpoffha", "tlsgdhi" },
++    { "ha", "gotha", "gotoffha", "tpoffha", "gottpoffha", "tlsgdhi" },
+   };
+   reloc_type type = RTYPE_DIRECT;
+ 
+diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
+index 6dda230f217..858f30743b7 100644
+--- a/gcc/config/or1k/or1k.h
++++ b/gcc/config/or1k/or1k.h
+@@ -21,6 +21,8 @@
+ #ifndef GCC_OR1K_H
+ #define GCC_OR1K_H
+ 
++#include "config/or1k/or1k-opts.h"
++
+ /* Names to predefine in the preprocessor for this target machine.  */
+ #define TARGET_CPU_CPP_BUILTINS()		\
+   do						\
+@@ -35,6 +37,11 @@
+     }						\
+   while (0)
+ 
++#define TARGET_CMODEL_SMALL \
++  (or1k_code_model == CMODEL_SMALL)
++#define TARGET_CMODEL_LARGE \
++  (or1k_code_model == CMODEL_LARGE)
++
+ /* Storage layout.  */
+ 
+ #define DEFAULT_SIGNED_CHAR 1
+diff --git a/gcc/config/or1k/or1k.opt b/gcc/config/or1k/or1k.opt
+index 7bdbd842dd4..116524c3441 100644
+--- a/gcc/config/or1k/or1k.opt
++++ b/gcc/config/or1k/or1k.opt
+@@ -23,6 +23,9 @@
+ 
+ ; Please try to keep this file in ASCII collating order.
+ 
++HeaderInclude
++config/or1k/or1k-opts.h
++
+ mhard-div
+ Target RejectNegative InverseMask(SOFT_DIV)
+ Use hardware divide instructions, use -msoft-div for emulation.
+@@ -31,6 +34,22 @@ mhard-mul
+ Target RejectNegative InverseMask(SOFT_MUL).
+ Use hardware multiply instructions, use -msoft-mul for emulation.
+ 
++mcmodel=
++Target RejectNegative Joined Enum(or1k_cmodel_type) Var(or1k_code_model) Init(CMODEL_SMALL)
++Specify the code model used for accessing memory addresses.  Specifying large
++enables generating binaries with large global offset tables.  By default the
++value is small.
++
++Enum
++Name(or1k_cmodel_type) Type(enum or1k_cmodel_type)
++Known code model types (for use with the -mcmodel= option):
++
++EnumValue
++Enum(or1k_cmodel_type) String(small) Value(CMODEL_SMALL)
++
++EnumValue
++Enum(or1k_cmodel_type) String(large) Value(CMODEL_LARGE)
++
+ mcmov
+ Target RejectNegative Mask(CMOV)
+ Allows generation of binaries which use the l.cmov instruction.  If your target
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 0ab6c9c6449..0904b2b5a41 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -1030,7 +1030,9 @@ Objective-C and Objective-C++ Dialects}.
+ @emph{OpenRISC Options}
+ @gccoptlist{-mboard=@var{name}  -mnewlib  -mhard-mul  -mhard-div @gol
+ -msoft-mul  -msoft-div @gol
+--mcmov  -mror  -msext  -msfimm  -mshftimm}
++-mcmov  -mror  -mrori  -msext  -msfimm  -mshftimm @gol
++-mcmodel=@var{code-model}}
++
+ 
+ @emph{PDP-11 Options}
+ @gccoptlist{-mfpu  -msoft-float  -mac0  -mno-ac0  -m40  -m45  -m10 @gol
+@@ -27408,6 +27410,15 @@ MWAITX, SHA, CLZERO, AES, PCL_MUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
+ SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
+ instruction set extensions.)
+ 
++ at item -mcmodel=small
++ at opindex mcmodel=small
++Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
++the default model.
++
++ at item -mcmodel=large
++ at opindex mcmodel=large
++Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
++
+ 
+ @item btver1
+ CPUs based on AMD Family 14h cores with x86-64 instruction set support.  (This
+-- 
+2.25.1
+
diff --git a/package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch b/package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch
new file mode 100644
index 0000000000..6190a8297a
--- /dev/null
+++ b/package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch
@@ -0,0 +1,60 @@
+From b540f7b916ba7cf2059b84c5cc8d08c67ebe9a0b Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Sun, 2 May 2021 06:11:45 +0900
+Subject: [PATCH 7/7] or1k: Use cmodel=large when building crtstuff
+
+When linking gcc runtime objects into large binaries the link may fail
+with the below errors.  This will happen even if we are building with
+-mcmodel=large.
+
+    /home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o: in function `deregister_tm_clones':
+    crtstuff.c:(.text+0x3c): relocation truncated to fit: R_OR1K_GOT16 against undefined symbol `_ITM_deregisterTMCloneTable'
+    /home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o: in function `register_tm_clones':
+    crtstuff.c:(.text+0xc0): relocation truncated to fit: R_OR1K_GOT16 against undefined symbol `_ITM_registerTMCloneTable'
+
+This patch builds the gcc crtstuff binaries always with the
+-mcmodel=large option to ensure they can be linked into large binaries.
+
+libgcc/ChangeLog:
+
+	PR 99783
+	* config.host (or1k-*, tmake_file): Add or1k/t-crtstuff.
+	* config/or1k/t-crtstuff: New file.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ libgcc/config.host            | 4 ++--
+ libgcc/config/or1k/t-crtstuff | 2 ++
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+ create mode 100644 libgcc/config/or1k/t-crtstuff
+
+diff --git a/libgcc/config.host b/libgcc/config.host
+index 0f15fda3612..0c21d384e6f 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -1051,12 +1051,12 @@ nios2-*-*)
+ 	extra_parts="$extra_parts crti.o crtn.o"
+ 	;;
+ or1k-*-linux*)
+-	tmake_file="$tmake_file or1k/t-or1k"
++	tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff"
+ 	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+ 	md_unwind_header=or1k/linux-unwind.h
+ 	;;
+ or1k-*-*)
+-	tmake_file="$tmake_file or1k/t-or1k"
++	tmake_file="$tmake_file or1k/t-or1k or1k/t-crtstuff"
+ 	tmake_file="$tmake_file t-softfp-sfdf t-softfp"
+ 	;;
+ pdp11-*-*)
+diff --git a/libgcc/config/or1k/t-crtstuff b/libgcc/config/or1k/t-crtstuff
+new file mode 100644
+index 00000000000..dcae7f3498e
+--- /dev/null
++++ b/libgcc/config/or1k/t-crtstuff
+@@ -0,0 +1,2 @@
++# Compile crtbeginS.o and crtendS.o with -mcmodel=large
++CRTSTUFF_T_CFLAGS_S += -mcmodel=large
+-- 
+2.25.1
+
-- 
2.25.1

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

* [Buildroot] [PATCH 4/9] package/libgeos: fix build failure due to missing -mcmodel=large
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (2 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 3/9] package/gcc: add upstream patches that introduce -mcmodel=large option for or1k Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 5/9] package/protobuf: " Giulio Benetti
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

When building libgeos for or1k -mcmodel=large is needed to link, so let's
add that gcc option in case we're building for or1k.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/libgeos/libgeos.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/libgeos/libgeos.mk b/package/libgeos/libgeos.mk
index a355732af8..43211d0434 100644
--- a/package/libgeos/libgeos.mk
+++ b/package/libgeos/libgeos.mk
@@ -23,6 +23,10 @@ ifeq ($(BR2_arm)$(BR2_armeb),y)
 LIBGEOS_CONF_OPTS += -DDISABLE_GEOS_INLINE=ON
 endif
 
+ifeq ($(BR2_or1k),y)
+LIBGEOS_CXXFLAGS += -mcmodel=large
+endif
+
 LIBGEOS_CONF_OPTS += -DCMAKE_CXX_FLAGS="$(LIBGEOS_CXXFLAGS)"
 
 $(eval $(cmake-package))
-- 
2.25.1

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

* [Buildroot] [PATCH 5/9] package/protobuf: fix build failure due to missing -mcmodel=large
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (3 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 4/9] package/libgeos: fix build failure due to missing -mcmodel=large Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 6/9] toolchain: remove binutils bug 21464 Giulio Benetti
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

When building protobuf for or1k -mcmodel=large is needed to link, so let's
add that gcc option in case we're building for or1k.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/protobuf/protobuf.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/protobuf/protobuf.mk b/package/protobuf/protobuf.mk
index ea75480038..d6b3557020 100644
--- a/package/protobuf/protobuf.mk
+++ b/package/protobuf/protobuf.mk
@@ -24,6 +24,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_85180),y)
 PROTOBUF_CXXFLAGS += -O0
 endif
 
+ifeq ($(BR2_or1k),y)
+PROTOBUF_CXXFLAGS += -mcmodel=large
+endif
+
 PROTOBUF_CONF_ENV = CXXFLAGS="$(PROTOBUF_CXXFLAGS)"
 
 ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
-- 
2.25.1

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

* [Buildroot] [PATCH 6/9] toolchain: remove binutils bug 21464
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (4 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 5/9] package/protobuf: " Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 7/9] package/libgeos: remove binutils bug 21464 dependency Giulio Benetti
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

This bug has been fixed upstream and backported to buildroot binutils
package. So let's remove it.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 toolchain/Config.in | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/toolchain/Config.in b/toolchain/Config.in
index 78444f6130..06c338ee7d 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -71,12 +71,6 @@ source "package/gdb/Config.in.host"
 
 comment "Toolchain Generic Options"
 
-# https://sourceware.org/bugzilla/show_bug.cgi?id=21464
-# Affect toolchains built with binutils 2.31.1, still not fixed.
-config BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464
-	bool
-	default y if BR2_or1k
-
 # https://sourceware.org/bugzilla/show_bug.cgi?id=27100
 # Affect toolchains built with binutils 2.33.1 (fixed in binutils 2.36)
 config BR2_TOOLCHAIN_HAS_BINUTILS_BUG_27100
-- 
2.25.1

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

* [Buildroot] [PATCH 7/9] package/libgeos: remove binutils bug 21464 dependency
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (5 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 6/9] toolchain: remove binutils bug 21464 Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 8/9] package/postgis: remove libgeos binutils bug 21464 inheritance Giulio Benetti
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/libgeos/Config.in | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/package/libgeos/Config.in b/package/libgeos/Config.in
index ebe40bd1ff..b659c98460 100644
--- a/package/libgeos/Config.in
+++ b/package/libgeos/Config.in
@@ -2,7 +2,6 @@ config BR2_PACKAGE_LIBGEOS
 	bool "libgeos"
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_USE_WCHAR
-	depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464
 	depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_27597
 	help
 	  GEOS (Geometry Engine - Open Source) is a C++ port of the
@@ -13,7 +12,6 @@ config BR2_PACKAGE_LIBGEOS
 
 	  https://trac.osgeo.org/geos
 
-comment "libgeos needs a toolchain w/ C++, wchar, not binutils bug 21464, 27597"
+comment "libgeos needs a toolchain w/ C++, wchar, not binutils bug 27597"
 	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR || \
-		   !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464 || \
 		   !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_27597
-- 
2.25.1

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

* [Buildroot] [PATCH 8/9] package/postgis: remove libgeos binutils bug 21464 inheritance
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (6 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 7/9] package/libgeos: remove binutils bug 21464 dependency Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-03 11:13 ` [Buildroot] [PATCH 9/9] package/protobuf: remove binutils bug 21464 dependency Giulio Benetti
  2021-05-21  8:46 ` [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Arnout Vandecappelle
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/postgis/Config.in | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/package/postgis/Config.in b/package/postgis/Config.in
index 49887b61c0..553c89d9dd 100644
--- a/package/postgis/Config.in
+++ b/package/postgis/Config.in
@@ -6,7 +6,6 @@ config BR2_PACKAGE_POSTGIS
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # C++11, proj
 	depends on BR2_TOOLCHAIN_HAS_THREADS # proj
 	depends on BR2_USE_WCHAR # libgeos, proj
-	depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464 # libgeos
 	depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_27597 # libgeos
 	select BR2_PACKAGE_LIBGEOS
 	select BR2_PACKAGE_PROJ
@@ -20,9 +19,8 @@ config BR2_PACKAGE_POSTGIS
 
 	  https://postgis.net/
 
-comment "postgis needs a toolchain w/ C++, threads, wchar, gcc >= 4.7, not binutils bug 21464, 27597"
+comment "postgis needs a toolchain w/ C++, threads, wchar, gcc >= 4.7, not binutils bug 27597"
 	depends on !BR2_microblazeel && !BR2_microblazebe # ICE
 	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 || \
 		!BR2_TOOLCHAIN_HAS_THREADS || !BR2_USE_WCHAR || \
-		!BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464 || \
 		!BR2_TOOLCHAIN_HAS_BINUTILS_BUG_27597
-- 
2.25.1

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

* [Buildroot] [PATCH 9/9] package/protobuf: remove binutils bug 21464 dependency
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (7 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 8/9] package/postgis: remove libgeos binutils bug 21464 inheritance Giulio Benetti
@ 2021-05-03 11:13 ` Giulio Benetti
  2021-05-21  8:46 ` [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Arnout Vandecappelle
  9 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-03 11:13 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/protobuf/Config.in | 1 -
 1 file changed, 1 deletion(-)

diff --git a/package/protobuf/Config.in b/package/protobuf/Config.in
index 30050950aa..46c820b9cf 100644
--- a/package/protobuf/Config.in
+++ b/package/protobuf/Config.in
@@ -24,7 +24,6 @@ config BR2_PACKAGE_PROTOBUF_ARCH_SUPPORTS
 	default y if BR2_TOOLCHAIN_HAS_ATOMIC
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
 	depends on BR2_USE_MMU # fork()
-	depends on !BR2_TOOLCHAIN_HAS_BINUTILS_BUG_21464
 
 config BR2_PACKAGE_PROTOBUF
 	bool "protobuf"
-- 
2.25.1

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

* [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it
  2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
                   ` (8 preceding siblings ...)
  2021-05-03 11:13 ` [Buildroot] [PATCH 9/9] package/protobuf: remove binutils bug 21464 dependency Giulio Benetti
@ 2021-05-21  8:46 ` Arnout Vandecappelle
  2021-05-21 14:21   ` Giulio Benetti
  9 siblings, 1 reply; 22+ messages in thread
From: Arnout Vandecappelle @ 2021-05-21  8:46 UTC (permalink / raw)
  To: buildroot

 Hi Giulio,

 Thanks for these!

On 03/05/2021 13:13, Giulio Benetti wrote:
> This patchset fixes binutils bug 21464 and fixes libgeos build failure
> by introducing the gcc option flag -mcmodel. This is done by adding
> upstreamed binutils and gcc patches. Note tha this way buildroot
> toolchains can be considered bug binutils 21464 free and the only other
> OpenRisc toolchain supported is the external Bootlin one. So this
> patchset has to be considered valid once Bootlin updates its OpenRisc
> by adding binutils and gcc patches that are added with patches in this
> patchset.
> 
> Giulio Benetti (9):
>   package/binutils: update or1k patches for plt link version with
>     upstream
>   package/binutils: add upstream backported patches to support
>     -mcmodel=large gcc option
>   package/gcc: add upstream patches that introduce -mcmodel=large option
>     for or1k

 Patches 1-3 applied to master. Note that I had to fix all of them up because
they failed check-package. The [PATCH N/M] things are not allowed. Ideally, when
you add patches, you shouldn't just pluck them from the mailing list. Instead,
you should apply them in a git clone - preferably by cherry-picking with `git
cherry-pick -x <sha1>` if they have been applied upstream. Then you should
regenerate *all* patches `git format-patch -N <base>..`. Then verify that only
the patches that you intended to change have actually changed.


>   package/libgeos: fix build failure due to missing -mcmodel=large
>   package/protobuf: fix build failure due to missing -mcmodel=large

 As mentioned, these can only be applied after Thomas updates the bootlin
toolchains *and* the patch to update them in Buildroot has been merged. That's
not going to happen on master :-)

>   toolchain: remove binutils bug 21464
>   package/libgeos: remove binutils bug 21464 dependency
>   package/postgis: remove libgeos binutils bug 21464 inheritance
>   package/protobuf: remove binutils bug 21464 dependency

 These four should be squashed into a single patch.


 Regards,
 Arnout

> 
>  .../0010-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
>  ...ith-plt-link-failure-for-local-calls.patch |  59 +++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
>  ...ith-plt-link-failure-for-local-calls.patch |  59 +++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
>  ...ith-plt-link-failure-for-local-calls.patch |  59 +++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  .../0003-bfd-elf32-or1k-fix-ld-assert.patch   |  35 --
>  ...ith-plt-link-failure-for-local-calls.patch |  59 +++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  ...-mcmodel-option-to-handle-large-GOTs.patch | 200 +++++++
>  ...-cmodel-large-when-building-crtstuff.patch |  60 +++
>  ...-mcmodel-option-to-handle-large-GOTs.patch | 201 +++++++
>  ...-cmodel-large-when-building-crtstuff.patch |  60 +++
>  package/libgeos/Config.in                     |   4 +-
>  package/libgeos/libgeos.mk                    |   4 +
>  package/postgis/Config.in                     |   4 +-
>  package/protobuf/Config.in                    |   1 -
>  package/protobuf/protobuf.mk                  |   4 +
>  toolchain/Config.in                           |   6 -
>  30 files changed, 4035 insertions(+), 153 deletions(-)
>  delete mode 100644 package/binutils/2.32/0010-bfd-elf32-or1k-fix-ld-assert.patch
>  create mode 100644 package/binutils/2.32/0010-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
>  create mode 100644 package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  delete mode 100644 package/binutils/2.34/0003-bfd-elf32-or1k-fix-ld-assert.patch
>  create mode 100644 package/binutils/2.34/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
>  create mode 100644 package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  delete mode 100644 package/binutils/2.35.2/0003-bfd-elf32-or1k-fix-ld-assert.patch
>  create mode 100644 package/binutils/2.35.2/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
>  create mode 100644 package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  delete mode 100644 package/binutils/2.36.1/0003-bfd-elf32-or1k-fix-ld-assert.patch
>  create mode 100644 package/binutils/2.36.1/0003-or1k-Fix-issue-with-plt-link-failure-for-local-calls.patch
>  create mode 100644 package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  create mode 100644 package/gcc/10.3.0/0002-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
>  create mode 100644 package/gcc/10.3.0/0003-or1k-Use-cmodel-large-when-building-crtstuff.patch
>  create mode 100644 package/gcc/9.3.0/0006-or1k-Add-mcmodel-option-to-handle-large-GOTs.patch
>  create mode 100644 package/gcc/9.3.0/0007-or1k-Use-cmodel-large-when-building-crtstuff.patch
> 

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

* [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it
  2021-05-21  8:46 ` [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Arnout Vandecappelle
@ 2021-05-21 14:21   ` Giulio Benetti
  2021-05-21 21:26     ` Yann E. MORIN
  0 siblings, 1 reply; 22+ messages in thread
From: Giulio Benetti @ 2021-05-21 14:21 UTC (permalink / raw)
  To: buildroot

Hi Arnout,

On 5/21/21 10:46 AM, Arnout Vandecappelle wrote:
>   Hi Giulio,
> 
>   Thanks for these!

Happy to help :-)

> On 03/05/2021 13:13, Giulio Benetti wrote:
>> This patchset fixes binutils bug 21464 and fixes libgeos build failure
>> by introducing the gcc option flag -mcmodel. This is done by adding
>> upstreamed binutils and gcc patches. Note tha this way buildroot
>> toolchains can be considered bug binutils 21464 free and the only other
>> OpenRisc toolchain supported is the external Bootlin one. So this
>> patchset has to be considered valid once Bootlin updates its OpenRisc
>> by adding binutils and gcc patches that are added with patches in this
>> patchset.
>>
>> Giulio Benetti (9):
>>    package/binutils: update or1k patches for plt link version with
>>      upstream
>>    package/binutils: add upstream backported patches to support
>>      -mcmodel=large gcc option
>>    package/gcc: add upstream patches that introduce -mcmodel=large option
>>      for or1k
> 
>   Patches 1-3 applied to master. Note that I had to fix all of them up because
> they failed check-package. The [PATCH N/M] things are not allowed. Ideally, when
> you add patches, you shouldn't just pluck them from the mailing list. Instead,
> you should apply them in a git clone - preferably by cherry-picking with `git
> cherry-pick -x <sha1>` if they have been applied upstream. Then you should
> regenerate *all* patches `git format-patch -N <base>..`. Then verify that only
> the patches that you intended to change have actually changed.

Oh right, thank you for modifying them, I've forgotten to check-package 
them.

> 
>>    package/libgeos: fix build failure due to missing -mcmodel=large
>>    package/protobuf: fix build failure due to missing -mcmodel=large
> 
>   As mentioned, these can only be applied after Thomas updates the bootlin
> toolchains *and* the patch to update them in Buildroot has been merged. That's
> not going to happen on master :-)

Ok

>>    toolchain: remove binutils bug 21464
>>    package/libgeos: remove binutils bug 21464 dependency
>>    package/postgis: remove libgeos binutils bug 21464 inheritance
>>    package/protobuf: remove binutils bug 21464 dependency
> 
>   These four should be squashed into a single patch.

I've just sent a v2 for this:
https://patchwork.ozlabs.org/project/buildroot/patch/20210521140942.3032331-1-giulio.benetti at benettiengineering.com/


Kind regards
-- 
Giulio Benetti
Benetti Engineering sas

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

* [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it
  2021-05-21 14:21   ` Giulio Benetti
@ 2021-05-21 21:26     ` Yann E. MORIN
  2021-05-21 21:28       ` Giulio Benetti
  0 siblings, 1 reply; 22+ messages in thread
From: Yann E. MORIN @ 2021-05-21 21:26 UTC (permalink / raw)
  To: buildroot

Giulio, Arnout, All,

On 2021-05-21 16:21 +0200, Giulio Benetti spake thusly:
> On 5/21/21 10:46 AM, Arnout Vandecappelle wrote:
> >On 03/05/2021 13:13, Giulio Benetti wrote:
> >>   toolchain: remove binutils bug 21464
> >>   package/libgeos: remove binutils bug 21464 dependency
> >>   package/postgis: remove libgeos binutils bug 21464 inheritance
> >>   package/protobuf: remove binutils bug 21464 dependency
> >  These four should be squashed into a single patch.
> I've just sent a v2 for this:
> https://patchwork.ozlabs.org/project/buildroot/patch/20210521140942.3032331-1-giulio.benetti at benettiengineering.com/

As a consequence, I've marked the original 4 as supersded in Patchwork,
which only leaves the remaining two:

    package/libgeos: fix build failure due to missing -mcmodel=large
    package/protobuf: fix build failure due to missing -mcmodel=large 

Thanks!

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

* [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it
  2021-05-21 21:26     ` Yann E. MORIN
@ 2021-05-21 21:28       ` Giulio Benetti
  0 siblings, 0 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-05-21 21:28 UTC (permalink / raw)
  To: buildroot

On 5/21/21 11:26 PM, Yann E. MORIN wrote:
> Giulio, Arnout, All,
> 
> On 2021-05-21 16:21 +0200, Giulio Benetti spake thusly:
>> On 5/21/21 10:46 AM, Arnout Vandecappelle wrote:
>>> On 03/05/2021 13:13, Giulio Benetti wrote:
>>>>    toolchain: remove binutils bug 21464
>>>>    package/libgeos: remove binutils bug 21464 dependency
>>>>    package/postgis: remove libgeos binutils bug 21464 inheritance
>>>>    package/protobuf: remove binutils bug 21464 dependency
>>>   These four should be squashed into a single patch.
>> I've just sent a v2 for this:
>> https://patchwork.ozlabs.org/project/buildroot/patch/20210521140942.3032331-1-giulio.benetti at benettiengineering.com/
> 
> As a consequence, I've marked the original 4 as supersded in Patchwork,
> which only leaves the remaining two:
> 
>      package/libgeos: fix build failure due to missing -mcmodel=large
>      package/protobuf: fix build failure due to missing -mcmodel=large

Oh yes, I've forgotten, thank you :-)

Kind regards
-- 
Giulio Benetti
Benetti Engineering sas

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-05-03 11:13 ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
@ 2021-06-08 21:29   ` Romain Naour
  2021-06-08 22:16     ` Giulio Benetti
  0 siblings, 1 reply; 22+ messages in thread
From: Romain Naour @ 2021-06-08 21:29 UTC (permalink / raw)
  To: buildroot

Hi Giulio, All,

Le 03/05/2021 ? 13:13, Giulio Benetti a ?crit?:
> Add upstream backported patches that allows using -mcmodel=large gcc option
> that in order allows fixing build failure due to binutils bug 21464:
> https://sourceware.org/bugzilla/show_bug.cgi?id=21464
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> ---
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>  ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>  ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>  12 files changed, 3268 insertions(+)
>  create mode 100644 package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  create mode 100644 package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  create mode 100644 package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>  create mode 100644 package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>  create mode 100644 package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>  create mode 100644 package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
> 

> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
> +-  unsigned insn4;
> ++  unsigned output_insns[PLT_MAX_INSN_COUNT];
> ++
> ++  /* Copy instructions into the output buffer.  */
> ++  for (size_t i = 0; i < insn_count; i++)
> ++    output_insns[i] = insns[i];
> + 

This syntax break with good old compilers :)

elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
C99 or C11 mode
   for (size_t i = 0; i < insn_count; i++)
   ^

See:
https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298

Best regards,
Romain

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-06-08 21:29   ` Romain Naour
@ 2021-06-08 22:16     ` Giulio Benetti
  2021-06-09  6:26       ` Romain Naour
  0 siblings, 1 reply; 22+ messages in thread
From: Giulio Benetti @ 2021-06-08 22:16 UTC (permalink / raw)
  To: buildroot

Hi Romain,

On 6/8/21 11:29 PM, Romain Naour wrote:
> Hi Giulio, All,
> 
> Le 03/05/2021 ? 13:13, Giulio Benetti a ?crit?:
>> Add upstream backported patches that allows using -mcmodel=large gcc option
>> that in order allows fixing build failure due to binutils bug 21464:
>> https://sourceware.org/bugzilla/show_bug.cgi?id=21464
>>
>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
>> ---
>>   ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>   ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>   ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>   ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>   ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>   ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>   ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>   ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>   ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>   ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>   ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>   ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>   12 files changed, 3268 insertions(+)
>>   create mode 100644 package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>   create mode 100644 package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>   create mode 100644 package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>   create mode 100644 package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>   create mode 100644 package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>   create mode 100644 package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>   create mode 100644 package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>   create mode 100644 package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>   create mode 100644 package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>   create mode 100644 package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>   create mode 100644 package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>   create mode 100644 package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>
> 
>> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
>> +-  unsigned insn4;
>> ++  unsigned output_insns[PLT_MAX_INSN_COUNT];
>> ++
>> ++  /* Copy instructions into the output buffer.  */
>> ++  for (size_t i = 0; i < insn_count; i++)
>> ++    output_insns[i] = insns[i];
>> +
> 
> This syntax break with good old compilers :)
> 
> elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
> C99 or C11 mode
>     for (size_t i = 0; i < insn_count; i++)
>     ^
> 
> See:
> https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298

Thanks for pointing, I didn't think about old host compiler. I'm going 
to fix it soon by patching actual patches initializing variable at the
begin of functions.

Best regards
-- 
Giulio Benetti
Benetti Engineering sas

> Best regards,
> Romain
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-06-08 22:16     ` Giulio Benetti
@ 2021-06-09  6:26       ` Romain Naour
  2021-06-09 16:27         ` [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5 Giulio Benetti
  2021-06-09 16:50         ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
  0 siblings, 2 replies; 22+ messages in thread
From: Romain Naour @ 2021-06-09  6:26 UTC (permalink / raw)
  To: buildroot

Hi Giulio,

Le 09/06/2021 ? 00:16, Giulio Benetti a ?crit?:
> Hi Romain,
> 
> On 6/8/21 11:29 PM, Romain Naour wrote:
>> Hi Giulio, All,
>>
>> Le 03/05/2021 ? 13:13, Giulio Benetti a ?crit?:
>>> Add upstream backported patches that allows using -mcmodel=large gcc option
>>> that in order allows fixing build failure due to binutils bug 21464:
>>> https://sourceware.org/bugzilla/show_bug.cgi?id=21464
>>>
>>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
>>> ---
>>> ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>> ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>> ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>> ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>> ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>> ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>> ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>> ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>> ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>> ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>> ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>> ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>> ? 12 files changed, 3268 insertions(+)
>>> ? create mode 100644
>>> package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>
>>> ? create mode 100644
>>> package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>
>>>
>>
>>> +?? unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
>>> +-? unsigned insn4;
>>> ++? unsigned output_insns[PLT_MAX_INSN_COUNT];
>>> ++
>>> ++? /* Copy instructions into the output buffer.? */
>>> ++? for (size_t i = 0; i < insn_count; i++)
>>> ++??? output_insns[i] = insns[i];
>>> +
>>
>> This syntax break with good old compilers :)
>>
>> elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
>> C99 or C11 mode
>> ??? for (size_t i = 0; i < insn_count; i++)
>> ??? ^
>>
>> See:
>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298
> 
> Thanks for pointing, I didn't think about old host compiler. I'm going to fix it
> soon by patching actual patches initializing variable at the
> begin of functions.

Toolchain-builder use Debian 8 jessie to build the toolchain while Debian 9
stretch is used to run the Buildroot testsuite.

See, there is no problem to build the qemu_or1k_defconfig in gitlab using stretch:
https://gitlab.com/buildroot.org/buildroot/-/jobs/1307293494

The host gcc used by stretch is gcc 6 while it's gcc 4.9 for jessie, the default
mode for C is -std=gnu11 since gcc 5:
https://gcc.gnu.org/gcc-5/changes.html

Thanks!

Best regards,
Romain


> 
> Best regards

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

* [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5
  2021-06-09  6:26       ` Romain Naour
@ 2021-06-09 16:27         ` Giulio Benetti
  2021-06-09 17:10           ` Romain Naour
  2021-07-18 20:35           ` Thomas Petazzoni
  2021-06-09 16:50         ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
  1 sibling, 2 replies; 22+ messages in thread
From: Giulio Benetti @ 2021-06-09 16:27 UTC (permalink / raw)
  To: buildroot

Add patches to fix building on hosts that provide gcc version < 5
(i.e. 4.9), otherwise they fail due to missing default '-std=gnu11' option
on variable declaration inside for loops.

The patch is pending upstream:
https://sourceware.org/pipermail/binutils/2021-June/116884.html

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
 ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
 ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
 ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
 4 files changed, 200 insertions(+)
 create mode 100644 package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
 create mode 100644 package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
 create mode 100644 package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
 create mode 100644 package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch

diff --git a/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
new file mode 100644
index 0000000000..c3978e22fa
--- /dev/null
+++ b/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
@@ -0,0 +1,50 @@
+From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Wed, 9 Jun 2021 17:28:27 +0200
+Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
+
+Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
+an old compiler(i.e. gcc 4.9) build fails on:
+```
+elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
+C99 or C11 mode
+    for (size_t i = 0; i < insn_count; i++)
+    ^
+```
+
+So let's declare `size_t i` at the top of the function instead of inside
+for loop.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 4ae7f324d33..32063ab0289 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+   unsigned output_insns[PLT_MAX_INSN_COUNT];
++  size_t i;
+ 
+   /* Copy instructions into the output buffer.  */
+-  for (size_t i = 0; i < insn_count; i++)
++  for (i = 0; i < insn_count; i++)
+     output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+     }
+ 
+   /* Write out the output buffer.  */
+-  for (size_t i = 0; i < (insn_count+1); i++)
++  for (i = 0; i < (insn_count+1); i++)
+     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
new file mode 100644
index 0000000000..c3978e22fa
--- /dev/null
+++ b/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
@@ -0,0 +1,50 @@
+From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Wed, 9 Jun 2021 17:28:27 +0200
+Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
+
+Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
+an old compiler(i.e. gcc 4.9) build fails on:
+```
+elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
+C99 or C11 mode
+    for (size_t i = 0; i < insn_count; i++)
+    ^
+```
+
+So let's declare `size_t i` at the top of the function instead of inside
+for loop.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 4ae7f324d33..32063ab0289 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+   unsigned output_insns[PLT_MAX_INSN_COUNT];
++  size_t i;
+ 
+   /* Copy instructions into the output buffer.  */
+-  for (size_t i = 0; i < insn_count; i++)
++  for (i = 0; i < insn_count; i++)
+     output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+     }
+ 
+   /* Write out the output buffer.  */
+-  for (size_t i = 0; i < (insn_count+1); i++)
++  for (i = 0; i < (insn_count+1); i++)
+     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
new file mode 100644
index 0000000000..c3978e22fa
--- /dev/null
+++ b/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
@@ -0,0 +1,50 @@
+From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Wed, 9 Jun 2021 17:28:27 +0200
+Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
+
+Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
+an old compiler(i.e. gcc 4.9) build fails on:
+```
+elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
+C99 or C11 mode
+    for (size_t i = 0; i < insn_count; i++)
+    ^
+```
+
+So let's declare `size_t i` at the top of the function instead of inside
+for loop.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 4ae7f324d33..32063ab0289 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+   unsigned output_insns[PLT_MAX_INSN_COUNT];
++  size_t i;
+ 
+   /* Copy instructions into the output buffer.  */
+-  for (size_t i = 0; i < insn_count; i++)
++  for (i = 0; i < insn_count; i++)
+     output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+     }
+ 
+   /* Write out the output buffer.  */
+-  for (size_t i = 0; i < (insn_count+1); i++)
++  for (i = 0; i < (insn_count+1); i++)
+     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+-- 
+2.25.1
+
diff --git a/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
new file mode 100644
index 0000000000..c3978e22fa
--- /dev/null
+++ b/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
@@ -0,0 +1,50 @@
+From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Wed, 9 Jun 2021 17:28:27 +0200
+Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
+
+Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
+an old compiler(i.e. gcc 4.9) build fails on:
+```
+elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
+C99 or C11 mode
+    for (size_t i = 0; i < insn_count; i++)
+    ^
+```
+
+So let's declare `size_t i` at the top of the function instead of inside
+for loop.
+
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ bfd/elf32-or1k.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
+index 4ae7f324d33..32063ab0289 100644
+--- a/bfd/elf32-or1k.c
++++ b/bfd/elf32-or1k.c
+@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+ {
+   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
+   unsigned output_insns[PLT_MAX_INSN_COUNT];
++  size_t i;
+ 
+   /* Copy instructions into the output buffer.  */
+-  for (size_t i = 0; i < insn_count; i++)
++  for (i = 0; i < insn_count; i++)
+     output_insns[i] = insns[i];
+ 
+   /* Honor the no-delay-slot setting.  */
+@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
+     }
+ 
+   /* Write out the output buffer.  */
+-  for (size_t i = 0; i < (insn_count+1); i++)
++  for (i = 0; i < (insn_count+1); i++)
+     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
+ }
+ 
+-- 
+2.25.1
+
-- 
2.25.1

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-06-09  6:26       ` Romain Naour
  2021-06-09 16:27         ` [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5 Giulio Benetti
@ 2021-06-09 16:50         ` Giulio Benetti
  2021-06-09 16:57           ` Romain Naour
  1 sibling, 1 reply; 22+ messages in thread
From: Giulio Benetti @ 2021-06-09 16:50 UTC (permalink / raw)
  To: buildroot

Hi Romain, All,

On 6/9/21 8:26 AM, Romain Naour wrote:
> Hi Giulio,
> 
> Le 09/06/2021 ? 00:16, Giulio Benetti a ?crit?:
>> Hi Romain,
>>
>> On 6/8/21 11:29 PM, Romain Naour wrote:
>>> Hi Giulio, All,
>>>
>>> Le 03/05/2021 ? 13:13, Giulio Benetti a ?crit?:
>>>> Add upstream backported patches that allows using -mcmodel=large gcc option
>>>> that in order allows fixing build failure due to binutils bug 21464:
>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=21464
>>>>
>>>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
>>>> ---
>>>>  ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>  ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>>>  ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>  ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>  ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>>>  ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>  ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>  ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>>>  ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>  ? ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>  ? ...K_GOT16-overflow-failures-in-presenc.patch |? 61 +++
>>>>  ? ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>  ? 12 files changed, 3268 insertions(+)
>>>>  ? create mode 100644
>>>> package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>  ? create mode 100644
>>>> package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>
>>>
>>>> +?? unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
>>>> +-? unsigned insn4;
>>>> ++? unsigned output_insns[PLT_MAX_INSN_COUNT];
>>>> ++
>>>> ++? /* Copy instructions into the output buffer.? */
>>>> ++? for (size_t i = 0; i < insn_count; i++)
>>>> ++??? output_insns[i] = insns[i];
>>>> +
>>>
>>> This syntax break with good old compilers :)
>>>
>>> elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
>>> C99 or C11 mode
>>>  ??? for (size_t i = 0; i < insn_count; i++)
>>>  ??? ^
>>>
>>> See:
>>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298
>>
>> Thanks for pointing, I didn't think about old host compiler. I'm going to fix it
>> soon by patching actual patches initializing variable at the
>> begin of functions.
> 
> Toolchain-builder use Debian 8 jessie to build the toolchain while Debian 9
> stretch is used to run the Buildroot testsuite.
> 
> See, there is no problem to build the qemu_or1k_defconfig in gitlab using stretch:
> https://gitlab.com/buildroot.org/buildroot/-/jobs/1307293494
> 
> The host gcc used by stretch is gcc 6 while it's gcc 4.9 for jessie, the default
> mode for C is -std=gnu11 since gcc 5:
> https://gcc.gnu.org/gcc-5/changes.html

Here is the patch that fixes that issue [1]

I've tested it on Debian Jessie and it works fine(while before I've 
encountered your same problem).

It's pending upstream[2], this is why I've decided to add a new patch 
instead of modifying the current one.

Does it sound good for you?

[1]: 
https://patchwork.ozlabs.org/project/buildroot/patch/20210609162753.1138390-1-giulio.benetti at benettiengineering.com/

[2]: https://sourceware.org/pipermail/binutils/2021-June/116884.html

Best regards
-- 
Giulio Benetti
Benetti Engineering sas

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

* [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option
  2021-06-09 16:50         ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
@ 2021-06-09 16:57           ` Romain Naour
  0 siblings, 0 replies; 22+ messages in thread
From: Romain Naour @ 2021-06-09 16:57 UTC (permalink / raw)
  To: buildroot

Hello Giulio,

Le 09/06/2021 ? 18:50, Giulio Benetti a ?crit?:
> Hi Romain, All,
> 
> On 6/9/21 8:26 AM, Romain Naour wrote:
>> Hi Giulio,
>>
>> Le 09/06/2021 ? 00:16, Giulio Benetti a ?crit?:
>>> Hi Romain,
>>>
>>> On 6/8/21 11:29 PM, Romain Naour wrote:
>>>> Hi Giulio, All,
>>>>

[...]

>>>>> +?? unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
>>>>> +-? unsigned insn4;
>>>>> ++? unsigned output_insns[PLT_MAX_INSN_COUNT];
>>>>> ++
>>>>> ++? /* Copy instructions into the output buffer.? */
>>>>> ++? for (size_t i = 0; i < insn_count; i++)
>>>>> ++??? output_insns[i] = insns[i];
>>>>> +
>>>>
>>>> This syntax break with good old compilers :)
>>>>
>>>> elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
>>>> C99 or C11 mode
>>>> ???? for (size_t i = 0; i < insn_count; i++)
>>>> ???? ^
>>>>
>>>> See:
>>>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298
>>>
>>> Thanks for pointing, I didn't think about old host compiler. I'm going to fix it
>>> soon by patching actual patches initializing variable at the
>>> begin of functions.
>>
>> Toolchain-builder use Debian 8 jessie to build the toolchain while Debian 9
>> stretch is used to run the Buildroot testsuite.
>>
>> See, there is no problem to build the qemu_or1k_defconfig in gitlab using
>> stretch:
>> https://gitlab.com/buildroot.org/buildroot/-/jobs/1307293494
>>
>> The host gcc used by stretch is gcc 6 while it's gcc 4.9 for jessie, the default
>> mode for C is -std=gnu11 since gcc 5:
>> https://gcc.gnu.org/gcc-5/changes.html
> 
> Here is the patch that fixes that issue [1]
> 
> I've tested it on Debian Jessie and it works fine(while before I've encountered
> your same problem).
> 
> It's pending upstream[2], this is why I've decided to add a new patch instead of
> modifying the current one.
> 
> Does it sound good for you?

It's fine for me, the current patch come from upstream so we should avoid adding
changes.

Thanks!

Best regards,
Romain


> 
> [1]:
> https://patchwork.ozlabs.org/project/buildroot/patch/20210609162753.1138390-1-giulio.benetti at benettiengineering.com/
> 
> 
> [2]: https://sourceware.org/pipermail/binutils/2021-June/116884.html
> 
> Best regards

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

* [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5
  2021-06-09 16:27         ` [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5 Giulio Benetti
@ 2021-06-09 17:10           ` Romain Naour
  2021-07-18 20:35           ` Thomas Petazzoni
  1 sibling, 0 replies; 22+ messages in thread
From: Romain Naour @ 2021-06-09 17:10 UTC (permalink / raw)
  To: buildroot

Hi Giulio,

Le 09/06/2021 ? 18:27, Giulio Benetti a ?crit?:
> Add patches to fix building on hosts that provide gcc version < 5
> (i.e. 4.9), otherwise they fail due to missing default '-std=gnu11' option
> on variable declaration inside for loops.
> 
> The patch is pending upstream:
> https://sourceware.org/pipermail/binutils/2021-June/116884.html
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>

Reviewed-by: Romain Naour <romain.naour@gmail.com>

Best regards,
Romain


> ---
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  4 files changed, 200 insertions(+)
>  create mode 100644 package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> 
> diff --git a/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> new file mode 100644
> index 0000000000..c3978e22fa
> --- /dev/null
> +++ b/package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> @@ -0,0 +1,50 @@
> +From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +Date: Wed, 9 Jun 2021 17:28:27 +0200
> +Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
> +
> +Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
> +an old compiler(i.e. gcc 4.9) build fails on:
> +```
> +elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
> +C99 or C11 mode
> +    for (size_t i = 0; i < insn_count; i++)
> +    ^
> +```
> +
> +So let's declare `size_t i` at the top of the function instead of inside
> +for loop.
> +
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + bfd/elf32-or1k.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
> +index 4ae7f324d33..32063ab0289 100644
> +--- a/bfd/elf32-or1k.c
> ++++ b/bfd/elf32-or1k.c
> +@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> + {
> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
> +   unsigned output_insns[PLT_MAX_INSN_COUNT];
> ++  size_t i;
> + 
> +   /* Copy instructions into the output buffer.  */
> +-  for (size_t i = 0; i < insn_count; i++)
> ++  for (i = 0; i < insn_count; i++)
> +     output_insns[i] = insns[i];
> + 
> +   /* Honor the no-delay-slot setting.  */
> +@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> +     }
> + 
> +   /* Write out the output buffer.  */
> +-  for (size_t i = 0; i < (insn_count+1); i++)
> ++  for (i = 0; i < (insn_count+1); i++)
> +     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
> + }
> + 
> +-- 
> +2.25.1
> +
> diff --git a/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> new file mode 100644
> index 0000000000..c3978e22fa
> --- /dev/null
> +++ b/package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> @@ -0,0 +1,50 @@
> +From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +Date: Wed, 9 Jun 2021 17:28:27 +0200
> +Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
> +
> +Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
> +an old compiler(i.e. gcc 4.9) build fails on:
> +```
> +elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
> +C99 or C11 mode
> +    for (size_t i = 0; i < insn_count; i++)
> +    ^
> +```
> +
> +So let's declare `size_t i` at the top of the function instead of inside
> +for loop.
> +
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + bfd/elf32-or1k.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
> +index 4ae7f324d33..32063ab0289 100644
> +--- a/bfd/elf32-or1k.c
> ++++ b/bfd/elf32-or1k.c
> +@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> + {
> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
> +   unsigned output_insns[PLT_MAX_INSN_COUNT];
> ++  size_t i;
> + 
> +   /* Copy instructions into the output buffer.  */
> +-  for (size_t i = 0; i < insn_count; i++)
> ++  for (i = 0; i < insn_count; i++)
> +     output_insns[i] = insns[i];
> + 
> +   /* Honor the no-delay-slot setting.  */
> +@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> +     }
> + 
> +   /* Write out the output buffer.  */
> +-  for (size_t i = 0; i < (insn_count+1); i++)
> ++  for (i = 0; i < (insn_count+1); i++)
> +     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
> + }
> + 
> +-- 
> +2.25.1
> +
> diff --git a/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> new file mode 100644
> index 0000000000..c3978e22fa
> --- /dev/null
> +++ b/package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> @@ -0,0 +1,50 @@
> +From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +Date: Wed, 9 Jun 2021 17:28:27 +0200
> +Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
> +
> +Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
> +an old compiler(i.e. gcc 4.9) build fails on:
> +```
> +elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
> +C99 or C11 mode
> +    for (size_t i = 0; i < insn_count; i++)
> +    ^
> +```
> +
> +So let's declare `size_t i` at the top of the function instead of inside
> +for loop.
> +
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + bfd/elf32-or1k.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
> +index 4ae7f324d33..32063ab0289 100644
> +--- a/bfd/elf32-or1k.c
> ++++ b/bfd/elf32-or1k.c
> +@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> + {
> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
> +   unsigned output_insns[PLT_MAX_INSN_COUNT];
> ++  size_t i;
> + 
> +   /* Copy instructions into the output buffer.  */
> +-  for (size_t i = 0; i < insn_count; i++)
> ++  for (i = 0; i < insn_count; i++)
> +     output_insns[i] = insns[i];
> + 
> +   /* Honor the no-delay-slot setting.  */
> +@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> +     }
> + 
> +   /* Write out the output buffer.  */
> +-  for (size_t i = 0; i < (insn_count+1); i++)
> ++  for (i = 0; i < (insn_count+1); i++)
> +     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
> + }
> + 
> +-- 
> +2.25.1
> +
> diff --git a/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch b/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> new file mode 100644
> index 0000000000..c3978e22fa
> --- /dev/null
> +++ b/package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
> @@ -0,0 +1,50 @@
> +From c3003947e4bad18faea4337fd2073feeb30ee078 Mon Sep 17 00:00:00 2001
> +From: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +Date: Wed, 9 Jun 2021 17:28:27 +0200
> +Subject: [PATCH] bfd/elf32-or1k: fix building with gcc version < 5
> +
> +Gcc version >= 5 has standard C mode not set to -std=gnu11, so if we use
> +an old compiler(i.e. gcc 4.9) build fails on:
> +```
> +elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
> +C99 or C11 mode
> +    for (size_t i = 0; i < insn_count; i++)
> +    ^
> +```
> +
> +So let's declare `size_t i` at the top of the function instead of inside
> +for loop.
> +
> +Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> +---
> + bfd/elf32-or1k.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
> +index 4ae7f324d33..32063ab0289 100644
> +--- a/bfd/elf32-or1k.c
> ++++ b/bfd/elf32-or1k.c
> +@@ -2244,9 +2244,10 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> + {
> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
> +   unsigned output_insns[PLT_MAX_INSN_COUNT];
> ++  size_t i;
> + 
> +   /* Copy instructions into the output buffer.  */
> +-  for (size_t i = 0; i < insn_count; i++)
> ++  for (i = 0; i < insn_count; i++)
> +     output_insns[i] = insns[i];
> + 
> +   /* Honor the no-delay-slot setting.  */
> +@@ -2277,7 +2278,7 @@ or1k_write_plt_entry (bfd *output_bfd, bfd_byte *contents, unsigned insnj,
> +     }
> + 
> +   /* Write out the output buffer.  */
> +-  for (size_t i = 0; i < (insn_count+1); i++)
> ++  for (i = 0; i < (insn_count+1); i++)
> +     bfd_put_32 (output_bfd, output_insns[i], contents + (i*4));
> + }
> + 
> +-- 
> +2.25.1
> +
> 

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

* [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5
  2021-06-09 16:27         ` [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5 Giulio Benetti
  2021-06-09 17:10           ` Romain Naour
@ 2021-07-18 20:35           ` Thomas Petazzoni
  1 sibling, 0 replies; 22+ messages in thread
From: Thomas Petazzoni @ 2021-07-18 20:35 UTC (permalink / raw)
  To: buildroot

On Wed,  9 Jun 2021 18:27:53 +0200
Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:

> Add patches to fix building on hosts that provide gcc version < 5
> (i.e. 4.9), otherwise they fail due to missing default '-std=gnu11' option
> on variable declaration inside for loops.
> 
> The patch is pending upstream:
> https://sourceware.org/pipermail/binutils/2021-June/116884.html
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> ---
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  ...or1k-fix-building-with-gcc-version-5.patch | 50 +++++++++++++++++++
>  4 files changed, 200 insertions(+)
>  create mode 100644 package/binutils/2.32/0014-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.34/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.35.2/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch
>  create mode 100644 package/binutils/2.36.1/0007-bfd-elf32-or1k-fix-building-with-gcc-version-5.patch

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2021-07-18 20:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 11:13 [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 1/9] package/binutils: update or1k patches for plt link version with upstream Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
2021-06-08 21:29   ` Romain Naour
2021-06-08 22:16     ` Giulio Benetti
2021-06-09  6:26       ` Romain Naour
2021-06-09 16:27         ` [Buildroot] [PATCH] package/binutils: fix building or1k with host gcc version < 5 Giulio Benetti
2021-06-09 17:10           ` Romain Naour
2021-07-18 20:35           ` Thomas Petazzoni
2021-06-09 16:50         ` [Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option Giulio Benetti
2021-06-09 16:57           ` Romain Naour
2021-05-03 11:13 ` [Buildroot] [PATCH 3/9] package/gcc: add upstream patches that introduce -mcmodel=large option for or1k Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 4/9] package/libgeos: fix build failure due to missing -mcmodel=large Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 5/9] package/protobuf: " Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 6/9] toolchain: remove binutils bug 21464 Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 7/9] package/libgeos: remove binutils bug 21464 dependency Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 8/9] package/postgis: remove libgeos binutils bug 21464 inheritance Giulio Benetti
2021-05-03 11:13 ` [Buildroot] [PATCH 9/9] package/protobuf: remove binutils bug 21464 dependency Giulio Benetti
2021-05-21  8:46 ` [Buildroot] [PATCH 0/9] Fix binutils bug 21464 and remove it Arnout Vandecappelle
2021-05-21 14:21   ` Giulio Benetti
2021-05-21 21:26     ` Yann E. MORIN
2021-05-21 21:28       ` Giulio Benetti

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.