+++ /dev/null
-From 745dae5923aba02982563481d75a21595df22ff8 Mon Sep 17 00:00:00 2001
-From: Tamar Christina <tamar.christina@arm.com>
-Date: Fri, 21 May 2021 10:30:59 +0100
-Subject: [PATCH] libsanitizer: Remove cyclades from libsanitizer
-
-The Linux kernel has removed the interface to cyclades from
-the latest kernel headers[1] due to them being orphaned for the
-past 13 years.
-
-libsanitizer uses this header when compiling against glibc, but
-glibcs itself doesn't seem to have any references to cyclades.
-
-Further more it seems that the driver is broken in the kernel and
-the firmware doesn't seem to be available anymore.
-
-As such since this is breaking the build of libsanitizer (and so the
-GCC bootstrap[2]) I propose to remove this.
-
-[1] https://lkml.org/lkml/2021/3/2/153
-[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100379
-
-(cherry picked from commit f7c5351552387bd43f6ca3631016d7f0dfe0f135)
-
-libsanitizer/ChangeLog:
-
- PR sanitizer/100379
- * sanitizer_common/sanitizer_common_interceptors_ioctl.inc: Cherry-pick
- llvm-project revision f7c5351552387bd43f6ca3631016d7f0dfe0f135.
- * sanitizer_common/sanitizer_platform_limits_posix.cpp: Likewise.
- * sanitizer_common/sanitizer_platform_limits_posix.h: Likewise.
-
-Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
----
- .../sanitizer_common_interceptors_ioctl.inc | 9 ---------
- .../sanitizer_platform_limits_posix.cpp | 11 -----------
- .../sanitizer_platform_limits_posix.h | 10 ----------
- 3 files changed, 30 deletions(-)
-
-diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-index 7f181258eab..b7da6598755 100644
---- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-@@ -370,15 +370,6 @@ static void ioctl_table_fill() {
-
- #if SANITIZER_GLIBC
- // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
-- _(CYGETDEFTHRESH, WRITE, sizeof(int));
-- _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
-- _(CYGETMON, WRITE, struct_cyclades_monitor_sz);
-- _(CYGETTHRESH, WRITE, sizeof(int));
-- _(CYGETTIMEOUT, WRITE, sizeof(int));
-- _(CYSETDEFTHRESH, NONE, 0);
-- _(CYSETDEFTIMEOUT, NONE, 0);
-- _(CYSETTHRESH, NONE, 0);
-- _(CYSETTIMEOUT, NONE, 0);
- _(EQL_EMANCIPATE, WRITE, struct_ifreq_sz);
- _(EQL_ENSLAVE, WRITE, struct_ifreq_sz);
- _(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz);
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-index 35a690cba5c..6e5c330b98e 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-@@ -143,7 +143,6 @@ typedef struct user_fpregs elf_fpregset_t;
- # include <sys/procfs.h>
- #endif
- #include <sys/user.h>
--#include <linux/cyclades.h>
- #include <linux/if_eql.h>
- #include <linux/if_plip.h>
- #include <linux/lp.h>
-@@ -460,7 +459,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-
- #if SANITIZER_GLIBC
- unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
-- unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
- #if EV_VERSION > (0x010000)
- unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
- #else
-@@ -824,15 +822,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
- #endif // SANITIZER_LINUX
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
-- unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
-- unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
-- unsigned IOCTL_CYGETMON = CYGETMON;
-- unsigned IOCTL_CYGETTHRESH = CYGETTHRESH;
-- unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT;
-- unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH;
-- unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
-- unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
-- unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
- unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
- unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
- unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-index ad358eef8b7..cba41ba5494 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-@@ -983,7 +983,6 @@ extern unsigned struct_vt_mode_sz;
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- extern unsigned struct_ax25_parms_struct_sz;
--extern unsigned struct_cyclades_monitor_sz;
- extern unsigned struct_input_keymap_entry_sz;
- extern unsigned struct_ipx_config_data_sz;
- extern unsigned struct_kbdiacrs_sz;
-@@ -1328,15 +1327,6 @@ extern unsigned IOCTL_VT_WAITACTIVE;
- #endif // SANITIZER_LINUX
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
--extern unsigned IOCTL_CYGETDEFTHRESH;
--extern unsigned IOCTL_CYGETDEFTIMEOUT;
--extern unsigned IOCTL_CYGETMON;
--extern unsigned IOCTL_CYGETTHRESH;
--extern unsigned IOCTL_CYGETTIMEOUT;
--extern unsigned IOCTL_CYSETDEFTHRESH;
--extern unsigned IOCTL_CYSETDEFTIMEOUT;
--extern unsigned IOCTL_CYSETTHRESH;
--extern unsigned IOCTL_CYSETTIMEOUT;
- extern unsigned IOCTL_EQL_EMANCIPATE;
- extern unsigned IOCTL_EQL_ENSLAVE;
- extern unsigned IOCTL_EQL_GETMASTRCFG;
---
-2.27.0
-
+++ /dev/null
-From eff8110674ef193481d3657456a262beeb9951ff Mon Sep 17 00:00:00 2001
-From: Stafford Horne <shorne@gmail.com>
-Date: Tue, 6 Apr 2021 05:47:17 +0900
-Subject: [PATCH] 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 target/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.texi (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 e772a7addea..27d3fa17995 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 fe01ab81ead..669907e7e74 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 \
-@@ -37,6 +39,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 6bd0f3eee6d..cc23e3b8856 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 57b97a0838c..d8a6b0b60c9 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -1141,7 +1141,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
-@@ -26684,6 +26685,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.
-
-+@item -mcmodel=small
-+@opindex mcmodel=small
-+Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
-+the default model.
-+
-+@item -mcmodel=large
-+@opindex mcmodel=large
-+Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
-+
-
- @end table
-
---
-2.25.1
-
+++ /dev/null
-From da8a9d695b3c4b9397b5d9a27660bfa48af8d707 Mon Sep 17 00:00:00 2001
-From: Stafford Horne <shorne@gmail.com>
-Date: Wed, 21 Apr 2021 05:33:15 +0900
-Subject: [PATCH] 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 target/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 50f00062232..8ca7a00082a 100644
---- a/libgcc/config.host
-+++ b/libgcc/config.host
-@@ -1119,12 +1119,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
-
--- /dev/null
+From eff8110674ef193481d3657456a262beeb9951ff Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Tue, 6 Apr 2021 05:47:17 +0900
+Subject: [PATCH] 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 target/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.texi (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 e772a7addea..27d3fa17995 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 fe01ab81ead..669907e7e74 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 \
+@@ -37,6 +39,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 6bd0f3eee6d..cc23e3b8856 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 57b97a0838c..d8a6b0b60c9 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -1141,7 +1141,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
+@@ -26684,6 +26685,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.
+
++@item -mcmodel=small
++@opindex mcmodel=small
++Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
++the default model.
++
++@item -mcmodel=large
++@opindex mcmodel=large
++Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
++
+
+ @end table
+
+--
+2.25.1
+
--- /dev/null
+From da8a9d695b3c4b9397b5d9a27660bfa48af8d707 Mon Sep 17 00:00:00 2001
+From: Stafford Horne <shorne@gmail.com>
+Date: Wed, 21 Apr 2021 05:33:15 +0900
+Subject: [PATCH] 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 target/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 50f00062232..8ca7a00082a 100644
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -1119,12 +1119,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
+
default "8.4.0" if BR2_GCC_VERSION_POWERPC_SPE
default "9.4.0" if BR2_GCC_VERSION_9_X
default "10.3.0" if BR2_GCC_VERSION_10_X
- default "11.1.0" if BR2_GCC_VERSION_11_X
+ default "11.2.0" if BR2_GCC_VERSION_11_X
default "arc-2020.09-release" if BR2_GCC_VERSION_ARC
default "48152afb96c59733d5bc79e3399bb7b3d4b44266" if BR2_GCC_VERSION_CSKY
sha512 dfd3500bf21784b8351a522d53463cf362ede66b0bc302edf350bb44e94418497a8b4b797b6af8ca9b2eeb746b3b115d9c3698381b989546e9151b4496415624 gcc-9.4.0.tar.xz
# From ftp://gcc.gnu.org/pub/gcc/releases/gcc-10.3.0/sha512.sum
sha512 2b2dd7453d48a398c29eaebd1422b70341001b8c90a62aee51e83344e7fdd8a8e45f82a4a9165bd7edc76dada912c932f4b6632c5636760fec4c5d7e402b3f86 gcc-10.3.0.tar.xz
-# From ftp://gcc.gnu.org/pub/gcc/releases/gcc-11.1.0/sha512.sum
-sha512 fd6bba0f67ff48069d03073d1a9b5e896383b1cfc9dde008e868e60a9ec5014a837d56af0ecbf467b3fb9b37ec74a676e819a18b44393a0a3c4280175b5d7ad8 gcc-11.1.0.tar.xz
+# From ftp://gcc.gnu.org/pub/gcc/releases/gcc-11.2.0/sha512.sum
+sha512 d53a0a966230895c54f01aea38696f818817b505f1e2bfa65e508753fcd01b2aedb4a61434f41f3a2ddbbd9f41384b96153c684ded3f0fa97c82758d9de5c7cf gcc-11.2.0.tar.xz
# Locally calculated (fetched from Github)
sha512 b0853e2b1c5998044392023fa653e399e74118c46e616504ac59e1a2cf27620f94434767ce06b6cf4ca3dfb57f81d6eda92752befaf095ea5e564a9181b4659c gcc-arc-2020.09-release.tar.gz