summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-9.5
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-9.5')
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch42
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0002-gcc-poison-system-directories.patch203
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0002-libstdc-Fix-inconsistent-noexcept-specific-for-valar.patch44
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch73
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0004-64-bit-multilib-hack.patch119
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0005-optional-libstdc.patch125
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0006-COLLECT_GCC_OPTIONS.patch38
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch96
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0008-fortran-cross-compile-hack.patch46
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0009-cpp-honor-sysroot.patch54
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0010-MIPS64-Default-to-N64-ABI.patch57
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch246
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0012-gcc-Fix-argument-list-too-long-error.patch44
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0013-Disable-sdt.patch113
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0014-libtool.patch42
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch43
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch102
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0018-export-CPP.patch53
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0019-Ensure-target-gcc-headers-can-be-included.patch60
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0020-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch54
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0021-Don-t-search-host-directory-during-relink-if-inst_pr.patch38
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0022-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch29
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0023-aarch64-Add-support-for-musl-ldso.patch28
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0024-libcc1-fix-libcc1-s-install-path-and-rpath.patch54
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch346
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0026-Search-target-sysroot-gcc-version-specific-dirs-with.patch102
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0027-Fix-various-_FOR_BUILD-and-related-variables.patch137
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0028-nios2-Define-MUSL_DYNAMIC_LINKER.patch28
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0029-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch87
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0030-ldbl128-config.patch79
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0031-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch29
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0032-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch86
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0033-sync-gcc-stddef.h-with-musl.patch91
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0034-fix-segmentation-fault-in-precompiled-header-generat.patch60
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0035-Fix-for-testsuite-failure.patch258
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0036-Re-introduce-spe-commandline-options.patch41
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0037-CVE-2019-14250-Check-zero-value-in-simple_object_elf.patch48
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0038-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch185
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/0039-process_alt_operands-Don-t-match-user-defined-regs-o.patch100
-rw-r--r--meta/recipes-devtools/gcc/gcc-9.5/CVE-2023-4039.patch1506
41 files changed, 5017 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc-9.5/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
new file mode 100644
index 0000000000..0d9222df17
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
@@ -0,0 +1,42 @@
1From 02b1789dbbb184726782b5038a4dd96515ec790c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 08:37:11 +0400
4Subject: [PATCH 01/39] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Upstream-Status: Inappropriate [embedded specific]
9---
10 configure | 2 +-
11 configure.ac | 2 +-
12 2 files changed, 2 insertions(+), 2 deletions(-)
13
14diff --git a/configure b/configure
15index abd93a990a9..b121088d778 100755
16--- a/configure
17+++ b/configure
18@@ -7603,7 +7603,7 @@ fi
19 # for target_alias and gcc doesn't manage it consistently.
20 target_configargs="--cache-file=./config.cache ${target_configargs}"
21
22-FLAGS_FOR_TARGET=
23+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET"
24 case " $target_configdirs " in
25 *" newlib "*)
26 case " $target_configargs " in
27diff --git a/configure.ac b/configure.ac
28index 9db4fd14aa2..aad93c4d183 100644
29--- a/configure.ac
30+++ b/configure.ac
31@@ -3119,7 +3119,7 @@ fi
32 # for target_alias and gcc doesn't manage it consistently.
33 target_configargs="--cache-file=./config.cache ${target_configargs}"
34
35-FLAGS_FOR_TARGET=
36+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET"
37 case " $target_configdirs " in
38 *" newlib "*)
39 case " $target_configargs " in
40--
412.25.1
42
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0002-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc-9.5/0002-gcc-poison-system-directories.patch
new file mode 100644
index 0000000000..f427ee67c1
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0002-gcc-poison-system-directories.patch
@@ -0,0 +1,203 @@
1From 5368cd0293ce50a69ced6e4b25ba6c8d8e014256 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 08:59:00 +0400
4Subject: [PATCH 02/39] gcc: poison-system-directories
5
6Add /sw/include and /opt/include based on the original
7zecke-no-host-includes.patch patch. The original patch checked for
8/usr/include, /sw/include and /opt/include and then triggered a failure and
9aborted.
10
11Instead, we add the two missing items to the current scan. If the user
12wants this to be a failure, they can add "-Werror=poison-system-directories".
13
14Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16
17Upstream-Status: Pending
18---
19 gcc/common.opt | 4 ++++
20 gcc/config.in | 6 ++++++
21 gcc/configure | 16 ++++++++++++++++
22 gcc/configure.ac | 10 ++++++++++
23 gcc/doc/invoke.texi | 9 +++++++++
24 gcc/gcc.c | 2 ++
25 gcc/incpath.c | 21 +++++++++++++++++++++
26 7 files changed, 68 insertions(+)
27
28diff --git a/gcc/common.opt b/gcc/common.opt
29index d342c4f3749..c64fd4a6c50 100644
30--- a/gcc/common.opt
31+++ b/gcc/common.opt
32@@ -684,6 +684,10 @@ Wreturn-local-addr
33 Common Var(warn_return_local_addr) Init(1) Warning
34 Warn about returning a pointer/reference to a local or temporary variable.
35
36+Wpoison-system-directories
37+Common Var(flag_poison_system_directories) Init(1) Warning
38+Warn for -I and -L options using system directories if cross compiling
39+
40 Wshadow
41 Common Var(warn_shadow) Warning
42 Warn when one variable shadows another. Same as -Wshadow=global.
43diff --git a/gcc/config.in b/gcc/config.in
44index a718ceaf3da..5713342efb1 100644
45--- a/gcc/config.in
46+++ b/gcc/config.in
47@@ -200,6 +200,12 @@
48 #endif
49
50
51+/* Define to warn for use of native system header directories */
52+#ifndef USED_FOR_TARGET
53+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
54+#endif
55+
56+
57 /* Define if you want all operations on RTL (the basic data structure of the
58 optimizer and back end) to be checked for dynamic type safety at runtime.
59 This is quite expensive. */
60diff --git a/gcc/configure b/gcc/configure
61index a065ba23728..2e26dd33310 100755
62--- a/gcc/configure
63+++ b/gcc/configure
64@@ -996,6 +996,7 @@ with_system_zlib
65 enable_maintainer_mode
66 enable_link_mutex
67 enable_version_specific_runtime_libs
68+enable_poison_system_directories
69 enable_plugin
70 enable_host_shared
71 enable_libquadmath_support
72@@ -1749,6 +1750,8 @@ Optional Features:
73 --enable-version-specific-runtime-libs
74 specify that runtime libraries should be installed
75 in a compiler-specific directory
76+ --enable-poison-system-directories
77+ warn for use of native system header directories
78 --enable-plugin enable plugin support
79 --enable-host-shared build host code as shared libraries
80 --disable-libquadmath-support
81@@ -29753,6 +29756,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
82 fi
83
84
85+# Check whether --enable-poison-system-directories was given.
86+if test "${enable_poison_system_directories+set}" = set; then :
87+ enableval=$enable_poison_system_directories;
88+else
89+ enable_poison_system_directories=no
90+fi
91+
92+if test "x${enable_poison_system_directories}" = "xyes"; then
93+
94+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
95+
96+fi
97+
98 # Substitute configuration variables
99
100
101diff --git a/gcc/configure.ac b/gcc/configure.ac
102index 3a7251102ef..12d1d04e645 100644
103--- a/gcc/configure.ac
104+++ b/gcc/configure.ac
105@@ -6380,6 +6380,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
106 [specify that runtime libraries should be
107 installed in a compiler-specific directory])])
108
109+AC_ARG_ENABLE([poison-system-directories],
110+ AS_HELP_STRING([--enable-poison-system-directories],
111+ [warn for use of native system header directories]),,
112+ [enable_poison_system_directories=no])
113+if test "x${enable_poison_system_directories}" = "xyes"; then
114+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
115+ [1],
116+ [Define to warn for use of native system header directories])
117+fi
118+
119 # Substitute configuration variables
120 AC_SUBST(subdirs)
121 AC_SUBST(srcdir)
122diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
123index 0ab6c9c6449..c3d3d51a28f 100644
124--- a/gcc/doc/invoke.texi
125+++ b/gcc/doc/invoke.texi
126@@ -333,6 +333,7 @@ Objective-C and Objective-C++ Dialects}.
127 -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
128 -Wparentheses -Wno-pedantic-ms-format @gol
129 -Wplacement-new -Wplacement-new=@var{n} @gol
130+-Wno-poison-system-directories @gol
131 -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol
132 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
133 -Wrestrict -Wno-return-local-addr @gol
134@@ -6290,6 +6291,14 @@ made up of data only and thus requires no special treatment. But, for
135 most targets, it is made up of code and thus requires the stack to be
136 made executable in order for the program to work properly.
137
138+@item -Wno-poison-system-directories
139+@opindex Wno-poison-system-directories
140+Do not warn for @option{-I} or @option{-L} options using system
141+directories such as @file{/usr/include} when cross compiling. This
142+option is intended for use in chroot environments when such
143+directories contain the correct headers and libraries for the target
144+system rather than the host.
145+
146 @item -Wfloat-equal
147 @opindex Wfloat-equal
148 @opindex Wno-float-equal
149diff --git a/gcc/gcc.c b/gcc/gcc.c
150index 4f57765b012..a2601a6bb06 100644
151--- a/gcc/gcc.c
152+++ b/gcc/gcc.c
153@@ -1042,6 +1042,8 @@ proper position among the other output files. */
154 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
155 "%X %{o*} %{e*} %{N} %{n} %{r}\
156 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
157+ %{Wno-poison-system-directories:--no-poison-system-directories} \
158+ %{Werror=poison-system-directories:--error-poison-system-directories} \
159 %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
160 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
161 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
162diff --git a/gcc/incpath.c b/gcc/incpath.c
163index bcbe2082905..5752298bbf2 100644
164--- a/gcc/incpath.c
165+++ b/gcc/incpath.c
166@@ -26,6 +26,7 @@
167 #include "intl.h"
168 #include "incpath.h"
169 #include "cppdefault.h"
170+#include "diagnostic-core.h"
171
172 /* Microsoft Windows does not natively support inodes.
173 VMS has non-numeric inodes. */
174@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
175 }
176 fprintf (stderr, _("End of search list.\n"));
177 }
178+
179+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
180+ if (flag_poison_system_directories)
181+ {
182+ struct cpp_dir *p;
183+
184+ for (p = heads[INC_QUOTE]; p; p = p->next)
185+ {
186+ if ((!strncmp (p->name, "/usr/include", 12))
187+ || (!strncmp (p->name, "/usr/local/include", 18))
188+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
189+ || (!strncmp (p->name, "/sw/include", 11))
190+ || (!strncmp (p->name, "/opt/include", 12)))
191+ warning (OPT_Wpoison_system_directories,
192+ "include location \"%s\" is unsafe for "
193+ "cross-compilation",
194+ p->name);
195+ }
196+ }
197+#endif
198 }
199
200 /* Use given -I paths for #include "..." but not #include <...>, and
201--
2022.25.1
203
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0002-libstdc-Fix-inconsistent-noexcept-specific-for-valar.patch b/meta/recipes-devtools/gcc/gcc-9.5/0002-libstdc-Fix-inconsistent-noexcept-specific-for-valar.patch
new file mode 100644
index 0000000000..506064bfc2
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0002-libstdc-Fix-inconsistent-noexcept-specific-for-valar.patch
@@ -0,0 +1,44 @@
1From 60d966708d7cf105dccf128d2b7a38b0b2580a1a Mon Sep 17 00:00:00 2001
2From: Jonathan Wakely <jwakely@redhat.com>
3Date: Fri, 5 Nov 2021 21:42:20 +0000
4Subject: [PATCH] libstdc++: Fix inconsistent noexcept-specific for valarray
5 begin/end
6
7These declarations should be noexcept after I added it to the
8definitions in <valarray>.
9
10libstdc++-v3/ChangeLog:
11
12 * include/bits/range_access.h (begin(valarray), end(valarray)):
13 Add noexcept.
14
15(cherry picked from commit 2b2d97fc545635a0f6aa9c9ee3b017394bc494bf)
16
17Upstream-Status: Backport [https://github.com/hkaelber/gcc/commit/2b2d97fc545635a0f6aa9c9ee3b017394bc494bf]
18Signed-off-by: Virendra Thakur <virendrak@kpit.com>
19
20---
21 libstdc++-v3/include/bits/range_access.h | 8 ++++----
22 1 file changed, 4 insertions(+), 4 deletions(-)
23
24diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
25index 3d99ea92027..4736e75fda1 100644
26--- a/libstdc++-v3/include/bits/range_access.h
27+++ b/libstdc++-v3/include/bits/range_access.h
28@@ -101,10 +101,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
29
30 template<typename _Tp> class valarray;
31 // These overloads must be declared for cbegin and cend to use them.
32- template<typename _Tp> _Tp* begin(valarray<_Tp>&);
33- template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
34- template<typename _Tp> _Tp* end(valarray<_Tp>&);
35- template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
36+ template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
37+ template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
38+ template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
39+ template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
40
41 /**
42 * @brief Return an iterator pointing to the first element of
43--
442.25.1 \ No newline at end of file
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc-9.5/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
new file mode 100644
index 0000000000..23ec5bce03
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
@@ -0,0 +1,73 @@
1From df90dbdba7a85c20bad95de71525f0f400a849d2 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:08:31 +0400
4Subject: [PATCH 03/39] gcc-4.3.3: SYSROOT_CFLAGS_FOR_TARGET
5
6Before committing, I noticed that PR/32161 was marked as a dup of PR/32009, but my previous patch did not fix it.
7
8This alternative patch is better because it lets you just use CFLAGS_FOR_TARGET to set the compilation flags for libgcc. Since bootstrapped target libraries are never compiled with the native compiler, it makes little sense to use different flags for stage1 and later stages. And it also makes little sense to use a different variable than CFLAGS_FOR_TARGET.
9
10Other changes I had to do include:
11
12- moving the creation of default CFLAGS_FOR_TARGET from Makefile.am to configure.ac, because otherwise the BOOT_CFLAGS are substituted into CFLAGS_FOR_TARGET (which is "-O2 -g $(CFLAGS)") via $(CFLAGS). It is also cleaner this way though.
13
14- passing the right CFLAGS to configure scripts as exported environment variables
15
16I also stopped passing LIBCFLAGS to configure scripts since they are unused in the whole src tree. And I updated the documentation as H-P reminded me to do.
17
18Bootstrapped/regtested i686-pc-linux-gnu, will commit to 4.4 shortly. Ok for 4.3?
19
20Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
21Signed-off-by: Khem Raj <raj.khem@gmail.com>
22
23Upstream-Status: Pending
24---
25 configure | 32 ++++++++++++++++++++++++++++++++
26 1 file changed, 32 insertions(+)
27
28diff --git a/configure b/configure
29index b121088d778..93aae5bb26f 100755
30--- a/configure
31+++ b/configure
32@@ -6864,6 +6864,38 @@ fi
33
34
35
36+# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
37+# might be empty or "-g". We don't require a C++ compiler, so CXXFLAGS
38+# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
39+# We want to ensure that TARGET libraries (which we know are built with
40+# gcc) are built with "-O2 -g", so include those options when setting
41+# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
42+if test "x$CFLAGS_FOR_TARGET" = x; then
43+ CFLAGS_FOR_TARGET=$CFLAGS
44+ case " $CFLAGS " in
45+ *" -O2 "*) ;;
46+ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
47+ esac
48+ case " $CFLAGS " in
49+ *" -g "* | *" -g3 "*) ;;
50+ *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
51+ esac
52+fi
53+
54+
55+if test "x$CXXFLAGS_FOR_TARGET" = x; then
56+ CXXFLAGS_FOR_TARGET=$CXXFLAGS
57+ case " $CXXFLAGS " in
58+ *" -O2 "*) ;;
59+ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
60+ esac
61+ case " $CXXFLAGS " in
62+ *" -g "* | *" -g3 "*) ;;
63+ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
64+ esac
65+fi
66+
67+
68 # Handle --with-headers=XXX. If the value is not "yes", the contents of
69 # the named directory are copied to $(tooldir)/sys-include.
70 if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
71--
722.25.1
73
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0004-64-bit-multilib-hack.patch b/meta/recipes-devtools/gcc/gcc-9.5/0004-64-bit-multilib-hack.patch
new file mode 100644
index 0000000000..17ec8986c1
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0004-64-bit-multilib-hack.patch
@@ -0,0 +1,119 @@
1From 2e00d0a9a809153f693659e977c1e0550665e65c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:10:06 +0400
4Subject: [PATCH 04/39] 64-bit multilib hack.
5
6GCC has internal multilib handling code but it assumes a very specific rigid directory
7layout. The build system implementation of multilib layout is very generic and allows
8complete customisation of the library directories.
9
10This patch is a partial solution to allow any custom directories to be passed into gcc
11and handled correctly. It forces gcc to use the base_libdir (which is the current
12directory, "."). We need to do this for each multilib that is configured as we don't
13know which compiler options may be being passed into the compiler. Since we have a compiler
14per mulitlib at this point that isn't an issue.
15
16The one problem is the target compiler is only going to work for the default multlilib at
17this point. Ideally we'd figure out which multilibs were being enabled with which paths
18and be able to patch these entries with a complete set of correct paths but this we
19don't have such code at this point. This is something the target gcc recipe should do
20and override these platform defaults in its build config.
21
22Do same for riscv64 and aarch64
23
24RP 15/8/11
25
26Upstream-Status: Inappropriate[OE-Specific]
27
28Signed-off-by: Khem Raj <raj.khem@gmail.com>
29Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
30Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
31---
32 gcc/config/aarch64/t-aarch64-linux | 8 ++++----
33 gcc/config/i386/t-linux64 | 6 ++----
34 gcc/config/mips/t-linux64 | 10 +++-------
35 gcc/config/riscv/t-linux | 6 ++++--
36 gcc/config/rs6000/t-linux64 | 5 ++---
37 5 files changed, 15 insertions(+), 20 deletions(-)
38
39diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux
40index 5ad670ba2ce..e26019e7157 100644
41--- a/gcc/config/aarch64/t-aarch64-linux
42+++ b/gcc/config/aarch64/t-aarch64-linux
43@@ -21,8 +21,8 @@
44 LIB1ASMSRC = aarch64/lib1funcs.asm
45 LIB1ASMFUNCS = _aarch64_sync_cache_range
46
47-AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
48-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
49-MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
50+#AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
51+#MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
52+#MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
53
54-MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
55+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
56diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
57index c686ab2f0d2..c82b60dadcd 100644
58--- a/gcc/config/i386/t-linux64
59+++ b/gcc/config/i386/t-linux64
60@@ -32,7 +32,5 @@
61 #
62 comma=,
63 MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
64-MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
65-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
66-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
67-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
68+MULTILIB_DIRNAMES = . .
69+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
70diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64
71index 3a2ff700d7d..13ef19576b5 100644
72--- a/gcc/config/mips/t-linux64
73+++ b/gcc/config/mips/t-linux64
74@@ -17,10 +17,6 @@
75 # <http://www.gnu.org/licenses/>.
76
77 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
78-MULTILIB_DIRNAMES = n32 32 64
79-MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
80-MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
81-MULTILIB_OSDIRNAMES = \
82- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
83- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
84- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
85+MULTILIB_DIRNAMES = . . .
86+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
87+
88diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
89index 216d2776a18..e4d817621fc 100644
90--- a/gcc/config/riscv/t-linux
91+++ b/gcc/config/riscv/t-linux
92@@ -1,3 +1,5 @@
93 # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
94-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
95-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
96+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
97+MULTILIB_DIRNAMES := . .
98+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
99+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
100diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64
101index f3c6e2be1d9..bd0393155fa 100644
102--- a/gcc/config/rs6000/t-linux64
103+++ b/gcc/config/rs6000/t-linux64
104@@ -26,10 +26,9 @@
105 # MULTILIB_OSDIRNAMES according to what is found on the target.
106
107 MULTILIB_OPTIONS := m64/m32
108-MULTILIB_DIRNAMES := 64 32
109+MULTILIB_DIRNAMES := . .
110 MULTILIB_EXTRA_OPTS :=
111-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
112-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
113+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
114
115 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
116 $(COMPILE) $<
117--
1182.25.1
119
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0005-optional-libstdc.patch b/meta/recipes-devtools/gcc/gcc-9.5/0005-optional-libstdc.patch
new file mode 100644
index 0000000000..3c28aeac63
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0005-optional-libstdc.patch
@@ -0,0 +1,125 @@
1From 435e45592e944018f33bff32f1202b0872a23141 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:12:56 +0400
4Subject: [PATCH 05/39] optional libstdc
5
6gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++
7will not run correctly since by default the linker will try to link against libstdc++
8which shouldn't exist yet. We need an option to disable -lstdc++
9option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc
10driver. This patch adds such an option which only disables the -lstdc++.
11
12A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to
13do this officially, the likely answer is don't build libstdc++ separately.
14
15RP 29/6/10
16
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18
19Upstream-Status: Inappropriate [embedded specific]
20---
21 gcc/c-family/c.opt | 4 ++++
22 gcc/cp/g++spec.c | 1 +
23 gcc/doc/invoke.texi | 32 +++++++++++++++++++++++++++++++-
24 gcc/gcc.c | 1 +
25 4 files changed, 37 insertions(+), 1 deletion(-)
26
27diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
28index 916cc67b453..41619fa591c 100644
29--- a/gcc/c-family/c.opt
30+++ b/gcc/c-family/c.opt
31@@ -1952,6 +1952,10 @@ nostdinc++
32 C++ ObjC++
33 Do not search standard system include directories for C++.
34
35+nostdlib++
36+Driver
37+Do not link standard C++ runtime library
38+
39 o
40 C ObjC C++ ObjC++ Joined Separate
41 ; Documented in common.opt
42diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
43index 6c4574a837d..0e2657f00ee 100644
44--- a/gcc/cp/g++spec.c
45+++ b/gcc/cp/g++spec.c
46@@ -137,6 +137,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
47 switch (decoded_options[i].opt_index)
48 {
49 case OPT_nostdlib:
50+ case OPT_nostdlib__:
51 case OPT_nodefaultlibs:
52 library = -1;
53 break;
54diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
55index c3d3d51a28f..2f7ffe456c3 100644
56--- a/gcc/doc/invoke.texi
57+++ b/gcc/doc/invoke.texi
58@@ -228,6 +228,9 @@ in the following sections.
59 -fno-weak -nostdinc++ @gol
60 -fvisibility-inlines-hidden @gol
61 -fvisibility-ms-compat @gol
62+-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
63+-fvtv-counts -fvtv-debug @gol
64+-nostdlib++ @gol
65 -fext-numeric-literals @gol
66 -Wabi=@var{n} -Wabi-tag -Wconversion-null -Wctor-dtor-privacy @gol
67 -Wdelete-non-virtual-dtor -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
68@@ -539,7 +542,7 @@ Objective-C and Objective-C++ Dialects}.
69 -pie -pthread -r -rdynamic @gol
70 -s -static -static-pie -static-libgcc -static-libstdc++ @gol
71 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
72--shared -shared-libgcc -symbolic @gol
73+-shared -shared-libgcc -symbolic -nostdlib++ @gol
74 -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
75 -u @var{symbol} -z @var{keyword}}
76
77@@ -13321,6 +13324,33 @@ Specify that the program entry point is @var{entry}. The argument is
78 interpreted by the linker; the GNU linker accepts either a symbol name
79 or an address.
80
81+@item -nostdlib++
82+@opindex nostdlib++
83+Do not use the standard system C++ runtime libraries when linking.
84+Only the libraries you specify will be passed to the linker.
85+
86+@cindex @option{-lgcc}, use with @option{-nostdlib}
87+@cindex @option{-nostdlib} and unresolved references
88+@cindex unresolved references and @option{-nostdlib}
89+@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
90+@cindex @option{-nodefaultlibs} and unresolved references
91+@cindex unresolved references and @option{-nodefaultlibs}
92+One of the standard libraries bypassed by @option{-nostdlib} and
93+@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
94+which GCC uses to overcome shortcomings of particular machines, or special
95+needs for some languages.
96+(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
97+Collection (GCC) Internals},
98+for more discussion of @file{libgcc.a}.)
99+In most cases, you need @file{libgcc.a} even when you want to avoid
100+other standard libraries. In other words, when you specify @option{-nostdlib}
101+or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
102+This ensures that you have no unresolved references to internal GCC
103+library subroutines.
104+(An example of such an internal subroutine is @code{__main}, used to ensure C++
105+constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
106+GNU Compiler Collection (GCC) Internals}.)
107+
108 @item -pie
109 @opindex pie
110 Produce a dynamically linked position independent executable on targets
111diff --git a/gcc/gcc.c b/gcc/gcc.c
112index a2601a6bb06..cd6c6fc95db 100644
113--- a/gcc/gcc.c
114+++ b/gcc/gcc.c
115@@ -1052,6 +1052,7 @@ proper position among the other output files. */
116 %(mflib) " STACK_SPLIT_SPEC "\
117 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \
118 %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\
119+ %{!nostdlib++:}\
120 %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}"
121 #endif
122
123--
1242.25.1
125
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0006-COLLECT_GCC_OPTIONS.patch b/meta/recipes-devtools/gcc/gcc-9.5/0006-COLLECT_GCC_OPTIONS.patch
new file mode 100644
index 0000000000..906f3a7317
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0006-COLLECT_GCC_OPTIONS.patch
@@ -0,0 +1,38 @@
1From c99684477ec66f290ec74efe732acd3c24db7dcc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:16:28 +0400
4Subject: [PATCH 06/39] COLLECT_GCC_OPTIONS
5
6This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to
7invoke collect2.
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10
11Upstream-Status: Pending
12---
13 gcc/gcc.c | 9 +++++++++
14 1 file changed, 9 insertions(+)
15
16diff --git a/gcc/gcc.c b/gcc/gcc.c
17index cd6c6fc95db..7da9c5d457b 100644
18--- a/gcc/gcc.c
19+++ b/gcc/gcc.c
20@@ -4804,6 +4804,15 @@ set_collect_gcc_options (void)
21 sizeof ("COLLECT_GCC_OPTIONS=") - 1);
22
23 first_time = TRUE;
24+#ifdef HAVE_LD_SYSROOT
25+ if (target_system_root_changed && target_system_root)
26+ {
27+ obstack_grow (&collect_obstack, "'--sysroot=", sizeof("'--sysroot=")-1);
28+ obstack_grow (&collect_obstack, target_system_root,strlen(target_system_root));
29+ obstack_grow (&collect_obstack, "'", 1);
30+ first_time = FALSE;
31+ }
32+#endif
33 for (i = 0; (int) i < n_switches; i++)
34 {
35 const char *const *args;
36--
372.25.1
38
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta/recipes-devtools/gcc/gcc-9.5/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
new file mode 100644
index 0000000000..68a876cb95
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
@@ -0,0 +1,96 @@
1From d6f4edaab0ad0e742fb1e3a6f76908a2ac9927d5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:17:25 +0400
4Subject: [PATCH 07/39] Use the defaults.h in ${B} instead of ${S}, and t-oe in
5 ${B}
6
7Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}, so that
8the source can be shared between gcc-cross-initial,
9gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build.
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12
13Upstream-Status: Pending
14
15While compiling gcc-crosssdk-initial-x86_64 on some host, there is
16occasionally failure that test the existance of default.h doesn't
17work, the reason is tm_include_list='** defaults.h' rather than
18tm_include_list='** ./defaults.h'
19
20So we add the test condition for this situation.
21Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
22---
23 gcc/Makefile.in | 2 +-
24 gcc/configure | 4 ++--
25 gcc/configure.ac | 4 ++--
26 gcc/mkconfig.sh | 4 ++--
27 4 files changed, 7 insertions(+), 7 deletions(-)
28
29diff --git a/gcc/Makefile.in b/gcc/Makefile.in
30index abae872cd63..fef6c4c61e3 100644
31--- a/gcc/Makefile.in
32+++ b/gcc/Makefile.in
33@@ -540,7 +540,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
34 TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
35
36 xmake_file=@xmake_file@
37-tmake_file=@tmake_file@
38+tmake_file=@tmake_file@ ./t-oe
39 TM_ENDIAN_CONFIG=@TM_ENDIAN_CONFIG@
40 TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@
41 TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@
42diff --git a/gcc/configure b/gcc/configure
43index 2e26dd33310..ed7931daed3 100755
44--- a/gcc/configure
45+++ b/gcc/configure
46@@ -12342,8 +12342,8 @@ for f in $tm_file; do
47 tm_include_list="${tm_include_list} $f"
48 ;;
49 defaults.h )
50- tm_file_list="${tm_file_list} \$(srcdir)/$f"
51- tm_include_list="${tm_include_list} $f"
52+ tm_file_list="${tm_file_list} ./$f"
53+ tm_include_list="${tm_include_list} ./$f"
54 ;;
55 * )
56 tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
57diff --git a/gcc/configure.ac b/gcc/configure.ac
58index 12d1d04e645..e0500e30d50 100644
59--- a/gcc/configure.ac
60+++ b/gcc/configure.ac
61@@ -1968,8 +1968,8 @@ for f in $tm_file; do
62 tm_include_list="${tm_include_list} $f"
63 ;;
64 defaults.h )
65- tm_file_list="${tm_file_list} \$(srcdir)/$f"
66- tm_include_list="${tm_include_list} $f"
67+ tm_file_list="${tm_file_list} ./$f"
68+ tm_include_list="${tm_include_list} ./$f"
69 ;;
70 * )
71 tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
72diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh
73index 308b87d0cc1..19068cbc24a 100644
74--- a/gcc/mkconfig.sh
75+++ b/gcc/mkconfig.sh
76@@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then
77 if [ $# -ge 1 ]; then
78 echo '#ifdef IN_GCC' >> ${output}T
79 for file in "$@"; do
80- if test x"$file" = x"defaults.h"; then
81+ if test x"$file" = x"./defaults.h" -o x"$file" = x"defaults.h"; then
82 postpone_defaults_h="yes"
83 else
84 echo "# include \"$file\"" >> ${output}T
85@@ -106,7 +106,7 @@ esac
86
87 # If we postponed including defaults.h, add the #include now.
88 if test x"$postpone_defaults_h" = x"yes"; then
89- echo "# include \"defaults.h\"" >> ${output}T
90+ echo "# include \"./defaults.h\"" >> ${output}T
91 fi
92
93 # Add multiple inclusion protection guard, part two.
94--
952.25.1
96
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0008-fortran-cross-compile-hack.patch b/meta/recipes-devtools/gcc/gcc-9.5/0008-fortran-cross-compile-hack.patch
new file mode 100644
index 0000000000..6acd2b0cf9
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0008-fortran-cross-compile-hack.patch
@@ -0,0 +1,46 @@
1From 2c514ada36ffbf70177909f633e9f68811de61e0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:20:01 +0400
4Subject: [PATCH 08/39] fortran cross-compile hack.
5
6* Fortran would have searched for arm-angstrom-gnueabi-gfortran but would have used
7used gfortan. For gcc_4.2.2.bb we want to use the gfortran compiler from our cross
8directory.
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11
12Upstream-Status: Inappropriate [embedded specific]
13---
14 libgfortran/configure | 2 +-
15 libgfortran/configure.ac | 2 +-
16 2 files changed, 2 insertions(+), 2 deletions(-)
17
18diff --git a/libgfortran/configure b/libgfortran/configure
19index 60867b93d0e..3fc9fca5b7b 100755
20--- a/libgfortran/configure
21+++ b/libgfortran/configure
22@@ -13071,7 +13071,7 @@ esac
23
24 # We need gfortran to compile parts of the library
25 #AC_PROG_FC(gfortran)
26-FC="$GFORTRAN"
27+#FC="$GFORTRAN"
28 ac_ext=${ac_fc_srcext-f}
29 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
30 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
31diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
32index 7cfce28ab69..6cd515ee1a4 100644
33--- a/libgfortran/configure.ac
34+++ b/libgfortran/configure.ac
35@@ -250,7 +250,7 @@ AC_SUBST(enable_static)
36
37 # We need gfortran to compile parts of the library
38 #AC_PROG_FC(gfortran)
39-FC="$GFORTRAN"
40+#FC="$GFORTRAN"
41 AC_PROG_FC(gfortran)
42
43 # extra LD Flags which are required for targets
44--
452.25.1
46
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0009-cpp-honor-sysroot.patch b/meta/recipes-devtools/gcc/gcc-9.5/0009-cpp-honor-sysroot.patch
new file mode 100644
index 0000000000..5a9e527606
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0009-cpp-honor-sysroot.patch
@@ -0,0 +1,54 @@
1From 0a7c03a9cf925ba09a510a32e684f01ec5a50650 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:22:00 +0400
4Subject: [PATCH 09/39] cpp: honor sysroot.
5
6Currently, if the gcc toolchain is relocated and installed from sstate, then you try and compile
7preprocessed source (.i or .ii files), the compiler will try and access the builtin sysroot location
8rather than the --sysroot option specified on the commandline. If access to that directory is
9permission denied (unreadable), gcc will error.
10
11This happens when ccache is in use due to the fact it uses preprocessed source files.
12
13The fix below adds %I to the cpp-output spec macro so the default substitutions for -iprefix,
14-isystem, -isysroot happen and the correct sysroot is used.
15
16[YOCTO #2074]
17
18RP 2012/04/13
19
20Signed-off-by: Khem Raj <raj.khem@gmail.com>
21
22Upstream-Status: Pending
23---
24 gcc/cp/lang-specs.h | 2 +-
25 gcc/gcc.c | 2 +-
26 2 files changed, 2 insertions(+), 2 deletions(-)
27
28diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h
29index c6e42eda283..e1ddf066467 100644
30--- a/gcc/cp/lang-specs.h
31+++ b/gcc/cp/lang-specs.h
32@@ -66,5 +66,5 @@ along with GCC; see the file COPYING3. If not see
33 {".ii", "@c++-cpp-output", 0, 0, 0},
34 {"@c++-cpp-output",
35 "%{!E:%{!M:%{!MM:"
36- " cc1plus -fpreprocessed %i %(cc1_options) %2"
37+ " cc1plus -fpreprocessed %i %I %(cc1_options) %2"
38 " %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
39diff --git a/gcc/gcc.c b/gcc/gcc.c
40index 7da9c5d457b..4e7c45b268c 100644
41--- a/gcc/gcc.c
42+++ b/gcc/gcc.c
43@@ -1349,7 +1349,7 @@ static const struct compiler default_compilers[] =
44 %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0},
45 {".i", "@cpp-output", 0, 0, 0},
46 {"@cpp-output",
47- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
48+ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %I %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
49 {".s", "@assembler", 0, 0, 0},
50 {"@assembler",
51 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},
52--
532.25.1
54
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0010-MIPS64-Default-to-N64-ABI.patch b/meta/recipes-devtools/gcc/gcc-9.5/0010-MIPS64-Default-to-N64-ABI.patch
new file mode 100644
index 0000000000..a8103b951e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0010-MIPS64-Default-to-N64-ABI.patch
@@ -0,0 +1,57 @@
1From 374aab6a88200fbd7343467d97f7ee6455bbce61 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:23:08 +0400
4Subject: [PATCH 10/39] MIPS64: Default to N64 ABI
5
6MIPS64 defaults to n32 ABI, this patch makes it
7so that it defaults to N64 ABI
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10
11Upstream-Status: Inappropriate [OE config specific]
12---
13 gcc/config.gcc | 10 +++++-----
14 1 file changed, 5 insertions(+), 5 deletions(-)
15
16diff --git a/gcc/config.gcc b/gcc/config.gcc
17index b2282ecdf0b..69c0e4a005b 100644
18--- a/gcc/config.gcc
19+++ b/gcc/config.gcc
20@@ -2282,29 +2282,29 @@ mips*-*-linux*) # Linux MIPS, either endian.
21 default_mips_arch=mips32
22 ;;
23 mips64el-st-linux-gnu)
24- default_mips_abi=n32
25+ default_mips_abi=64
26 tm_file="${tm_file} mips/st.h"
27 tmake_file="${tmake_file} mips/t-st"
28 enable_mips_multilibs="yes"
29 ;;
30 mips64octeon*-*-linux*)
31- default_mips_abi=n32
32+ default_mips_abi=64
33 tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\""
34 target_cpu_default=MASK_SOFT_FLOAT_ABI
35 enable_mips_multilibs="yes"
36 ;;
37 mipsisa64r6*-*-linux*)
38- default_mips_abi=n32
39+ default_mips_abi=64
40 default_mips_arch=mips64r6
41 enable_mips_multilibs="yes"
42 ;;
43 mipsisa64r2*-*-linux*)
44- default_mips_abi=n32
45+ default_mips_abi=64
46 default_mips_arch=mips64r2
47 enable_mips_multilibs="yes"
48 ;;
49 mips64*-*-linux* | mipsisa64*-*-linux*)
50- default_mips_abi=n32
51+ default_mips_abi=64
52 enable_mips_multilibs="yes"
53 ;;
54 esac
55--
562.25.1
57
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta/recipes-devtools/gcc/gcc-9.5/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
new file mode 100644
index 0000000000..d9d563d0f7
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
@@ -0,0 +1,246 @@
1From dcd7891d6aea5327969132fea6ca4c199f14e985 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:24:50 +0400
4Subject: [PATCH 11/39] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
5 relative to SYSTEMLIBS_DIR
6
7This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
8relative to SYSTEMLIBS_DIR which can be set in generated headers
9This breaks the assumption of hardcoded multilib in gcc
10Change is only for the supported architectures in OE including
11SH, sparc, alpha for possible future support (if any)
12
13Removes the do_headerfix task in metadata
14
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16
17Upstream-Status: Inappropriate [OE configuration]
18---
19 gcc/config/alpha/linux-elf.h | 4 ++--
20 gcc/config/arm/linux-eabi.h | 4 ++--
21 gcc/config/arm/linux-elf.h | 2 +-
22 gcc/config/i386/linux.h | 2 +-
23 gcc/config/i386/linux64.h | 6 +++---
24 gcc/config/linux.h | 8 ++++----
25 gcc/config/mips/linux.h | 12 ++++++------
26 gcc/config/riscv/linux.h | 2 +-
27 gcc/config/rs6000/linux64.h | 15 +++++----------
28 gcc/config/sh/linux.h | 2 +-
29 gcc/config/sparc/linux.h | 2 +-
30 gcc/config/sparc/linux64.h | 4 ++--
31 12 files changed, 29 insertions(+), 34 deletions(-)
32
33diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
34index 824861befec..6afacce3292 100644
35--- a/gcc/config/alpha/linux-elf.h
36+++ b/gcc/config/alpha/linux-elf.h
37@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see
38 #define EXTRA_SPECS \
39 { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
40
41-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
42-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
43+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
44+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0"
45 #if DEFAULT_LIBC == LIBC_UCLIBC
46 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
47 #elif DEFAULT_LIBC == LIBC_GLIBC
48diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
49index 66ec0ea3980..e4ade2e2ab0 100644
50--- a/gcc/config/arm/linux-eabi.h
51+++ b/gcc/config/arm/linux-eabi.h
52@@ -65,8 +65,8 @@
53 GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
54
55 #undef GLIBC_DYNAMIC_LINKER
56-#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
57-#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
58+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT SYSTEMLIBS_DIR "ld-linux.so.3"
59+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT SYSTEMLIBS_DIR "ld-linux-armhf.so.3"
60 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
61
62 #define GLIBC_DYNAMIC_LINKER \
63diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
64index 9a360defd21..98f6e960b64 100644
65--- a/gcc/config/arm/linux-elf.h
66+++ b/gcc/config/arm/linux-elf.h
67@@ -60,7 +60,7 @@
68
69 #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
70
71-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
72+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
73
74 #define LINUX_TARGET_LINK_SPEC "%{h*} \
75 %{static:-Bstatic} \
76diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
77index 9a6e2d99896..31efbb73016 100644
78--- a/gcc/config/i386/linux.h
79+++ b/gcc/config/i386/linux.h
80@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
81 <http://www.gnu.org/licenses/>. */
82
83 #define GNU_USER_LINK_EMULATION "elf_i386"
84-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
85+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
86
87 #undef MUSL_DYNAMIC_LINKER
88 #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
89diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
90index c08221c4210..dbb474d792b 100644
91--- a/gcc/config/i386/linux64.h
92+++ b/gcc/config/i386/linux64.h
93@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
94 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
95 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
96
97-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
98-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
99-#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
100+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
101+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
102+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
103
104 #undef MUSL_DYNAMIC_LINKER32
105 #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
106diff --git a/gcc/config/linux.h b/gcc/config/linux.h
107index c3c4a219e67..4b05d8e93d1 100644
108--- a/gcc/config/linux.h
109+++ b/gcc/config/linux.h
110@@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
111 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
112 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
113 supporting both 32-bit and 64-bit compilation. */
114-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
115-#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
116-#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
117-#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
118+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0"
119+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
120+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
121+#define UCLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ldx32-uClibc.so.0"
122 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
123 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
124 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
125diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
126index 6f79ac9c01a..25de96f9561 100644
127--- a/gcc/config/mips/linux.h
128+++ b/gcc/config/mips/linux.h
129@@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see
130 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
131
132 #define GLIBC_DYNAMIC_LINKER32 \
133- "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
134+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
135 #define GLIBC_DYNAMIC_LINKER64 \
136- "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
137+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
138 #define GLIBC_DYNAMIC_LINKERN32 \
139- "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
140+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
141
142 #undef UCLIBC_DYNAMIC_LINKER32
143 #define UCLIBC_DYNAMIC_LINKER32 \
144- "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
145+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
146 #undef UCLIBC_DYNAMIC_LINKER64
147 #define UCLIBC_DYNAMIC_LINKER64 \
148- "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
149+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld64-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld64-uClibc.so.0}"
150 #define UCLIBC_DYNAMIC_LINKERN32 \
151- "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
152+ "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
153
154 #undef MUSL_DYNAMIC_LINKER32
155 #define MUSL_DYNAMIC_LINKER32 \
156diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
157index 58dd18b89f3..112ba9cd764 100644
158--- a/gcc/config/riscv/linux.h
159+++ b/gcc/config/riscv/linux.h
160@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
161 GNU_USER_TARGET_OS_CPP_BUILTINS(); \
162 } while (0)
163
164-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
165+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
166
167 #define MUSL_ABI_SUFFIX \
168 "%{mabi=ilp32:-sf}" \
169diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
170index 9946d3fed94..45a9a7cae59 100644
171--- a/gcc/config/rs6000/linux64.h
172+++ b/gcc/config/rs6000/linux64.h
173@@ -423,24 +423,19 @@ extern int dot_symbols;
174 #undef LINK_OS_DEFAULT_SPEC
175 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
176
177-#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
178-
179+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
180 #ifdef LINUX64_DEFAULT_ABI_ELFv2
181-#define GLIBC_DYNAMIC_LINKER64 \
182-"%{mabi=elfv1:%(dynamic_linker_prefix)/lib64/ld64.so.1;" \
183-":%(dynamic_linker_prefix)/lib64/ld64.so.2}"
184+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:" SYSTEMLIBS_DIR "ld64.so.1;:" SYSTEMLIBS_DIR "ld64.so.2}"
185 #else
186-#define GLIBC_DYNAMIC_LINKER64 \
187-"%{mabi=elfv2:%(dynamic_linker_prefix)/lib64/ld64.so.2;" \
188-":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
189+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}"
190 #endif
191
192 #undef MUSL_DYNAMIC_LINKER32
193 #define MUSL_DYNAMIC_LINKER32 \
194- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
195+ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
196 #undef MUSL_DYNAMIC_LINKER64
197 #define MUSL_DYNAMIC_LINKER64 \
198- "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
199+ SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
200
201 #undef DEFAULT_ASM_ENDIAN
202 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
203diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
204index c9897b7aca5..82f275319cc 100644
205--- a/gcc/config/sh/linux.h
206+++ b/gcc/config/sh/linux.h
207@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see
208 "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
209 "%{mfdpic:-fdpic}.so.1"
210
211-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
212+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
213
214 #undef SUBTARGET_LINK_EMUL_SUFFIX
215 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
216diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
217index 08476f1d94d..80440e712ad 100644
218--- a/gcc/config/sparc/linux.h
219+++ b/gcc/config/sparc/linux.h
220@@ -84,7 +84,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
221 When the -shared link option is used a final link is not being
222 done. */
223
224-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
225+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
226
227 #undef LINK_SPEC
228 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
229diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
230index 789d1df4bd5..b920c680fb1 100644
231--- a/gcc/config/sparc/linux64.h
232+++ b/gcc/config/sparc/linux64.h
233@@ -84,8 +84,8 @@ along with GCC; see the file COPYING3. If not see
234 When the -shared link option is used a final link is not being
235 done. */
236
237-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
238-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
239+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
240+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux.so.2"
241
242 #ifdef SPARC_BI_ARCH
243
244--
2452.25.1
246
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0012-gcc-Fix-argument-list-too-long-error.patch b/meta/recipes-devtools/gcc/gcc-9.5/0012-gcc-Fix-argument-list-too-long-error.patch
new file mode 100644
index 0000000000..f0b79ee145
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0012-gcc-Fix-argument-list-too-long-error.patch
@@ -0,0 +1,44 @@
1From faa0f712a67005ef0260f95eebe7c7c57a6f8360 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:26:37 +0400
4Subject: [PATCH 12/39] gcc: Fix argument list too long error.
5
6There would be an "Argument list too long" error when the
7build directory is longer than 200, this is caused by:
8
9headers=`echo $(PLUGIN_HEADERS) | tr ' ' '\012' | sort -u`
10
11The PLUGIN_HEADERS is too long before sort, so the "echo" can't handle
12it, use the $(sort list) of GNU make which can handle the too long list
13would fix the problem, the header would be short enough after sorted.
14The "tr ' ' '\012'" was used for translating the space to "\n", the
15$(sort list) doesn't need this.
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19
20RP: gcc then added *.h and *.def additions to this list, breaking the original
21fix. Add the sort to the original gcc code, leaving the tr+sort to fix the original
22issue but include the new files too as reported by Zhuang <qiuguang.zqg@alibaba-inc.com>
23
24Upstream-Status: Pending
25---
26 gcc/Makefile.in | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/gcc/Makefile.in b/gcc/Makefile.in
30index fef6c4c61e3..57cf7804f0a 100644
31--- a/gcc/Makefile.in
32+++ b/gcc/Makefile.in
33@@ -3538,7 +3538,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
34 # We keep the directory structure for files in config or c-family and .def
35 # files. All other files are flattened to a single directory.
36 $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
37- headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
38+ headers=`echo $(sort $(PLUGIN_HEADERS)) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
39 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \
40 for file in $$headers; do \
41 if [ -f $$file ] ; then \
42--
432.25.1
44
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0013-Disable-sdt.patch b/meta/recipes-devtools/gcc/gcc-9.5/0013-Disable-sdt.patch
new file mode 100644
index 0000000000..455858354f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0013-Disable-sdt.patch
@@ -0,0 +1,113 @@
1From 4df5a747265983092afd6fbc5329dd808cc1da3c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:28:10 +0400
4Subject: [PATCH 13/39] Disable sdt.
5
6We don't list dtrace in DEPENDS so we shouldn't be depending on this header.
7It may or may not exist from preivous builds though. To be determinstic, disable
8sdt.h usage always. This avoids build failures if the header is removed after configure
9but before libgcc is compiled for example.
10
11RP 2012/8/7
12
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14
15Disable sdt for libstdc++-v3.
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18
19Upstream-Status: Inappropriate [hack]
20---
21 gcc/configure | 12 ++++++------
22 gcc/configure.ac | 18 +++++++++---------
23 libstdc++-v3/configure | 6 +++---
24 libstdc++-v3/configure.ac | 2 +-
25 4 files changed, 19 insertions(+), 19 deletions(-)
26
27diff --git a/gcc/configure b/gcc/configure
28index ed7931daed3..52f52b0ec86 100755
29--- a/gcc/configure
30+++ b/gcc/configure
31@@ -29333,12 +29333,12 @@ fi
32 { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
33 $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
34 have_sys_sdt_h=no
35-if test -f $target_header_dir/sys/sdt.h; then
36- have_sys_sdt_h=yes
37-
38-$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
39-
40-fi
41+#if test -f $target_header_dir/sys/sdt.h; then
42+# have_sys_sdt_h=yes
43+#
44+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
45+#
46+#fi
47 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
48 $as_echo "$have_sys_sdt_h" >&6; }
49
50diff --git a/gcc/configure.ac b/gcc/configure.ac
51index e0500e30d50..242ad28ec83 100644
52--- a/gcc/configure.ac
53+++ b/gcc/configure.ac
54@@ -5995,15 +5995,15 @@ fi
55 AC_SUBST([enable_default_ssp])
56
57 # Test for <sys/sdt.h> on the target.
58-GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
59-AC_MSG_CHECKING(sys/sdt.h in the target C library)
60-have_sys_sdt_h=no
61-if test -f $target_header_dir/sys/sdt.h; then
62- have_sys_sdt_h=yes
63- AC_DEFINE(HAVE_SYS_SDT_H, 1,
64- [Define if your target C library provides sys/sdt.h])
65-fi
66-AC_MSG_RESULT($have_sys_sdt_h)
67+#GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
68+#AC_MSG_CHECKING(sys/sdt.h in the target C library)
69+#have_sys_sdt_h=no
70+#if test -f $target_header_dir/sys/sdt.h; then
71+# have_sys_sdt_h=yes
72+# AC_DEFINE(HAVE_SYS_SDT_H, 1,
73+# [Define if your target C library provides sys/sdt.h])
74+#fi
75+#AC_MSG_RESULT($have_sys_sdt_h)
76
77 # Check if TFmode long double should be used by default or not.
78 # Some glibc targets used DFmode long double, but with glibc 2.4
79diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
80index 1225edc596b..3b89b880fc8 100755
81--- a/libstdc++-v3/configure
82+++ b/libstdc++-v3/configure
83@@ -22325,11 +22325,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
84 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
85 ac_compiler_gnu=$ac_cv_c_compiler_gnu
86
87- if test $glibcxx_cv_sys_sdt_h = yes; then
88+# if test $glibcxx_cv_sys_sdt_h = yes; then
89
90-$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
91+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
92
93- fi
94+# fi
95 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_sys_sdt_h" >&5
96 $as_echo "$glibcxx_cv_sys_sdt_h" >&6; }
97
98diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
99index d8455e41574..844cf1acbce 100644
100--- a/libstdc++-v3/configure.ac
101+++ b/libstdc++-v3/configure.ac
102@@ -232,7 +232,7 @@ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN
103 GLIBCXX_CHECK_SC_NPROC_ONLN
104 GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP
105 GLIBCXX_CHECK_SYSCTL_HW_NCPU
106-GLIBCXX_CHECK_SDT_H
107+#GLIBCXX_CHECK_SDT_H
108
109 # Check for available headers.
110 AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \
111--
1122.25.1
113
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0014-libtool.patch b/meta/recipes-devtools/gcc/gcc-9.5/0014-libtool.patch
new file mode 100644
index 0000000000..2953859238
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0014-libtool.patch
@@ -0,0 +1,42 @@
1From 34977d994666a90983c96a9240dfa3540562da35 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:29:11 +0400
4Subject: [PATCH 14/39] libtool
5
6libstdc++ from gcc-runtime gets created with -rpath=/usr/lib/../lib for qemux86-64
7when running on am x86_64 build host.
8
9This patch stops this speading to libdir in the libstdc++.la file within libtool.
10Arguably, it shouldn't be passing this into libtool in the first place but
11for now this resolves the nastiest problems this causes.
12
13func_normal_abspath would resolve an empty path to `pwd` so we need
14to filter the zero case.
15
16RP 2012/8/24
17
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19
20Upstream-Status: Pending
21---
22 ltmain.sh | 4 ++++
23 1 file changed, 4 insertions(+)
24
25diff --git a/ltmain.sh b/ltmain.sh
26index 79f9ba89af5..8e222f7c16b 100644
27--- a/ltmain.sh
28+++ b/ltmain.sh
29@@ -6359,6 +6359,10 @@ func_mode_link ()
30 func_warning "ignoring multiple \`-rpath's for a libtool library"
31
32 install_libdir="$1"
33+ if test -n "$install_libdir"; then
34+ func_normal_abspath "$install_libdir"
35+ install_libdir=$func_normal_abspath_result
36+ fi
37
38 oldlibs=
39 if test -z "$rpath"; then
40--
412.25.1
42
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta/recipes-devtools/gcc/gcc-9.5/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
new file mode 100644
index 0000000000..d4445244e2
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
@@ -0,0 +1,43 @@
1From 4558ba7fa020c111f9a204021a418c0ce55d77f9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:30:32 +0400
4Subject: [PATCH 15/39] gcc: armv4: pass fix-v4bx to linker to support EABI.
5
6The LINK_SPEC for linux gets overwritten by linux-eabi.h which
7means the value of TARGET_FIX_V4BX_SPEC gets lost and as a result
8the option is not passed to linker when chosing march=armv4
9This patch redefines this in linux-eabi.h and reinserts it
10for eabi defaulting toolchains.
11
12We might want to send it upstream.
13
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15
16Upstream-Status: Pending
17---
18 gcc/config/arm/linux-eabi.h | 6 +++++-
19 1 file changed, 5 insertions(+), 1 deletion(-)
20
21diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
22index e4ade2e2ab0..108863f69d2 100644
23--- a/gcc/config/arm/linux-eabi.h
24+++ b/gcc/config/arm/linux-eabi.h
25@@ -91,10 +91,14 @@
26 #define MUSL_DYNAMIC_LINKER \
27 "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
28
29+/* For armv4 we pass --fix-v4bx to linker to support EABI */
30+#undef TARGET_FIX_V4BX_SPEC
31+#define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}"
32+
33 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
34 use the GNU/Linux version, not the generic BPABI version. */
35 #undef LINK_SPEC
36-#define LINK_SPEC EABI_LINK_SPEC \
37+#define LINK_SPEC TARGET_FIX_V4BX_SPEC EABI_LINK_SPEC \
38 LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
39 LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
40
41--
422.25.1
43
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta/recipes-devtools/gcc/gcc-9.5/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch
new file mode 100644
index 0000000000..6f0833ccda
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch
@@ -0,0 +1,102 @@
1From 7effc632d65c2d72bf6fa32a219ec2f82fef9405 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:33:04 +0400
4Subject: [PATCH 16/39] Use the multilib config files from ${B} instead of
5 using the ones from ${S}
6
7Use the multilib config files from ${B} instead of using the ones from ${S}
8so that the source can be shared between gcc-cross-initial,
9gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build.
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
13
14Upstream-Status: Inappropriate [configuration]
15---
16 gcc/configure | 22 ++++++++++++++++++----
17 gcc/configure.ac | 22 ++++++++++++++++++----
18 2 files changed, 36 insertions(+), 8 deletions(-)
19
20diff --git a/gcc/configure b/gcc/configure
21index 52f52b0ec86..a5f208af7cf 100755
22--- a/gcc/configure
23+++ b/gcc/configure
24@@ -12322,10 +12322,20 @@ done
25 tmake_file_=
26 for f in ${tmake_file}
27 do
28- if test -f ${srcdir}/config/$f
29- then
30- tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
31- fi
32+ case $f in
33+ */t-linux64 )
34+ if test -f ./config/$f
35+ then
36+ tmake_file_="${tmake_file_} ./config/$f"
37+ fi
38+ ;;
39+ * )
40+ if test -f ${srcdir}/config/$f
41+ then
42+ tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
43+ fi
44+ ;;
45+ esac
46 done
47 tmake_file="${tmake_file_}"
48
49@@ -12336,6 +12346,10 @@ tm_file_list="options.h"
50 tm_include_list="options.h insn-constants.h"
51 for f in $tm_file; do
52 case $f in
53+ */linux64.h )
54+ tm_file_list="${tm_file_list} ./config/$f"
55+ tm_include_list="${tm_include_list} ./config/$f"
56+ ;;
57 ./* )
58 f=`echo $f | sed 's/^..//'`
59 tm_file_list="${tm_file_list} $f"
60diff --git a/gcc/configure.ac b/gcc/configure.ac
61index 242ad28ec83..b7a7ead1c02 100644
62--- a/gcc/configure.ac
63+++ b/gcc/configure.ac
64@@ -1948,10 +1948,20 @@ done
65 tmake_file_=
66 for f in ${tmake_file}
67 do
68- if test -f ${srcdir}/config/$f
69- then
70- tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
71- fi
72+ case $f in
73+ */t-linux64 )
74+ if test -f ./config/$f
75+ then
76+ tmake_file_="${tmake_file_} ./config/$f"
77+ fi
78+ ;;
79+ * )
80+ if test -f ${srcdir}/config/$f
81+ then
82+ tmake_file_="${tmake_file_} \$(srcdir)/config/$f"
83+ fi
84+ ;;
85+ esac
86 done
87 tmake_file="${tmake_file_}"
88
89@@ -1962,6 +1972,10 @@ tm_file_list="options.h"
90 tm_include_list="options.h insn-constants.h"
91 for f in $tm_file; do
92 case $f in
93+ */linux64.h )
94+ tm_file_list="${tm_file_list} ./config/$f"
95+ tm_include_list="${tm_include_list} ./config/$f"
96+ ;;
97 ./* )
98 f=`echo $f | sed 's/^..//'`
99 tm_file_list="${tm_file_list} $f"
100--
1012.25.1
102
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta/recipes-devtools/gcc/gcc-9.5/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
new file mode 100644
index 0000000000..96da013bf2
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
@@ -0,0 +1,31 @@
1From a2b2bf77621f344a849e55ab179ece8587d19234 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 09:39:38 +0000
4Subject: [PATCH 17/39] Avoid using libdir from .la which usually points to a
5 host path
6
7Upstream-Status: Inappropriate [embedded specific]
8
9Signed-off-by: Jonathan Liu <net147@gmail.com>
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 ltmain.sh | 3 +++
13 1 file changed, 3 insertions(+)
14
15diff --git a/ltmain.sh b/ltmain.sh
16index 8e222f7c16b..0a93b4e5c3b 100644
17--- a/ltmain.sh
18+++ b/ltmain.sh
19@@ -5628,6 +5628,9 @@ func_mode_link ()
20 absdir="$abs_ladir"
21 libdir="$abs_ladir"
22 else
23+ # Instead of using libdir from .la which usually points to a host path,
24+ # use the path the .la is contained in.
25+ libdir="$abs_ladir"
26 dir="$libdir"
27 absdir="$libdir"
28 fi
29--
302.25.1
31
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0018-export-CPP.patch b/meta/recipes-devtools/gcc/gcc-9.5/0018-export-CPP.patch
new file mode 100644
index 0000000000..2385099c25
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0018-export-CPP.patch
@@ -0,0 +1,53 @@
1From cafb6a621c05c1f238679d52fc026446f38c8af5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 09:40:59 +0000
4Subject: [PATCH 18/39] export CPP
5
6The OE environment sets and exports CPP as being the target gcc. When
7building gcc-cross-canadian for a mingw targetted sdk, the following can be found
8in build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log:
9
10configure:3641: checking for _FILE_OFFSET_BITS value needed for large files
11configure:3666: gcc -c -isystem/media/build1/poky/build/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe conftest.c >&5
12configure:3666: $? = 0
13configure:3698: result: no
14configure:3786: checking how to run the C preprocessor
15configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32
16configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c
17configure:3876: $? = 0
18
19Note this is a *build* target (in build-x86_64-linux) so it should be
20using the host "gcc", not x86_64-pokysdk-mingw32-gcc. Since the mingw32
21headers are very different, using the wrong cpp is a real problem. It is leaking
22into configure through the CPP variable. Ultimately this leads to build
23failures related to not being able to include a process.h file for pem-unix.c.
24
25The fix is to ensure we export a sane CPP value into the build
26environment when using build targets. We could define a CPP_FOR_BUILD value which may be
27the version which needs to be upstreamed but for now, this fix is good enough to
28avoid the problem.
29
30RP 22/08/2013
31
32Upstream-Status: Pending
33
34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35---
36 Makefile.in | 1 +
37 1 file changed, 1 insertion(+)
38
39diff --git a/Makefile.in b/Makefile.in
40index 64e091ba71d..255822e3f27 100644
41--- a/Makefile.in
42+++ b/Makefile.in
43@@ -149,6 +149,7 @@ BUILD_EXPORTS = \
44 AR="$(AR_FOR_BUILD)"; export AR; \
45 AS="$(AS_FOR_BUILD)"; export AS; \
46 CC="$(CC_FOR_BUILD)"; export CC; \
47+ CPP="$(CC_FOR_BUILD) -E"; export CPP; \
48 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
49 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
50 CXX="$(CXX_FOR_BUILD)"; export CXX; \
51--
522.25.1
53
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0019-Ensure-target-gcc-headers-can-be-included.patch b/meta/recipes-devtools/gcc/gcc-9.5/0019-Ensure-target-gcc-headers-can-be-included.patch
new file mode 100644
index 0000000000..e0129d1f96
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0019-Ensure-target-gcc-headers-can-be-included.patch
@@ -0,0 +1,60 @@
1From 182057b80891edc0e8d46835e2d8bfd28330a55a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 10:25:11 +0000
4Subject: [PATCH 19/39] Ensure target gcc headers can be included
5
6There are a few headers installed as part of the OpenEmbedded
7gcc-runtime target (omp.h, ssp/*.h). Being installed from a recipe
8built for the target architecture, these are within the target
9sysroot and not cross/nativesdk; thus they weren't able to be
10found by gcc with the existing search paths. Add support for
11picking up these headers under the sysroot supplied on the gcc
12command line in order to resolve this.
13
14Upstream-Status: Pending
15
16Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 gcc/Makefile.in | 2 ++
20 gcc/cppdefault.c | 4 ++++
21 2 files changed, 6 insertions(+)
22
23diff --git a/gcc/Makefile.in b/gcc/Makefile.in
24index 57cf7804f0a..7772342ad5e 100644
25--- a/gcc/Makefile.in
26+++ b/gcc/Makefile.in
27@@ -618,6 +618,7 @@ libexecdir = @libexecdir@
28
29 # Directory in which the compiler finds libraries etc.
30 libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
31+libsubdir_target = $(target_noncanonical)/$(version)
32 # Directory in which the compiler finds executables
33 libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
34 # Directory in which all plugin resources are installed
35@@ -2867,6 +2868,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\"
36
37 PREPROCESSOR_DEFINES = \
38 -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
39+ -DGCC_INCLUDE_SUBDIR_TARGET=\"$(libsubdir_target)/include\" \
40 -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
41 -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
42 -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
43diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
44index c4796385643..980e2bd47a7 100644
45--- a/gcc/cppdefault.c
46+++ b/gcc/cppdefault.c
47@@ -59,6 +59,10 @@ const struct default_include cpp_include_defaults[]
48 /* This is the dir for gcc's private headers. */
49 { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
50 #endif
51+#ifdef GCC_INCLUDE_SUBDIR_TARGET
52+ /* This is the dir for gcc's private headers under the specified sysroot. */
53+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
54+#endif
55 #ifdef LOCAL_INCLUDE_DIR
56 /* /usr/local/include comes before the fixincluded header files. */
57 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
58--
592.25.1
60
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0020-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch b/meta/recipes-devtools/gcc/gcc-9.5/0020-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch
new file mode 100644
index 0000000000..1d2182140f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0020-gcc-4.8-won-t-build-with-disable-dependency-tracking.patch
@@ -0,0 +1,54 @@
1From a4740f1290e6a602fbbfa27b863be2e3b2675685 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 11:17:19 +0000
4Subject: [PATCH 20/39] gcc 4.8+ won't build with --disable-dependency-tracking
5
6since the *.Ppo files don't get created unless --enable-dependency-tracking is true.
7
8This patch ensures we only use those compiler options when its enabled.
9
10Upstream-Status: Submitted
11
12(Problem was already reported upstream, attached this patch there
13http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55930)
14
15RP
162012/09/22
17
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 libatomic/Makefile.am | 3 ++-
21 libatomic/Makefile.in | 3 ++-
22 2 files changed, 4 insertions(+), 2 deletions(-)
23
24diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
25index c1b7c73934a..ef43d62c07a 100644
26--- a/libatomic/Makefile.am
27+++ b/libatomic/Makefile.am
28@@ -101,7 +101,8 @@ PAT_S = $(word 3,$(PAT_SPLIT))
29 IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
30 IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
31
32-M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
33+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
34+@AMDEP_FALSE@M_DEPS =
35 M_SIZE = -DN=$(PAT_N)
36 M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
37 M_FILE = $(PAT_BASE)_n.c
38diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
39index 29324e3e0ac..d5cdb4259ef 100644
40--- a/libatomic/Makefile.in
41+++ b/libatomic/Makefile.in
42@@ -414,7 +414,8 @@ PAT_N = $(word 2,$(PAT_SPLIT))
43 PAT_S = $(word 3,$(PAT_SPLIT))
44 IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
45 IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
46-M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
47+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
48+@AMDEP_FALSE@M_DEPS =
49 M_SIZE = -DN=$(PAT_N)
50 M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
51 M_FILE = $(PAT_BASE)_n.c
52--
532.25.1
54
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0021-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta/recipes-devtools/gcc/gcc-9.5/0021-Don-t-search-host-directory-during-relink-if-inst_pr.patch
new file mode 100644
index 0000000000..e363c7d445
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0021-Don-t-search-host-directory-during-relink-if-inst_pr.patch
@@ -0,0 +1,38 @@
1From f3edad81d80dde5d64bf77e6abafda54db10b824 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 3 Mar 2015 08:21:19 +0000
4Subject: [PATCH 21/39] Don't search host directory during "relink" if
5 $inst_prefix is provided
6
7http://lists.gnu.org/archive/html/libtool-patches/2011-01/msg00026.html
8
9Upstream-Status: Submitted
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 ltmain.sh | 5 +++--
14 1 file changed, 3 insertions(+), 2 deletions(-)
15
16diff --git a/ltmain.sh b/ltmain.sh
17index 0a93b4e5c3b..6de6ed2f9a0 100644
18--- a/ltmain.sh
19+++ b/ltmain.sh
20@@ -6004,12 +6004,13 @@ func_mode_link ()
21 fi
22 else
23 # We cannot seem to hardcode it, guess we'll fake it.
24+ # Default if $libdir is not relative to the prefix:
25 add_dir="-L$libdir"
26- # Try looking first in the location we're being installed to.
27+
28 if test -n "$inst_prefix_dir"; then
29 case $libdir in
30 [\\/]*)
31- add_dir="$add_dir -L$inst_prefix_dir$libdir"
32+ add_dir="-L$inst_prefix_dir$libdir"
33 ;;
34 esac
35 fi
36--
372.25.1
38
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0022-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch b/meta/recipes-devtools/gcc/gcc-9.5/0022-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch
new file mode 100644
index 0000000000..846c0de5e8
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0022-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch
@@ -0,0 +1,29 @@
1From b8ea2c2c7d33376f5dd651646c7e822000e47749 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 28 Apr 2015 23:15:27 -0700
4Subject: [PATCH 22/39] Use SYSTEMLIBS_DIR replacement instead of hardcoding
5 base_libdir
6
7Upstream-Status: Pending
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 gcc/config/aarch64/aarch64-linux.h | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
15index 5e8b34ded03..7e628bf661e 100644
16--- a/gcc/config/aarch64/aarch64-linux.h
17+++ b/gcc/config/aarch64/aarch64-linux.h
18@@ -21,7 +21,7 @@
19 #ifndef GCC_AARCH64_LINUX_H
20 #define GCC_AARCH64_LINUX_H
21
22-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
23+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
24
25 #undef MUSL_DYNAMIC_LINKER
26 #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
27--
282.25.1
29
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0023-aarch64-Add-support-for-musl-ldso.patch b/meta/recipes-devtools/gcc/gcc-9.5/0023-aarch64-Add-support-for-musl-ldso.patch
new file mode 100644
index 0000000000..102d6fc742
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0023-aarch64-Add-support-for-musl-ldso.patch
@@ -0,0 +1,28 @@
1From 8645b57e7c0dfd93afee5caeaa534c714f449ba1 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 28 Apr 2015 23:18:39 -0700
4Subject: [PATCH 23/39] aarch64: Add support for musl ldso
5
6Upstream-Status: Pending
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 gcc/config/aarch64/aarch64-linux.h | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
14index 7e628bf661e..1717cbe5471 100644
15--- a/gcc/config/aarch64/aarch64-linux.h
16+++ b/gcc/config/aarch64/aarch64-linux.h
17@@ -24,7 +24,7 @@
18 #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
19
20 #undef MUSL_DYNAMIC_LINKER
21-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
22+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
23
24 #undef ASAN_CC1_SPEC
25 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
26--
272.25.1
28
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0024-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta/recipes-devtools/gcc/gcc-9.5/0024-libcc1-fix-libcc1-s-install-path-and-rpath.patch
new file mode 100644
index 0000000000..443e0a2ca6
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0024-libcc1-fix-libcc1-s-install-path-and-rpath.patch
@@ -0,0 +1,54 @@
1From b1666565e4e133ee41f32fa8032165bcb06afe9a Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Sun, 5 Jul 2015 20:25:18 -0700
4Subject: [PATCH 24/39] libcc1: fix libcc1's install path and rpath
5
6* Install libcc1.so and libcc1plugin.so into
7 $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version), as what we
8 had done to lto-plugin.
9* Fix bad RPATH iussue:
10 gcc-5.2.0: package gcc-plugins contains bad RPATH /patht/to/tmp/sysroots/qemux86-64/usr/lib64/../lib64 in file
11 /path/to/gcc/5.2.0-r0/packages-split/gcc-plugins/usr/lib64/gcc/x86_64-poky-linux/5.2.0/plugin/libcc1plugin.so.0.0.0
12 [rpaths]
13
14Upstream-Status: Inappropriate [OE configuration]
15
16Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
17---
18 libcc1/Makefile.am | 4 ++--
19 libcc1/Makefile.in | 4 ++--
20 2 files changed, 4 insertions(+), 4 deletions(-)
21
22diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am
23index 72c6aead475..42a87740b31 100644
24--- a/libcc1/Makefile.am
25+++ b/libcc1/Makefile.am
26@@ -37,8 +37,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
27 $(Wc)$(libiberty_normal)))
28 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
29
30-plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
31-cc1libdir = $(libdir)/$(libsuffix)
32+cc1libdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
33+plugindir = $(cc1libdir)
34
35 if ENABLE_PLUGIN
36 plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la
37diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in
38index 7104b649026..2103c477468 100644
39--- a/libcc1/Makefile.in
40+++ b/libcc1/Makefile.in
41@@ -393,8 +393,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
42 $(Wc)$(libiberty_normal)))
43
44 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
45-plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
46-cc1libdir = $(libdir)/$(libsuffix)
47+cc1libdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
48+plugindir = $(cc1libdir)
49 @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la
50 @ENABLE_PLUGIN_TRUE@cc1lib_LTLIBRARIES = libcc1.la
51 shared_source = callbacks.cc callbacks.hh connection.cc connection.hh \
52--
532.25.1
54
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch
new file mode 100644
index 0000000000..59ac97eaed
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0025-handle-sysroot-support-for-nativesdk-gcc.patch
@@ -0,0 +1,346 @@
1From 7d614a84709d7dc4a2529c3d529e2da8541f9fd4 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:39:54 +0000
4Subject: [PATCH 25/39] handle sysroot support for nativesdk-gcc
5
6Being able to build a nativesdk gcc is useful, particularly in cases
7where the host compiler may be of an incompatible version (or a 32
8bit compiler is needed).
9
10Sadly, building nativesdk-gcc is not straight forward. We install
11nativesdk-gcc into a relocatable location and this means that its
12library locations can change. "Normal" sysroot support doesn't help
13in this case since the values of paths like "libdir" change, not just
14base root directory of the system.
15
16In order to handle this we do two things:
17
18a) Add %r into spec file markup which can be used for injected paths
19 such as SYSTEMLIBS_DIR (see gcc_multilib_setup()).
20b) Add other paths which need relocation into a .gccrelocprefix section
21 which the relocation code will notice and adjust automatically.
22
23Upstream-Status: Inappropriate
24RP 2015/7/28
25
26Signed-off-by: Khem Raj <raj.khem@gmail.com>
27
28Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without
29these as part of the gccrelocprefix the system can't do runtime relocation
30if the executable is moved. (These paths were missed in the original
31implementation.)
32
33Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
34---
35 c-family/c-opts.c | 4 +--
36 cppdefault.c | 63 +++++++++++++++++++++++++++++++++---------------------
37 cppdefault.h | 13 ++++-------
38 gcc.c | 20 ++++++++++++-----
39 incpath.c | 12 +++++-----
40 prefix.c | 4 +--
41 6 files changed, 68 insertions(+), 48 deletions(-)
42
43Index: gcc-9.3.0/gcc/cppdefault.c
44===================================================================
45--- gcc-9.3.0.orig/gcc/cppdefault.c
46+++ gcc-9.3.0/gcc/cppdefault.c
47@@ -35,6 +35,30 @@
48 # undef CROSS_INCLUDE_DIR
49 #endif
50
51+static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR;
52+char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR;
53+static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR;
54+static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
55+static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET;
56+#ifdef LOCAL_INCLUDE_DIR
57+static char LOCAL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = LOCAL_INCLUDE_DIR;
58+#endif
59+#ifdef PREFIX_INCLUDE_DIR
60+static char PREFIX_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX_INCLUDE_DIR;
61+#endif
62+#ifdef FIXED_INCLUDE_DIR
63+static char FIXED_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = FIXED_INCLUDE_DIR;
64+#endif
65+#ifdef CROSS_INCLUDE_DIR
66+static char CROSS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = CROSS_INCLUDE_DIR;
67+#endif
68+#ifdef TOOL_INCLUDE_DIR
69+static char TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = TOOL_INCLUDE_DIR;
70+#endif
71+#ifdef NATIVE_SYSTEM_HEADER_DIR
72+static char NATIVE_SYSTEM_HEADER_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = NATIVE_SYSTEM_HEADER_DIR;
73+#endif
74+
75 const struct default_include cpp_include_defaults[]
76 #ifdef INCLUDE_DEFAULTS
77 = INCLUDE_DEFAULTS;
78@@ -42,38 +66,38 @@ const struct default_include cpp_include
79 = {
80 #ifdef GPLUSPLUS_INCLUDE_DIR
81 /* Pick up GNU C++ generic include files. */
82- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
83+ { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1,
84 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
85 #endif
86 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
87 /* Pick up GNU C++ target-dependent include files. */
88- { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
89+ { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1,
90 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
91 #endif
92 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
93 /* Pick up GNU C++ backward and deprecated include files. */
94- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
95+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1,
96 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
97 #endif
98 #ifdef GCC_INCLUDE_DIR
99 /* This is the dir for gcc's private headers. */
100- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
101+ { GCC_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
102 #endif
103 #ifdef GCC_INCLUDE_SUBDIR_TARGET
104 /* This is the dir for gcc's private headers under the specified sysroot. */
105- { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
106+ { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0 },
107 #endif
108 #ifdef LOCAL_INCLUDE_DIR
109 /* /usr/local/include comes before the fixincluded header files. */
110- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
111- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
112+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 },
113+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 },
114 #endif
115 #ifdef PREFIX_INCLUDE_DIR
116- { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
117+ { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0 },
118 #endif
119 #ifdef FIXED_INCLUDE_DIR
120 /* This is the dir for fixincludes. */
121- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
122+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0,
123 /* A multilib suffix needs adding if different multilibs use
124 different headers. */
125 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
126@@ -85,33 +109,24 @@ const struct default_include cpp_include
127 #endif
128 #ifdef CROSS_INCLUDE_DIR
129 /* One place the target system's headers might be. */
130- { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
131+ { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
132 #endif
133 #ifdef TOOL_INCLUDE_DIR
134 /* Another place the target system's headers might be. */
135- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
136+ { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0 },
137 #endif
138 #ifdef NATIVE_SYSTEM_HEADER_DIR
139 /* /usr/include comes dead last. */
140- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
141- { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
142+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
143+ { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
144 #endif
145 { 0, 0, 0, 0, 0, 0 }
146 };
147 #endif /* no INCLUDE_DEFAULTS */
148
149-#ifdef GCC_INCLUDE_DIR
150-const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
151-const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
152-#else
153-const char cpp_GCC_INCLUDE_DIR[] = "";
154-const size_t cpp_GCC_INCLUDE_DIR_len = 0;
155-#endif
156-
157 /* The configured prefix. */
158-const char cpp_PREFIX[] = PREFIX;
159-const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
160-const char cpp_EXEC_PREFIX[] = STANDARD_EXEC_PREFIX;
161+char PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX;
162+char EXEC_PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX;
163
164 /* This value is set by cpp_relocated at runtime */
165 const char *gcc_exec_prefix;
166Index: gcc-9.3.0/gcc/cppdefault.h
167===================================================================
168--- gcc-9.3.0.orig/gcc/cppdefault.h
169+++ gcc-9.3.0/gcc/cppdefault.h
170@@ -33,7 +33,8 @@
171
172 struct default_include
173 {
174- const char *const fname; /* The name of the directory. */
175+ const char *fname; /* The name of the directory. */
176+
177 const char *const component; /* The component containing the directory
178 (see update_path in prefix.c) */
179 const char cplusplus; /* Only look here if we're compiling C++. */
180@@ -50,17 +51,13 @@ struct default_include
181 };
182
183 extern const struct default_include cpp_include_defaults[];
184-extern const char cpp_GCC_INCLUDE_DIR[];
185-extern const size_t cpp_GCC_INCLUDE_DIR_len;
186+extern char GCC_INCLUDE_DIRVAR[] __attribute__ ((section (".gccrelocprefix")));
187
188 /* The configure-time prefix, i.e., the value supplied as the argument
189 to --prefix=. */
190-extern const char cpp_PREFIX[];
191+extern char PREFIXVAR[] __attribute__ ((section (".gccrelocprefix")));
192 /* The length of the configure-time prefix. */
193-extern const size_t cpp_PREFIX_len;
194-/* The configure-time execution prefix. This is typically the lib/gcc
195- subdirectory of cpp_PREFIX. */
196-extern const char cpp_EXEC_PREFIX[];
197+extern char EXEC_PREFIXVAR[] __attribute__ ((section (".gccrelocprefix")));
198 /* The run-time execution prefix. This is typically the lib/gcc
199 subdirectory of the actual installation. */
200 extern const char *gcc_exec_prefix;
201Index: gcc-9.3.0/gcc/gcc.c
202===================================================================
203--- gcc-9.3.0.orig/gcc/gcc.c
204+++ gcc-9.3.0/gcc/gcc.c
205@@ -253,6 +253,8 @@ FILE *report_times_to_file = NULL;
206 #endif
207 static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
208
209+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR;
210+
211 /* Nonzero means pass the updated target_system_root to the compiler. */
212
213 static int target_system_root_changed;
214@@ -527,6 +529,7 @@ or with constant text in a single argume
215 %G process LIBGCC_SPEC as a spec.
216 %R Output the concatenation of target_system_root and
217 target_sysroot_suffix.
218+ %r Output the base path target_relocatable_prefix
219 %S process STARTFILE_SPEC as a spec. A capital S is actually used here.
220 %E process ENDFILE_SPEC as a spec. A capital E is actually used here.
221 %C process CPP_SPEC as a spec.
222@@ -1500,10 +1503,10 @@ static const char *gcc_libexec_prefix;
223 gcc_exec_prefix is set because, in that case, we know where the
224 compiler has been installed, and use paths relative to that
225 location instead. */
226-static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
227-static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX;
228-static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
229-static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
230+static char standard_exec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX;
231+static char standard_libexec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_LIBEXEC_PREFIX;
232+static char standard_bindir_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_BINDIR_PREFIX;
233+static char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
234
235 /* For native compilers, these are well-known paths containing
236 components that may be provided by the system. For cross
237@@ -1511,9 +1514,9 @@ static const char *const standard_startf
238 static const char *md_exec_prefix = MD_EXEC_PREFIX;
239 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
240 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
241-static const char *const standard_startfile_prefix_1
242+static char standard_startfile_prefix_1[4096] __attribute__ ((section (".gccrelocprefix")))
243 = STANDARD_STARTFILE_PREFIX_1;
244-static const char *const standard_startfile_prefix_2
245+static char standard_startfile_prefix_2[4096] __attribute__ ((section (".gccrelocprefix")))
246 = STANDARD_STARTFILE_PREFIX_2;
247
248 /* A relative path to be used in finding the location of tools
249@@ -5922,6 +5925,11 @@ do_spec_1 (const char *spec, int inswitc
250 }
251 break;
252
253+ case 'r':
254+ obstack_grow (&obstack, target_relocatable_prefix,
255+ strlen (target_relocatable_prefix));
256+ break;
257+
258 case 'S':
259 value = do_spec_1 (startfile_spec, 0, NULL);
260 if (value != 0)
261Index: gcc-9.3.0/gcc/c-family/c-opts.c
262===================================================================
263--- gcc-9.3.0.orig/gcc/c-family/c-opts.c
264+++ gcc-9.3.0/gcc/c-family/c-opts.c
265@@ -1382,8 +1382,8 @@ add_prefixed_path (const char *suffix, i
266 size_t prefix_len, suffix_len;
267
268 suffix_len = strlen (suffix);
269- prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
270- prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
271+ prefix = iprefix ? iprefix : GCC_INCLUDE_DIRVAR;
272+ prefix_len = iprefix ? strlen (iprefix) : strlen(GCC_INCLUDE_DIRVAR) - 7;
273
274 path = (char *) xmalloc (prefix_len + suffix_len + 1);
275 memcpy (path, prefix, prefix_len);
276Index: gcc-9.3.0/gcc/incpath.c
277===================================================================
278--- gcc-9.3.0.orig/gcc/incpath.c
279+++ gcc-9.3.0/gcc/incpath.c
280@@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot,
281 int relocated = cpp_relocated ();
282 size_t len;
283
284- if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
285+ if (iprefix && (len = strlen(GCC_INCLUDE_DIRVAR) - 7) != 0)
286 {
287 /* Look for directories that start with the standard prefix.
288 "Translate" them, i.e. replace /usr/local/lib/gcc... with
289@@ -145,7 +145,7 @@ add_standard_paths (const char *sysroot,
290 now. */
291 if (sysroot && p->add_sysroot)
292 continue;
293- if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
294+ if (!filename_ncmp (p->fname, GCC_INCLUDE_DIRVAR, len))
295 {
296 char *str = concat (iprefix, p->fname + len, NULL);
297 if (p->multilib == 1 && imultilib)
298@@ -185,7 +185,7 @@ add_standard_paths (const char *sysroot,
299 free (sysroot_no_trailing_dir_separator);
300 }
301 else if (!p->add_sysroot && relocated
302- && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
303+ && !filename_ncmp (p->fname, PREFIXVAR, strlen(PREFIXVAR)))
304 {
305 static const char *relocated_prefix;
306 char *ostr;
307@@ -202,12 +202,12 @@ add_standard_paths (const char *sysroot,
308 dummy = concat (gcc_exec_prefix, "dummy", NULL);
309 relocated_prefix
310 = make_relative_prefix (dummy,
311- cpp_EXEC_PREFIX,
312- cpp_PREFIX);
313+ EXEC_PREFIXVAR,
314+ PREFIXVAR);
315 free (dummy);
316 }
317 ostr = concat (relocated_prefix,
318- p->fname + cpp_PREFIX_len,
319+ p->fname + strlen(PREFIXVAR),
320 NULL);
321 str = update_path (ostr, p->component);
322 free (ostr);
323Index: gcc-9.3.0/gcc/prefix.c
324===================================================================
325--- gcc-9.3.0.orig/gcc/prefix.c
326+++ gcc-9.3.0/gcc/prefix.c
327@@ -72,7 +72,9 @@ License along with GCC; see the file COP
328 #include "prefix.h"
329 #include "common/common-target.h"
330
331-static const char *std_prefix = PREFIX;
332+static const char PREFIXVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX;
333+
334+static const char *std_prefix = PREFIXVAR;
335
336 static const char *get_key_value (char *);
337 static char *translate_name (char *);
338@@ -212,7 +214,7 @@ translate_name (char *name)
339 prefix = getenv (key);
340
341 if (prefix == 0)
342- prefix = PREFIX;
343+ prefix = PREFIXVAR;
344
345 /* We used to strip trailing DIR_SEPARATORs here, but that can
346 sometimes yield a result with no separator when one was coded
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0026-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta/recipes-devtools/gcc/gcc-9.5/0026-Search-target-sysroot-gcc-version-specific-dirs-with.patch
new file mode 100644
index 0000000000..abfa7516da
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0026-Search-target-sysroot-gcc-version-specific-dirs-with.patch
@@ -0,0 +1,102 @@
1From 6c39a22c3e85d20dee9e2fc2274e95da980de4d0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:41:45 +0000
4Subject: [PATCH 26/39] Search target sysroot gcc version specific dirs with
5 multilib.
6
7We install the gcc libraries (such as crtbegin.p) into
8<sysroot><libdir>/<target-sys>/5.2.0/
9which is a default search path for GCC (aka multi_suffix in the
10code below). <target-sys> is 'machine' in gcc's terminology. We use
11these directories so that multiple gcc versions could in theory
12co-exist on target.
13
14We only want to build one gcc-cross-canadian per arch and have this work
15for all multilibs. <target-sys> can be handled by mapping the multilib
16<target-sys> to the one used by gcc-cross-canadian, e.g.
17mips64-polkmllib32-linux
18is symlinked to by mips64-poky-linux.
19
20The default gcc search path in the target sysroot for a "lib64" mutlilib
21is:
22
23<sysroot>/lib32/mips64-poky-linux/5.2.0/
24<sysroot>/lib32/../lib64/
25<sysroot>/usr/lib32/mips64-poky-linux/5.2.0/
26<sysroot>/usr/lib32/../lib64/
27<sysroot>/lib32/
28<sysroot>/usr/lib32/
29
30which means that the lib32 crtbegin.o will be found and the lib64 ones
31will not which leads to compiler failures.
32
33This patch injects a multilib version of that path first so the lib64
34binaries can be found first. With this change the search path becomes:
35
36<sysroot>/lib32/../lib64/mips64-poky-linux/5.2.0/
37<sysroot>/lib32/mips64-poky-linux/5.2.0/
38<sysroot>/lib32/../lib64/
39<sysroot>/usr/lib32/../lib64/mips64-poky-linux/5.2.0/
40<sysroot>/usr/lib32/mips64-poky-linux/5.2.0/
41<sysroot>/usr/lib32/../lib64/
42<sysroot>/lib32/
43<sysroot>/usr/lib32/
44
45Upstream-Status: Pending
46RP 2015/7/31
47
48Signed-off-by: Khem Raj <raj.khem@gmail.com>
49---
50 gcc/gcc.c | 29 ++++++++++++++++++++++++++++-
51 1 file changed, 28 insertions(+), 1 deletion(-)
52
53diff --git a/gcc/gcc.c b/gcc/gcc.c
54index 59fb64f5fd5..3e79da4238c 100644
55--- a/gcc/gcc.c
56+++ b/gcc/gcc.c
57@@ -2617,7 +2617,7 @@ for_each_path (const struct path_prefix *paths,
58 if (path == NULL)
59 {
60 len = paths->max_len + extra_space + 1;
61- len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len);
62+ len += MAX ((suffix_len + multi_os_dir_len), multiarch_len);
63 path = XNEWVEC (char, len);
64 }
65
66@@ -2629,6 +2629,33 @@ for_each_path (const struct path_prefix *paths,
67 /* Look first in MACHINE/VERSION subdirectory. */
68 if (!skip_multi_dir)
69 {
70+ if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir))
71+ {
72+ const char *this_multi;
73+ size_t this_multi_len;
74+
75+ if (pl->os_multilib)
76+ {
77+ this_multi = multi_os_dir;
78+ this_multi_len = multi_os_dir_len;
79+ }
80+ else
81+ {
82+ this_multi = multi_dir;
83+ this_multi_len = multi_dir_len;
84+ }
85+
86+ /* Look in multilib MACHINE/VERSION subdirectory first */
87+ if (this_multi_len)
88+ {
89+ memcpy (path + len, this_multi, this_multi_len + 1);
90+ memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1);
91+ ret = callback (path, callback_info);
92+ if (ret)
93+ break;
94+ }
95+ }
96+
97 memcpy (path + len, multi_suffix, suffix_len + 1);
98 ret = callback (path, callback_info);
99 if (ret)
100--
1012.25.1
102
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0027-Fix-various-_FOR_BUILD-and-related-variables.patch b/meta/recipes-devtools/gcc/gcc-9.5/0027-Fix-various-_FOR_BUILD-and-related-variables.patch
new file mode 100644
index 0000000000..ae8acc7f13
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0027-Fix-various-_FOR_BUILD-and-related-variables.patch
@@ -0,0 +1,137 @@
1From 07db34b16b6c8e3d948b417f2fc052500ffb77d3 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:42:45 +0000
4Subject: [PATCH 27/39] Fix various _FOR_BUILD and related variables
5
6When doing a FOR_BUILD thing, you have to override CFLAGS with
7CFLAGS_FOR_BUILD. And if you use C++, you also have to override
8CXXFLAGS with CXXFLAGS_FOR_BUILD.
9Without this, when building for mingw, you end up trying to use
10the mingw headers for a host build.
11
12The same goes for other variables as well, such as CPPFLAGS,
13CPP, and GMPINC.
14
15Upstream-Status: Pending
16
17Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
18Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 Makefile.in | 6 ++++++
22 Makefile.tpl | 5 +++++
23 gcc/Makefile.in | 2 +-
24 gcc/configure | 2 +-
25 gcc/configure.ac | 2 +-
26 5 files changed, 14 insertions(+), 3 deletions(-)
27
28diff --git a/Makefile.in b/Makefile.in
29index 255822e3f27..9dc0dff0474 100644
30--- a/Makefile.in
31+++ b/Makefile.in
32@@ -152,6 +152,7 @@ BUILD_EXPORTS = \
33 CPP="$(CC_FOR_BUILD) -E"; export CPP; \
34 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
35 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
36+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
37 CXX="$(CXX_FOR_BUILD)"; export CXX; \
38 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
39 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
40@@ -171,6 +172,9 @@ BUILD_EXPORTS = \
41 # built for the build system to override those in BASE_FLAGS_TO_PASS.
42 EXTRA_BUILD_FLAGS = \
43 CFLAGS="$(CFLAGS_FOR_BUILD)" \
44+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
45+ CPP="$(CC_FOR_BUILD) -E" \
46+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \
47 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
48
49 # This is the list of directories to built for the host system.
50@@ -188,6 +192,7 @@ HOST_SUBDIR = @host_subdir@
51 HOST_EXPORTS = \
52 $(BASE_EXPORTS) \
53 CC="$(CC)"; export CC; \
54+ CPP="$(CC) -E"; export CPP; \
55 ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
56 CFLAGS="$(CFLAGS)"; export CFLAGS; \
57 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
58@@ -775,6 +780,7 @@ BASE_FLAGS_TO_PASS = \
59 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
60 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
61 "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
62+ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \
63 "EXPECT=$(EXPECT)" \
64 "FLEX=$(FLEX)" \
65 "INSTALL=$(INSTALL)" \
66diff --git a/Makefile.tpl b/Makefile.tpl
67index 41cae58a267..d3f6b79acdc 100644
68--- a/Makefile.tpl
69+++ b/Makefile.tpl
70@@ -154,6 +154,7 @@ BUILD_EXPORTS = \
71 CC="$(CC_FOR_BUILD)"; export CC; \
72 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
73 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
74+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
75 CXX="$(CXX_FOR_BUILD)"; export CXX; \
76 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
77 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
78@@ -173,6 +174,9 @@ BUILD_EXPORTS = \
79 # built for the build system to override those in BASE_FLAGS_TO_PASS.
80 EXTRA_BUILD_FLAGS = \
81 CFLAGS="$(CFLAGS_FOR_BUILD)" \
82+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
83+ CPP="$(CC_FOR_BUILD) -E" \
84+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \
85 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
86
87 # This is the list of directories to built for the host system.
88@@ -190,6 +194,7 @@ HOST_SUBDIR = @host_subdir@
89 HOST_EXPORTS = \
90 $(BASE_EXPORTS) \
91 CC="$(CC)"; export CC; \
92+ CPP="$(CC) -E"; export CPP; \
93 ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
94 CFLAGS="$(CFLAGS)"; export CFLAGS; \
95 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
96diff --git a/gcc/Makefile.in b/gcc/Makefile.in
97index 7772342ad5e..02fec881b6d 100644
98--- a/gcc/Makefile.in
99+++ b/gcc/Makefile.in
100@@ -805,7 +805,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@
101 BUILD_NO_PIE_FLAG = @BUILD_NO_PIE_FLAG@
102 BUILD_LDFLAGS += $(BUILD_NO_PIE_FLAG)
103 BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
104- -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS)
105+ -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS_FOR_BUILD)
106
107 # Actual name to use when installing a native compiler.
108 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
109diff --git a/gcc/configure b/gcc/configure
110index a5f208af7cf..0788b7bf0b5 100755
111--- a/gcc/configure
112+++ b/gcc/configure
113@@ -11966,7 +11966,7 @@ else
114 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
115 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
116 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
117- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
118+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
119 ${realsrcdir}/configure \
120 --enable-languages=${enable_languages-all} \
121 --target=$target_alias --host=$build_alias --build=$build_alias
122diff --git a/gcc/configure.ac b/gcc/configure.ac
123index b7a7ead1c02..5ab50fae0f3 100644
124--- a/gcc/configure.ac
125+++ b/gcc/configure.ac
126@@ -1743,7 +1743,7 @@ else
127 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
128 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
129 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
130- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
131+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
132 ${realsrcdir}/configure \
133 --enable-languages=${enable_languages-all} \
134 --target=$target_alias --host=$build_alias --build=$build_alias
135--
1362.25.1
137
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0028-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta/recipes-devtools/gcc/gcc-9.5/0028-nios2-Define-MUSL_DYNAMIC_LINKER.patch
new file mode 100644
index 0000000000..52a5d97aef
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0028-nios2-Define-MUSL_DYNAMIC_LINKER.patch
@@ -0,0 +1,28 @@
1From 59543e897eb35194fb47288f7762e40a18fff611 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 2 Feb 2016 10:26:10 -0800
4Subject: [PATCH 28/39] nios2: Define MUSL_DYNAMIC_LINKER
5
6Upstream-Status: Pending
7
8Signed-off-by: Marek Vasut <marex@denx.de>
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 gcc/config/nios2/linux.h | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
15index 698734add35..eeee60ecfea 100644
16--- a/gcc/config/nios2/linux.h
17+++ b/gcc/config/nios2/linux.h
18@@ -30,6 +30,7 @@
19 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
20
21 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
22+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1"
23
24 #undef LINK_SPEC
25 #define LINK_SPEC LINK_SPEC_ENDIAN \
26--
272.25.1
28
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0029-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta/recipes-devtools/gcc/gcc-9.5/0029-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
new file mode 100644
index 0000000000..bfa7e19dd0
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0029-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
@@ -0,0 +1,87 @@
1From 8df99af0a65ef740bcf2b7dc9a109cc57f15c3aa Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 27 Jun 2017 18:10:54 -0700
4Subject: [PATCH 29/39] Add ssp_nonshared to link commandline for musl targets
5
6when -fstack-protector options are enabled we need to
7link with ssp_shared on musl since it does not provide
8the __stack_chk_fail_local() so essentially it provides
9libssp but not libssp_nonshared something like
10TARGET_LIBC_PROVIDES_SSP_BUT_NOT_SSP_NONSHARED
11 where-as for glibc the needed symbols
12are already present in libc_nonshared library therefore
13we do not need any library helper on glibc based systems
14but musl needs the libssp_noshared from gcc
15
16Upstream-Status: Pending
17
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 gcc/config/linux.h | 7 +++++++
21 gcc/config/rs6000/linux.h | 10 ++++++++++
22 gcc/config/rs6000/linux64.h | 10 ++++++++++
23 3 files changed, 27 insertions(+)
24
25diff --git a/gcc/config/linux.h b/gcc/config/linux.h
26index 4b05d8e93d1..0ca117e2ed4 100644
27--- a/gcc/config/linux.h
28+++ b/gcc/config/linux.h
29@@ -195,6 +195,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
30 { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
31 { 0, 0, 0, 0, 0, 0 } \
32 }
33+#ifdef TARGET_LIBC_PROVIDES_SSP
34+#undef LINK_SSP_SPEC
35+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
36+ "|fstack-protector-strong|fstack-protector-explicit" \
37+ ":-lssp_nonshared}"
38+#endif
39+
40 #endif
41
42 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
43diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
44index ffceb32bf65..c82cb2ad05b 100644
45--- a/gcc/config/rs6000/linux.h
46+++ b/gcc/config/rs6000/linux.h
47@@ -94,6 +94,16 @@
48 " -m elf32ppclinux")
49 #endif
50
51+/* link libssp_nonshared.a with musl */
52+#if DEFAULT_LIBC == LIBC_MUSL
53+#ifdef TARGET_LIBC_PROVIDES_SSP
54+#undef LINK_SSP_SPEC
55+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
56+ "|fstack-protector-strong|fstack-protector-explicit" \
57+ ":-lssp_nonshared}"
58+#endif
59+#endif
60+
61 #undef LINK_OS_LINUX_SPEC
62 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
63 %{!static-pie: \
64diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
65index 45a9a7cae59..d1e88a40e82 100644
66--- a/gcc/config/rs6000/linux64.h
67+++ b/gcc/config/rs6000/linux64.h
68@@ -456,6 +456,16 @@ extern int dot_symbols;
69 " -m elf64ppc")
70 #endif
71
72+/* link libssp_nonshared.a with musl */
73+#if DEFAULT_LIBC == LIBC_MUSL
74+#ifdef TARGET_LIBC_PROVIDES_SSP
75+#undef LINK_SSP_SPEC
76+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
77+ "|fstack-protector-strong|fstack-protector-explicit" \
78+ ":-lssp_nonshared}"
79+#endif
80+#endif
81+
82 #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
83 %{!static-pie: \
84 %{rdynamic:-export-dynamic} \
85--
862.25.1
87
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0030-ldbl128-config.patch b/meta/recipes-devtools/gcc/gcc-9.5/0030-ldbl128-config.patch
new file mode 100644
index 0000000000..f8e8c07f62
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0030-ldbl128-config.patch
@@ -0,0 +1,79 @@
1From 1bfae624b27ea4a1f5c5a92050d741b511e7b3d5 Mon Sep 17 00:00:00 2001
2From: Szabolcs Nagy <nsz@port70.net>
3Date: Wed, 28 Feb 2018 00:54:05 +0000
4Subject: [PATCH 30/39] ldbl128 config
5
6Upstream-Status: Pending
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 gcc/configure | 13 +++++++++++++
11 gcc/configure.ac | 16 ++++++++++++++--
12 2 files changed, 27 insertions(+), 2 deletions(-)
13
14diff --git a/gcc/configure b/gcc/configure
15index 0788b7bf0b5..eb1a45bb263 100755
16--- a/gcc/configure
17+++ b/gcc/configure
18@@ -29370,6 +29370,15 @@ if test "${with_long_double_128+set}" = set; then :
19 withval=$with_long_double_128; gcc_cv_target_ldbl128="$with_long_double_128"
20 else
21
22+ case "$target" in
23+ s390*-*-linux-musl*)
24+ gcc_cv_target_ldbl128=yes
25+ ;;
26+ powerpc*-*-linux-musl*)
27+ gcc_cv_target_ldbl128=no
28+ ;;
29+ *)
30+
31 if test $glibc_version_major -gt 2 \
32 || ( test $glibc_version_major -eq 2 && test $glibc_version_minor -ge 4 ); then :
33 gcc_cv_target_ldbl128=yes
34@@ -29381,6 +29390,10 @@ else
35 && gcc_cv_target_ldbl128=yes
36
37 fi
38+
39+ ;;
40+ esac
41+
42 fi
43
44 ;;
45diff --git a/gcc/configure.ac b/gcc/configure.ac
46index 5ab50fae0f3..7ffe35ee1c3 100644
47--- a/gcc/configure.ac
48+++ b/gcc/configure.ac
49@@ -6030,13 +6030,25 @@ case "$target" in
50 AC_ARG_WITH(long-double-128,
51 [AS_HELP_STRING([--with-long-double-128],
52 [use 128-bit long double by default])],
53- gcc_cv_target_ldbl128="$with_long_double_128",
54+ gcc_cv_target_ldbl128="$with_long_double_128", [
55+ case "$target" in
56+ s390*-*-linux-musl*)
57+ gcc_cv_target_ldbl128=yes
58+ ;;
59+ powerpc*-*-linux-musl*)
60+ gcc_cv_target_ldbl128=no
61+ ;;
62+ *)]
63 [GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_target_ldbl128=yes], [
64 [gcc_cv_target_ldbl128=no
65 grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \
66 $target_header_dir/bits/wordsize.h > /dev/null 2>&1 \
67 && gcc_cv_target_ldbl128=yes
68- ]])])
69+ ]])]
70+ [
71+ ;;
72+ esac
73+ ])
74 ;;
75 esac
76 if test x$gcc_cv_target_ldbl128 = xyes; then
77--
782.25.1
79
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0031-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta/recipes-devtools/gcc/gcc-9.5/0031-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
new file mode 100644
index 0000000000..60a29fc94d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0031-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
@@ -0,0 +1,29 @@
1From 31d008f5573627c6192ce9fcf729f0be464a7cf5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 4 May 2016 21:11:34 -0700
4Subject: [PATCH 31/39] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS
5
6Upstream-Status: Pending
7
8Signed-off-by: Christopher Larson <chris_larson@mentor.com>
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 libgcc/config/t-slibgcc | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc
15index 099bf23e62f..436b277a79f 100644
16--- a/libgcc/config/t-slibgcc
17+++ b/libgcc/config/t-slibgcc
18@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
19 $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
20
21 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
22- $(SHLIB_LDFLAGS) \
23+ $(LDFLAGS) $(SHLIB_LDFLAGS) \
24 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
25 $(SHLIB_OBJS) $(SHLIB_LC) && \
26 rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
27--
282.25.1
29
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0032-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta/recipes-devtools/gcc/gcc-9.5/0032-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
new file mode 100644
index 0000000000..6f048dab82
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0032-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
@@ -0,0 +1,86 @@
1From 761fa6e3e37608cfd1b288e721a2ff89288cd6aa Mon Sep 17 00:00:00 2001
2From: Szabolcs Nagy <nsz@port70.net>
3Date: Sat, 24 Oct 2015 20:09:53 +0000
4Subject: [PATCH 32/39] libgcc_s: Use alias for __cpu_indicator_init instead of
5 symver
6
7Adapter from
8
9https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00899.html
10
11This fix was debated but hasnt been applied gcc upstream since
12they expect musl to support '@' in symbol versioning which is
13a sun/gnu versioning extention. This patch however avoids the
14need for the '@' symbols at all
15
16libgcc/Changelog:
17
182015-05-11 Szabolcs Nagy <szabolcs.nagy@arm.com>
19
20 * config/i386/cpuinfo.c (__cpu_indicator_init_local): Add.
21 (__cpu_indicator_init@GCC_4.8.0, __cpu_model@GCC_4.8.0): Remove.
22
23 * config/i386/t-linux (HOST_LIBGCC2_CFLAGS): Remove -DUSE_ELF_SYMVER.
24
25gcc/Changelog:
26
272015-05-11 Szabolcs Nagy <szabolcs.nagy@arm.com>
28
29 * config/i386/i386.c (ix86_expand_builtin): Make __builtin_cpu_init
30 call __cpu_indicator_init_local instead of __cpu_indicator_init.
31
32Upstream-Status: Pending
33
34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35---
36 gcc/config/i386/i386.c | 4 ++--
37 libgcc/config/i386/cpuinfo.c | 6 +++---
38 libgcc/config/i386/t-linux | 2 +-
39 3 files changed, 6 insertions(+), 6 deletions(-)
40
41diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
42index 1bca5a7eea6..096c4bc8e25 100644
43--- a/gcc/config/i386/i386.c
44+++ b/gcc/config/i386/i386.c
45@@ -36685,10 +36685,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
46 {
47 case IX86_BUILTIN_CPU_INIT:
48 {
49- /* Make it call __cpu_indicator_init in libgcc. */
50+ /* Make it call __cpu_indicator_init_local in libgcc.a. */
51 tree call_expr, fndecl, type;
52 type = build_function_type_list (integer_type_node, NULL_TREE);
53- fndecl = build_fn_decl ("__cpu_indicator_init", type);
54+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
55 call_expr = build_call_expr (fndecl, 0);
56 return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
57 }
58diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
59index d6cb2de6265..ce04ef78205 100644
60--- a/libgcc/config/i386/cpuinfo.c
61+++ b/libgcc/config/i386/cpuinfo.c
62@@ -504,7 +504,7 @@ __cpu_indicator_init (void)
63 return 0;
64 }
65
66-#if defined SHARED && defined USE_ELF_SYMVER
67-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
68-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
69+#ifndef SHARED
70+int __cpu_indicator_init_local (void)
71+ __attribute__ ((weak, alias ("__cpu_indicator_init")));
72 #endif
73diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux
74index 8506a635790..564296f788e 100644
75--- a/libgcc/config/i386/t-linux
76+++ b/libgcc/config/i386/t-linux
77@@ -3,5 +3,5 @@
78 # t-slibgcc-elf-ver and t-linux
79 SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
80
81-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS)
82+HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS)
83 CRTSTUFF_T_CFLAGS += $(CET_FLAGS)
84--
852.25.1
86
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0033-sync-gcc-stddef.h-with-musl.patch b/meta/recipes-devtools/gcc/gcc-9.5/0033-sync-gcc-stddef.h-with-musl.patch
new file mode 100644
index 0000000000..f080b0596f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0033-sync-gcc-stddef.h-with-musl.patch
@@ -0,0 +1,91 @@
1From 126e342fb39d7af70c1e5a6df8ffafc8dfc3bf08 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 3 Feb 2017 12:56:00 -0800
4Subject: [PATCH 33/39] sync gcc stddef.h with musl
5
6musl defines ptrdiff_t size_t and wchar_t
7so dont define them here if musl is definining them
8
9Upstream-Status: Pending
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 gcc/ginclude/stddef.h | 9 +++++++++
14 1 file changed, 9 insertions(+)
15
16diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
17index da692e1c01a..9a00c261adb 100644
18--- a/gcc/ginclude/stddef.h
19+++ b/gcc/ginclude/stddef.h
20@@ -128,6 +128,7 @@ _TYPE_wchar_t;
21 #ifndef ___int_ptrdiff_t_h
22 #ifndef _GCC_PTRDIFF_T
23 #ifndef _PTRDIFF_T_DECLARED /* DragonFly */
24+#ifndef __DEFINED_ptrdiff_t /* musl */
25 #define _PTRDIFF_T
26 #define _T_PTRDIFF_
27 #define _T_PTRDIFF
28@@ -137,10 +138,12 @@ _TYPE_wchar_t;
29 #define ___int_ptrdiff_t_h
30 #define _GCC_PTRDIFF_T
31 #define _PTRDIFF_T_DECLARED
32+#define __DEFINED_ptrdiff_t /* musl */
33 #ifndef __PTRDIFF_TYPE__
34 #define __PTRDIFF_TYPE__ long int
35 #endif
36 typedef __PTRDIFF_TYPE__ ptrdiff_t;
37+#endif /* __DEFINED_ptrdiff_t */
38 #endif /* _PTRDIFF_T_DECLARED */
39 #endif /* _GCC_PTRDIFF_T */
40 #endif /* ___int_ptrdiff_t_h */
41@@ -178,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
42 #ifndef _GCC_SIZE_T
43 #ifndef _SIZET_
44 #ifndef __size_t
45+#ifndef __DEFINED_size_t /* musl */
46 #define __size_t__ /* BeOS */
47 #define __SIZE_T__ /* Cray Unicos/Mk */
48 #define _SIZE_T
49@@ -194,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
50 #define ___int_size_t_h
51 #define _GCC_SIZE_T
52 #define _SIZET_
53+#define __DEFINED_size_t /* musl */
54 #if defined (__FreeBSD__) \
55 || defined(__DragonFly__) \
56 || defined(__FreeBSD_kernel__) \
57@@ -228,6 +233,7 @@ typedef long ssize_t;
58 #endif /* _SIZE_T */
59 #endif /* __SIZE_T__ */
60 #endif /* __size_t__ */
61+#endif /* __DEFINED_size_t */
62 #undef __need_size_t
63 #endif /* _STDDEF_H or __need_size_t. */
64
65@@ -257,6 +263,7 @@ typedef long ssize_t;
66 #ifndef ___int_wchar_t_h
67 #ifndef __INT_WCHAR_T_H
68 #ifndef _GCC_WCHAR_T
69+#ifndef __DEFINED_wchar_t /* musl */
70 #define __wchar_t__ /* BeOS */
71 #define __WCHAR_T__ /* Cray Unicos/Mk */
72 #define _WCHAR_T
73@@ -272,6 +279,7 @@ typedef long ssize_t;
74 #define __INT_WCHAR_T_H
75 #define _GCC_WCHAR_T
76 #define _WCHAR_T_DECLARED
77+#define __DEFINED_wchar_t /* musl */
78
79 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
80 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
81@@ -337,6 +345,7 @@ typedef __WCHAR_TYPE__ wchar_t;
82 #endif
83 #endif /* __WCHAR_T__ */
84 #endif /* __wchar_t__ */
85+#endif /* __DEFINED_wchar_t musl */
86 #undef __need_wchar_t
87 #endif /* _STDDEF_H or __need_wchar_t. */
88
89--
902.25.1
91
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0034-fix-segmentation-fault-in-precompiled-header-generat.patch b/meta/recipes-devtools/gcc/gcc-9.5/0034-fix-segmentation-fault-in-precompiled-header-generat.patch
new file mode 100644
index 0000000000..3b7ccb3e3d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0034-fix-segmentation-fault-in-precompiled-header-generat.patch
@@ -0,0 +1,60 @@
1From d26fa9ededccc7e1ec47ead7f18afc80971483a3 Mon Sep 17 00:00:00 2001
2From: Juro Bystricky <juro.bystricky@intel.com>
3Date: Mon, 19 Mar 2018 22:31:20 -0700
4Subject: [PATCH 34/39] fix segmentation fault in precompiled header generation
5
6Prevent a segmentation fault which occurs when using incorrect
7structure trying to access name of some named operators, such as
8CPP_NOT, CPP_AND etc. "token->val.node.spelling" cannot be used in
9those cases, as is may not be initialized at all.
10
11[YOCTO #11738]
12
13Upstream-Status: Pending
14
15Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 libcpp/lex.c | 26 +++++++++++++++++++++-----
19 1 file changed, 21 insertions(+), 5 deletions(-)
20
21diff --git a/libcpp/lex.c b/libcpp/lex.c
22index eedfcbb3146..15040a1b1f0 100644
23--- a/libcpp/lex.c
24+++ b/libcpp/lex.c
25@@ -3280,11 +3280,27 @@ cpp_spell_token (cpp_reader *pfile, const cpp_token *token,
26 spell_ident:
27 case SPELL_IDENT:
28 if (forstring)
29- {
30- memcpy (buffer, NODE_NAME (token->val.node.spelling),
31- NODE_LEN (token->val.node.spelling));
32- buffer += NODE_LEN (token->val.node.spelling);
33- }
34+ {
35+ if (token->type == CPP_NAME)
36+ {
37+ memcpy (buffer, NODE_NAME (token->val.node.spelling),
38+ NODE_LEN (token->val.node.spelling));
39+ buffer += NODE_LEN (token->val.node.spelling);
40+ break;
41+ }
42+ /* NAMED_OP, cannot use node.spelling */
43+ if (token->flags & NAMED_OP)
44+ {
45+ const char *str = cpp_named_operator2name (token->type);
46+ if (str)
47+ {
48+ size_t len = strlen(str);
49+ memcpy(buffer, str, len);
50+ buffer += len;
51+ }
52+ break;
53+ }
54+ }
55 else
56 buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node);
57 break;
58--
592.25.1
60
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0035-Fix-for-testsuite-failure.patch b/meta/recipes-devtools/gcc/gcc-9.5/0035-Fix-for-testsuite-failure.patch
new file mode 100644
index 0000000000..5e199fbcfd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0035-Fix-for-testsuite-failure.patch
@@ -0,0 +1,258 @@
1From fb5bdf8f8527228d587e8af9fc700e5164b3c18c Mon Sep 17 00:00:00 2001
2From: RAGHUNATH LOLUR <raghunath.lolur@kpit.com>
3Date: Wed, 6 Dec 2017 22:52:26 -0800
4Subject: [PATCH 35/39] Fix for testsuite failure
5
62017-11-16 Raghunath Lolur <raghunath.lolur@kpit.com>
7
8 * gcc.dg/pr56275.c: If SSE is disabled, ensure that
9 "-mfpmath" is not set to use SSE. Set "-mfpmath=387".
10 * gcc.dg/pr68306.c: Likewise
11 * gcc.dg/pr68306-2.c: Likewise
12 * gcc.dg/pr68306-3.c: Likewise
13 * gcc.dg/pr69634.c: Likewise
14 * gcc.target/i386/amd64-abi-1.c: Likewise
15 * gcc.target/i386/funcspec-6.c: Likewise
16 * gcc.target/i386/interrupt-387-err-1.c: Likewise
17 * gcc.target/i386/isa-14.c: Likewise
18 * gcc.target/i386/pr44948-2b.c: Likewise
19 * gcc.target/i386/pr53425-1.c: Likewise
20 * gcc.target/i386/pr53425-2.c: Likewise
21 * gcc.target/i386/pr55247.c: Likewise
22 * gcc.target/i386/pr59644.c: Likewise
23 * gcc.target/i386/pr62120.c: Likewise
24 * gcc.target/i386/pr70467-1.c: Likewise
25 * gcc.target/i386/warn-vect-op-1.c: Likewise
26
27If -Wall, -Werror are used during compilation various test cases fail
28to compile.
29
30If SSE is disabled, be sure to -mfpmath=387 to resolve this.
31
32This patch removes the changes to Changelog from the original patch.
33This will help us avoid conflicts.
34
35Upstream-Status: Pending
36
37Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
38---
39 gcc/testsuite/gcc.dg/pr56275.c | 2 +-
40 gcc/testsuite/gcc.dg/pr68306-2.c | 2 +-
41 gcc/testsuite/gcc.dg/pr68306-3.c | 2 +-
42 gcc/testsuite/gcc.dg/pr68306.c | 2 +-
43 gcc/testsuite/gcc.dg/pr69634.c | 2 +-
44 gcc/testsuite/gcc.target/i386/amd64-abi-1.c | 2 +-
45 gcc/testsuite/gcc.target/i386/funcspec-6.c | 1 +
46 gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c | 2 +-
47 gcc/testsuite/gcc.target/i386/isa-14.c | 2 +-
48 gcc/testsuite/gcc.target/i386/pr44948-2b.c | 2 +-
49 gcc/testsuite/gcc.target/i386/pr53425-1.c | 2 +-
50 gcc/testsuite/gcc.target/i386/pr53425-2.c | 2 +-
51 gcc/testsuite/gcc.target/i386/pr55247.c | 2 +-
52 gcc/testsuite/gcc.target/i386/pr59644.c | 2 +-
53 gcc/testsuite/gcc.target/i386/pr62120.c | 2 +-
54 gcc/testsuite/gcc.target/i386/pr70467-1.c | 2 +-
55 gcc/testsuite/gcc.target/i386/warn-vect-op-1.c | 2 +-
56 17 files changed, 17 insertions(+), 16 deletions(-)
57
58diff --git a/gcc/testsuite/gcc.dg/pr56275.c b/gcc/testsuite/gcc.dg/pr56275.c
59index b901bb2b199..a4f6c95e1a1 100644
60--- a/gcc/testsuite/gcc.dg/pr56275.c
61+++ b/gcc/testsuite/gcc.dg/pr56275.c
62@@ -1,6 +1,6 @@
63 /* { dg-do compile } */
64 /* { dg-options "-O2" } */
65-/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
66+/* { dg-additional-options "-mno-sse -mfpmath=387" { target { i?86-*-* x86_64-*-* } } } */
67
68 typedef long long v2tw __attribute__ ((vector_size (2 * sizeof (long long))));
69
70diff --git a/gcc/testsuite/gcc.dg/pr68306-2.c b/gcc/testsuite/gcc.dg/pr68306-2.c
71index 4672ebe7987..2a368c484b6 100644
72--- a/gcc/testsuite/gcc.dg/pr68306-2.c
73+++ b/gcc/testsuite/gcc.dg/pr68306-2.c
74@@ -1,6 +1,6 @@
75 /* { dg-do compile } */
76 /* { dg-options "-O3" } */
77-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
78+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
79
80 struct {
81 int tz_minuteswest;
82diff --git a/gcc/testsuite/gcc.dg/pr68306-3.c b/gcc/testsuite/gcc.dg/pr68306-3.c
83index f5a8c102cf8..df3390c64c2 100644
84--- a/gcc/testsuite/gcc.dg/pr68306-3.c
85+++ b/gcc/testsuite/gcc.dg/pr68306-3.c
86@@ -1,6 +1,6 @@
87 /* { dg-do compile } */
88 /* { dg-options "-O3" } */
89-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
90+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
91 /* { dg-additional-options "-mno-altivec -mno-vsx" { target powerpc*-*-* } } */
92
93 extern void fn2();
94diff --git a/gcc/testsuite/gcc.dg/pr68306.c b/gcc/testsuite/gcc.dg/pr68306.c
95index 54e5b40f221..0813389e2c1 100644
96--- a/gcc/testsuite/gcc.dg/pr68306.c
97+++ b/gcc/testsuite/gcc.dg/pr68306.c
98@@ -1,6 +1,6 @@
99 /* { dg-do compile } */
100 /* { dg-options "-O3" } */
101-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
102+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
103
104 enum powerpc_pmc_type { PPC_PMC_IBM };
105 struct {
106diff --git a/gcc/testsuite/gcc.dg/pr69634.c b/gcc/testsuite/gcc.dg/pr69634.c
107index 60a56149463..bcc23f9ccd6 100644
108--- a/gcc/testsuite/gcc.dg/pr69634.c
109+++ b/gcc/testsuite/gcc.dg/pr69634.c
110@@ -1,6 +1,6 @@
111 /* { dg-do compile } */
112 /* { dg-options "-O2 -fno-dce -fschedule-insns -fno-tree-vrp -fcompare-debug -Wno-psabi" } */
113-/* { dg-additional-options "-mno-sse" { target i?86-*-* x86_64-*-* } } */
114+/* { dg-additional-options "-mno-sse -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
115 /* { dg-require-effective-target scheduling } */
116
117 typedef unsigned short u16;
118diff --git a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
119index 69fde57bf06..7f1f1c03edf 100644
120--- a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
121+++ b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
122@@ -1,5 +1,5 @@
123 /* { dg-do compile { target { ! ia32 } } } */
124-/* { dg-options "-mno-sse" } */
125+/* { dg-options "-mno-sse -mfpmath=387" } */
126 /* { dg-additional-options "-mabi=sysv" { target *-*-mingw* } } */
127
128 double foo(void) { return 0; } /* { dg-error "SSE disabled" } */
129diff --git a/gcc/testsuite/gcc.target/i386/funcspec-6.c b/gcc/testsuite/gcc.target/i386/funcspec-6.c
130index ea896b7ebfd..bf15569b826 100644
131--- a/gcc/testsuite/gcc.target/i386/funcspec-6.c
132+++ b/gcc/testsuite/gcc.target/i386/funcspec-6.c
133@@ -1,6 +1,7 @@
134 /* Test whether all of the 64-bit function specific options are accepted
135 without error. */
136 /* { dg-do compile { target { ! ia32 } } } */
137+/* { dg-additional-options "-mfpmath=387" } */
138
139 #include "funcspec-56.inc"
140
141diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
142index 8561a3c26d6..6377f814645 100644
143--- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
144+++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
145@@ -1,5 +1,5 @@
146 /* { dg-do compile } */
147-/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387" } */
148+/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387 -mfpmath=387" } */
149
150 typedef unsigned int uword_t __attribute__ ((mode (__word__)));
151
152diff --git a/gcc/testsuite/gcc.target/i386/isa-14.c b/gcc/testsuite/gcc.target/i386/isa-14.c
153index 5d49e6e77fe..1de2db92bdd 100644
154--- a/gcc/testsuite/gcc.target/i386/isa-14.c
155+++ b/gcc/testsuite/gcc.target/i386/isa-14.c
156@@ -1,5 +1,5 @@
157 /* { dg-do run } */
158-/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse" } */
159+/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse -mfpmath=387" } */
160
161 extern void abort (void);
162
163diff --git a/gcc/testsuite/gcc.target/i386/pr44948-2b.c b/gcc/testsuite/gcc.target/i386/pr44948-2b.c
164index fa1769b62fb..f79fb12726f 100644
165--- a/gcc/testsuite/gcc.target/i386/pr44948-2b.c
166+++ b/gcc/testsuite/gcc.target/i386/pr44948-2b.c
167@@ -1,5 +1,5 @@
168 /* { dg-do compile } */
169-/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic" } */
170+/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic -mfpmath=387" } */
171
172 struct A
173 {
174diff --git a/gcc/testsuite/gcc.target/i386/pr53425-1.c b/gcc/testsuite/gcc.target/i386/pr53425-1.c
175index 2e89ff7d81d..6339bf6b736 100644
176--- a/gcc/testsuite/gcc.target/i386/pr53425-1.c
177+++ b/gcc/testsuite/gcc.target/i386/pr53425-1.c
178@@ -1,6 +1,6 @@
179 /* PR target/53425 */
180 /* { dg-do compile { target { ! ia32 } } } */
181-/* { dg-options "-O2 -mno-sse" } */
182+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
183 /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */
184
185 typedef double __v2df __attribute__ ((__vector_size__ (16)));
186diff --git a/gcc/testsuite/gcc.target/i386/pr53425-2.c b/gcc/testsuite/gcc.target/i386/pr53425-2.c
187index 61f6283dbe9..2c5a55f0ac3 100644
188--- a/gcc/testsuite/gcc.target/i386/pr53425-2.c
189+++ b/gcc/testsuite/gcc.target/i386/pr53425-2.c
190@@ -1,6 +1,6 @@
191 /* PR target/53425 */
192 /* { dg-do compile { target { ! ia32 } } } */
193-/* { dg-options "-O2 -mno-sse" } */
194+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
195 /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */
196
197 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
198diff --git a/gcc/testsuite/gcc.target/i386/pr55247.c b/gcc/testsuite/gcc.target/i386/pr55247.c
199index 23366d0909d..9810e3abb76 100644
200--- a/gcc/testsuite/gcc.target/i386/pr55247.c
201+++ b/gcc/testsuite/gcc.target/i386/pr55247.c
202@@ -1,6 +1,6 @@
203 /* { dg-do compile { target { ! ia32 } } } */
204 /* { dg-require-effective-target maybe_x32 } */
205-/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long" } */
206+/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long -mfpmath=387" } */
207
208 typedef unsigned int uint32_t;
209 typedef uint32_t Elf32_Word;
210diff --git a/gcc/testsuite/gcc.target/i386/pr59644.c b/gcc/testsuite/gcc.target/i386/pr59644.c
211index 96006b3e338..4287e4538bf 100644
212--- a/gcc/testsuite/gcc.target/i386/pr59644.c
213+++ b/gcc/testsuite/gcc.target/i386/pr59644.c
214@@ -1,6 +1,6 @@
215 /* PR target/59644 */
216 /* { dg-do run { target lp64 } } */
217-/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone" } */
218+/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone -mfpmath=387" } */
219
220 /* This test uses __builtin_trap () instead of e.g. abort,
221 because due to -mpreferred-stack-boundary=3 it should not call
222diff --git a/gcc/testsuite/gcc.target/i386/pr62120.c b/gcc/testsuite/gcc.target/i386/pr62120.c
223index bfb8c4703eb..ed04cf181f3 100644
224--- a/gcc/testsuite/gcc.target/i386/pr62120.c
225+++ b/gcc/testsuite/gcc.target/i386/pr62120.c
226@@ -1,5 +1,5 @@
227 /* { dg-do compile } */
228-/* { dg-options "-mno-sse" } */
229+/* { dg-options "-mno-sse -mfpmath=387" } */
230
231 void foo ()
232 {
233diff --git a/gcc/testsuite/gcc.target/i386/pr70467-1.c b/gcc/testsuite/gcc.target/i386/pr70467-1.c
234index 4e112c88d07..bcfb396a68d 100644
235--- a/gcc/testsuite/gcc.target/i386/pr70467-1.c
236+++ b/gcc/testsuite/gcc.target/i386/pr70467-1.c
237@@ -1,6 +1,6 @@
238 /* PR rtl-optimization/70467 */
239 /* { dg-do compile } */
240-/* { dg-options "-O2 -mno-sse" } */
241+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
242
243 void foo (unsigned long long *);
244
245diff --git a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
246index 6cda1534311..26e37f5b8ba 100644
247--- a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
248+++ b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
249@@ -1,5 +1,5 @@
250 /* { dg-do compile { target { ! ia32 } } } */
251-/* { dg-options "-mno-sse -Wvector-operation-performance" } */
252+/* { dg-options "-mno-sse -Wvector-operation-performance -mfpmath=387" } */
253 #define vector(elcount, type) \
254 __attribute__((vector_size((elcount)*sizeof(type)))) type
255
256--
2572.25.1
258
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0036-Re-introduce-spe-commandline-options.patch b/meta/recipes-devtools/gcc/gcc-9.5/0036-Re-introduce-spe-commandline-options.patch
new file mode 100644
index 0000000000..825e070aa3
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0036-Re-introduce-spe-commandline-options.patch
@@ -0,0 +1,41 @@
1From dc23cabac6a7b2ca85b02d2a58a8916c98f382e0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 6 Jun 2018 12:10:22 -0700
4Subject: [PATCH 36/39] Re-introduce spe commandline options
5
6This should ensure that we keep accepting
7spe options
8
9Upstream-Status: Inappropriate [SPE port is removed from rs600 port]
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 gcc/config/rs6000/rs6000.opt | 12 ++++++++++++
14 1 file changed, 12 insertions(+)
15
16diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
17index f4b5c91e11f..69869350fce 100644
18--- a/gcc/config/rs6000/rs6000.opt
19+++ b/gcc/config/rs6000/rs6000.opt
20@@ -345,6 +345,18 @@ mdebug=
21 Target RejectNegative Joined
22 -mdebug= Enable debug output.
23
24+mspe
25+Target Var(rs6000_spe) Save
26+Generate SPE SIMD instructions on E500.
27+
28+mabi=spe
29+Target RejectNegative Var(rs6000_spe_abi) Save
30+Use the SPE ABI extensions.
31+
32+mabi=no-spe
33+Target RejectNegative Var(rs6000_spe_abi, 0)
34+Do not use the SPE ABI extensions.
35+
36 mabi=altivec
37 Target RejectNegative Var(rs6000_altivec_abi) Save
38 Use the AltiVec ABI extensions.
39--
402.25.1
41
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0037-CVE-2019-14250-Check-zero-value-in-simple_object_elf.patch b/meta/recipes-devtools/gcc/gcc-9.5/0037-CVE-2019-14250-Check-zero-value-in-simple_object_elf.patch
new file mode 100644
index 0000000000..f268a4eb58
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0037-CVE-2019-14250-Check-zero-value-in-simple_object_elf.patch
@@ -0,0 +1,48 @@
1From ac4af583bd59f6631671ad4abf985799ce4a53d9 Mon Sep 17 00:00:00 2001
2From: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Thu, 25 Jul 2019 10:46:54 +0000
4Subject: [PATCH 37/39] CVE-2019-14250: Check zero value in
5 simple_object_elf_match
6
72019-07-25 Richard Biener <rguenther@suse.de>
8
9 PR lto/90924
10 Backport from mainline
11 2019-07-12 Ren Kimura <rkx1209dev@gmail.com>
12
13 * simple-object-elf.c (simple_object_elf_match): Check zero value
14 shstrndx.
15
16git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@273793 138bc75d-0d04-0410-961f-82ee72b054a4
17
18Upstream-Status: Backport
19Affectes: < 9.2
20CVE: CVE-2019-14250
21Dropped changelog
22Signed-off-by: Armin Kuster <Akustre@mvista.com>
23---
24 libiberty/simple-object-elf.c | 8 ++++++++
25 1 file changed, 8 insertions(+)
26
27diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
28index 3d49f339631..c00cebdb6c7 100644
29--- a/libiberty/simple-object-elf.c
30+++ b/libiberty/simple-object-elf.c
31@@ -557,6 +557,14 @@ simple_object_elf_match (unsigned char header[SIMPLE_OBJECT_MATCH_HEADER_LEN],
32 return NULL;
33 }
34
35+ if (eor->shstrndx == 0)
36+ {
37+ *errmsg = "invalid ELF shstrndx == 0";
38+ *err = 0;
39+ XDELETE (eor);
40+ return NULL;
41+ }
42+
43 return (void *) eor;
44 }
45
46--
472.25.1
48
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0038-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch b/meta/recipes-devtools/gcc/gcc-9.5/0038-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
new file mode 100644
index 0000000000..a79fc03d15
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0038-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
@@ -0,0 +1,185 @@
1From 075e0929e04913538391052c32178b6a14ef0ae3 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 12 Mar 2020 14:41:40 -0700
4Subject: [PATCH 38/39] gentypes/genmodes: Do not use __LINE__ for maintaining
5 reproducibility
6
7Inserting line numbers into generated code means its not always reproducible wth
8differing versions of host gcc. Void the issue by not adding these.
9
10Upstream-Status: Inappropriate [OE Reproducibility specific]
11
12Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 gcc/gengtype.c | 6 +++---
16 gcc/genmodes.c | 32 ++++++++++++++++----------------
17 2 files changed, 19 insertions(+), 19 deletions(-)
18
19diff --git a/gcc/gengtype.c b/gcc/gengtype.c
20index 53317337cf8..bbb26151671 100644
21--- a/gcc/gengtype.c
22+++ b/gcc/gengtype.c
23@@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt,
24 /* Create a fake field with the given type and name. NEXT is the next
25 field in the chain. */
26 #define create_field(next,type,name) \
27- create_field_all (next,type,name, 0, this_file, __LINE__)
28+ create_field_all (next,type,name, 0, this_file, 0)
29
30 /* Like create_field, but the field is only valid when condition COND
31 is true. */
32@@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name,
33 }
34
35 #define create_optional_field(next,type,name,cond) \
36- create_optional_field_(next,type,name,cond,__LINE__)
37+ create_optional_field_(next,type,name,cond,0)
38
39 /* Reverse a linked list of 'struct pair's in place. */
40 pair_p
41@@ -5186,7 +5186,7 @@ main (int argc, char **argv)
42 /* These types are set up with #define or else outside of where
43 we can see them. We should initialize them before calling
44 read_input_list. */
45-#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__; \
46+#define POS_HERE(Call) do { pos.file = this_file; pos.line = 0; \
47 Call;} while (0)
48 POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
49 POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
50diff --git a/gcc/genmodes.c b/gcc/genmodes.c
51index f33eefa2494..07bef9eebe2 100644
52--- a/gcc/genmodes.c
53+++ b/gcc/genmodes.c
54@@ -429,7 +429,7 @@ complete_all_modes (void)
55 }
56
57 /* For each mode in class CLASS, construct a corresponding complex mode. */
58-#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, __LINE__)
59+#define COMPLEX_MODES(C) make_complex_modes (MODE_##C, __FILE__, 0)
60 static void
61 make_complex_modes (enum mode_class cl,
62 const char *file, unsigned int line)
63@@ -487,7 +487,7 @@ make_complex_modes (enum mode_class cl,
64 /* For all modes in class CL, construct vector modes of width
65 WIDTH, having as many components as necessary. */
66 #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W) \
67- make_vector_modes (MODE_##C, #PREFIX, W, __FILE__, __LINE__)
68+ make_vector_modes (MODE_##C, #PREFIX, W, __FILE__, 0)
69 #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W)
70 static void ATTRIBUTE_UNUSED
71 make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
72@@ -538,7 +538,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
73 /* Create a vector of booleans called NAME with COUNT elements and
74 BYTESIZE bytes in total. */
75 #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \
76- make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__)
77+ make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0)
78 static void ATTRIBUTE_UNUSED
79 make_vector_bool_mode (const char *name, unsigned int count,
80 unsigned int bytesize, const char *file,
81@@ -560,7 +560,7 @@ make_vector_bool_mode (const char *name, unsigned int count,
82 /* Input. */
83
84 #define _SPECIAL_MODE(C, N) \
85- make_special_mode (MODE_##C, #N, __FILE__, __LINE__)
86+ make_special_mode (MODE_##C, #N, __FILE__, 0)
87 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
88 #define CC_MODE(N) _SPECIAL_MODE (CC, N)
89
90@@ -573,7 +573,7 @@ make_special_mode (enum mode_class cl, const char *name,
91
92 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
93 #define FRACTIONAL_INT_MODE(N, B, Y) \
94- make_int_mode (#N, B, Y, __FILE__, __LINE__)
95+ make_int_mode (#N, B, Y, __FILE__, 0)
96
97 static void
98 make_int_mode (const char *name,
99@@ -586,16 +586,16 @@ make_int_mode (const char *name,
100 }
101
102 #define FRACT_MODE(N, Y, F) \
103- make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__)
104+ make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, 0)
105
106 #define UFRACT_MODE(N, Y, F) \
107- make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__)
108+ make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, 0)
109
110 #define ACCUM_MODE(N, Y, I, F) \
111- make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__)
112+ make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, 0)
113
114 #define UACCUM_MODE(N, Y, I, F) \
115- make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__)
116+ make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, 0)
117
118 /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
119 FILE, and LINE. */
120@@ -616,7 +616,7 @@ make_fixed_point_mode (enum mode_class cl,
121
122 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
123 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
124- make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
125+ make_float_mode (#N, B, Y, #F, __FILE__, 0)
126
127 static void
128 make_float_mode (const char *name,
129@@ -633,7 +633,7 @@ make_float_mode (const char *name,
130 #define DECIMAL_FLOAT_MODE(N, Y, F) \
131 FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
132 #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \
133- make_decimal_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
134+ make_decimal_float_mode (#N, B, Y, #F, __FILE__, 0)
135
136 static void
137 make_decimal_float_mode (const char *name,
138@@ -648,7 +648,7 @@ make_decimal_float_mode (const char *name,
139 }
140
141 #define RESET_FLOAT_FORMAT(N, F) \
142- reset_float_format (#N, #F, __FILE__, __LINE__)
143+ reset_float_format (#N, #F, __FILE__, 0)
144 static void ATTRIBUTE_UNUSED
145 reset_float_format (const char *name, const char *format,
146 const char *file, unsigned int line)
147@@ -669,7 +669,7 @@ reset_float_format (const char *name, const char *format,
148
149 /* __intN support. */
150 #define INT_N(M,PREC) \
151- make_int_n (#M, PREC, __FILE__, __LINE__)
152+ make_int_n (#M, PREC, __FILE__, 0)
153 static void ATTRIBUTE_UNUSED
154 make_int_n (const char *m, int bitsize,
155 const char *file, unsigned int line)
156@@ -698,7 +698,7 @@ make_int_n (const char *m, int bitsize,
157 /* Partial integer modes are specified by relation to a full integer
158 mode. */
159 #define PARTIAL_INT_MODE(M,PREC,NAME) \
160- make_partial_integer_mode (#M, #NAME, PREC, __FILE__, __LINE__)
161+ make_partial_integer_mode (#M, #NAME, PREC, __FILE__, 0)
162 static void ATTRIBUTE_UNUSED
163 make_partial_integer_mode (const char *base, const char *name,
164 unsigned int precision,
165@@ -725,7 +725,7 @@ make_partial_integer_mode (const char *base, const char *name,
166 /* A single vector mode can be specified by naming its component
167 mode and the number of components. */
168 #define VECTOR_MODE(C, M, N) \
169- make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
170+ make_vector_mode (MODE_##C, #M, N, __FILE__, 0);
171 static void ATTRIBUTE_UNUSED
172 make_vector_mode (enum mode_class bclass,
173 const char *base,
174@@ -768,7 +768,7 @@ make_vector_mode (enum mode_class bclass,
175
176 /* Adjustability. */
177 #define _ADD_ADJUST(A, M, X, C1, C2) \
178- new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__)
179+ new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, 0)
180
181 #define ADJUST_NUNITS(M, X) _ADD_ADJUST (nunits, M, X, RANDOM, RANDOM)
182 #define ADJUST_BYTESIZE(M, X) _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM)
183--
1842.25.1
185
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/0039-process_alt_operands-Don-t-match-user-defined-regs-o.patch b/meta/recipes-devtools/gcc/gcc-9.5/0039-process_alt_operands-Don-t-match-user-defined-regs-o.patch
new file mode 100644
index 0000000000..b69114d1e5
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/0039-process_alt_operands-Don-t-match-user-defined-regs-o.patch
@@ -0,0 +1,100 @@
1From e75bcc2ec4f1e7e081ce18713f0a25913ba15340 Mon Sep 17 00:00:00 2001
2From: Vladimir Makarov <vmakarov@redhat.com>
3Date: Wed, 10 Jul 2019 16:07:10 +0000
4Subject: [PATCH 39/39] process_alt_operands: Don't match user defined regs
5 only if they are early clobbers
6
7PR target/91102 (aarch64 ICE on Linux kernel with -Os starting with r270266)
8
92019-07-10 Vladimir Makarov <vmakarov@redhat.com>
10
11 PR target/91102
12 * lra-constraints.c (process_alt_operands): Don't match user
13 defined regs only if they are early clobbers.
14
152019-07-10 Vladimir Makarov <vmakarov@redhat.com>
16
17 PR target/91102
18 * gcc.target/aarch64/pr91102.c: New test.
19
20From-SVN: r273357
21Upstream-Status: Backport [https://github.com/gcc-mirror/gcc/commit/613caed2feb9cfc8158308670b59df3d031ec629]
22[takondra: dropped conflicting ChangeLog changes]
23Signed-off-by: Taras Kondratiuk <takondra@cisco.com>
24---
25 gcc/lra-constraints.c | 17 ++++++++++----
26 gcc/testsuite/gcc.target/aarch64/pr91102.c | 26 ++++++++++++++++++++++
27 2 files changed, 39 insertions(+), 4 deletions(-)
28 create mode 100644 gcc/testsuite/gcc.target/aarch64/pr91102.c
29
30diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
31index cf33da8013e..6382dbf852b 100644
32--- a/gcc/lra-constraints.c
33+++ b/gcc/lra-constraints.c
34@@ -2172,8 +2172,9 @@ process_alt_operands (int only_alternative)
35 else
36 {
37 /* Operands don't match. If the operands are
38- different user defined explicit hard registers,
39- then we cannot make them match. */
40+ different user defined explicit hard
41+ registers, then we cannot make them match
42+ when one is early clobber operand. */
43 if ((REG_P (*curr_id->operand_loc[nop])
44 || SUBREG_P (*curr_id->operand_loc[nop]))
45 && (REG_P (*curr_id->operand_loc[m])
46@@ -2192,9 +2193,17 @@ process_alt_operands (int only_alternative)
47 && REG_P (m_reg)
48 && HARD_REGISTER_P (m_reg)
49 && REG_USERVAR_P (m_reg))
50- break;
51+ {
52+ int i;
53+
54+ for (i = 0; i < early_clobbered_regs_num; i++)
55+ if (m == early_clobbered_nops[i])
56+ break;
57+ if (i < early_clobbered_regs_num
58+ || early_clobber_p)
59+ break;
60+ }
61 }
62-
63 /* Both operands must allow a reload register,
64 otherwise we cannot make them match. */
65 if (curr_alt[m] == NO_REGS)
66diff --git a/gcc/testsuite/gcc.target/aarch64/pr91102.c b/gcc/testsuite/gcc.target/aarch64/pr91102.c
67new file mode 100644
68index 00000000000..70b99045a48
69--- /dev/null
70+++ b/gcc/testsuite/gcc.target/aarch64/pr91102.c
71@@ -0,0 +1,26 @@
72+/* PR target/91102 */
73+/* { dg-do compile } */
74+/* { dg-options "-O2" } */
75+
76+int
77+foo (long d, long l)
78+{
79+ register long e asm ("x1") = d;
80+ register long f asm("x2") = l;
81+ asm ("" : : "r" (e), "r" (f));
82+ return 3;
83+}
84+
85+struct T { int i; int j; };
86+union S { long h; struct T t; };
87+
88+void
89+bar (union S b)
90+{
91+ while (1)
92+ {
93+ union S c = b;
94+ c.t.j++;
95+ b.h = foo (b.h, c.h);
96+ }
97+}
98--
992.25.1
100
diff --git a/meta/recipes-devtools/gcc/gcc-9.5/CVE-2023-4039.patch b/meta/recipes-devtools/gcc/gcc-9.5/CVE-2023-4039.patch
new file mode 100644
index 0000000000..56d229066f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-9.5/CVE-2023-4039.patch
@@ -0,0 +1,1506 @@
1From: Richard Sandiford <richard.sandiford@arm.com>
2Subject: [PATCH 00/19] aarch64: Fix -fstack-protector issue
3Date: Tue, 12 Sep 2023 16:25:10 +0100
4
5This series of patches fixes deficiencies in GCC's -fstack-protector
6implementation for AArch64 when using dynamically allocated stack space.
7This is CVE-2023-4039. See:
8
9https://developer.arm.com/Arm%20Security%20Center/GCC%20Stack%20Protector%20Vulnerability%20AArch64
10https://github.com/metaredteam/external-disclosures/security/advisories/GHSA-x7ch-h5rf-w2mf
11
12for more details.
13
14The fix is to put the saved registers above the locals area when
15-fstack-protector is used.
16
17The series also fixes a stack-clash problem that I found while working
18on the CVE. In unpatched sources, the stack-clash problem would only
19trigger for unrealistic numbers of arguments (8K 64-bit arguments, or an
20equivalent). But it would be a more significant issue with the new
21-fstack-protector frame layout. It's therefore important that both
22problems are fixed together.
23
24Some reorganisation of the code seemed necessary to fix the problems in a
25cleanish way. The series is therefore quite long, but only a handful of
26patches should have any effect on code generation.
27
28See the individual patches for a detailed description.
29
30Tested on aarch64-linux-gnu. Pushed to trunk and to all active branches.
31I've also pushed backports to GCC 7+ to vendors/ARM/heads/CVE-2023-4039.
32
33CVE: CVE-2023-4039
34Upstream-Status: Submitted
35Signed-off-by: Ross Burton <ross.burton@arm.com>
36
37
38From 78ebdb7b12d5e258b9811bab715734454268fd0c Mon Sep 17 00:00:00 2001
39From: Richard Sandiford <richard.sandiford@arm.com>
40Date: Fri, 16 Jun 2023 17:00:51 +0100
41Subject: [PATCH 01/10] aarch64: Explicitly handle frames with no saved
42 registers
43
44If a frame has no saved registers, it can be allocated in one go.
45There is no need to treat the areas below and above the saved
46registers as separate.
47
48And if we allocate the frame in one go, it should be allocated
49as the initial_adjust rather than the final_adjust. This allows the
50frame size to grow to guard_size - guard_used_by_caller before a stack
51probe is needed. (A frame with no register saves is necessarily a
52leaf frame.)
53
54This is a no-op as thing stand, since a leaf function will have
55no outgoing arguments, and so all the frame will be above where
56the saved registers normally go.
57
58gcc/
59 * config/aarch64/aarch64.c (aarch64_layout_frame): Explicitly
60 allocate the frame in one go if there are no saved registers.
61---
62 gcc/config/aarch64/aarch64.c | 8 +++++---
63 1 file changed, 5 insertions(+), 3 deletions(-)
64
65diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
66index a35dceab9fc..e9dad682738 100644
67--- a/gcc/config/aarch64/aarch64.c
68+++ b/gcc/config/aarch64/aarch64.c
69@@ -4771,9 +4771,11 @@ aarch64_layout_frame (void)
70 max_push_offset = 256;
71
72 HOST_WIDE_INT const_size, const_fp_offset;
73- if (cfun->machine->frame.frame_size.is_constant (&const_size)
74- && const_size < max_push_offset
75- && known_eq (crtl->outgoing_args_size, 0))
76+ if (cfun->machine->frame.saved_regs_size == 0)
77+ cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size;
78+ else if (cfun->machine->frame.frame_size.is_constant (&const_size)
79+ && const_size < max_push_offset
80+ && known_eq (crtl->outgoing_args_size, 0))
81 {
82 /* Simple, small frame with no outgoing arguments:
83 stp reg1, reg2, [sp, -frame_size]!
84--
852.34.1
86
87
88From 347487fffa0266d43bf18f1f91878410881f596e Mon Sep 17 00:00:00 2001
89From: Richard Sandiford <richard.sandiford@arm.com>
90Date: Fri, 16 Jun 2023 16:55:12 +0100
91Subject: [PATCH 02/10] aarch64: Add bytes_below_hard_fp to frame info
92
93The frame layout code currently hard-codes the assumption that
94the number of bytes below the saved registers is equal to the
95size of the outgoing arguments. This patch abstracts that
96value into a new field of aarch64_frame.
97
98gcc/
99 * config/aarch64/aarch64.h (aarch64_frame::bytes_below_hard_fp): New
100 field.
101 * config/aarch64/aarch64.c (aarch64_layout_frame): Initialize it,
102 and use it instead of crtl->outgoing_args_size.
103 (aarch64_get_separate_components): Use bytes_below_hard_fp instead
104 of outgoing_args_size.
105 (aarch64_process_components): Likewise.
106---
107 gcc/config/aarch64/aarch64.c | 50 +++++++++++++++++++-----------------
108 gcc/config/aarch64/aarch64.h | 6 ++++-
109 2 files changed, 32 insertions(+), 24 deletions(-)
110
111diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
112index e9dad682738..25cf10cc4b9 100644
113--- a/gcc/config/aarch64/aarch64.c
114+++ b/gcc/config/aarch64/aarch64.c
115@@ -4684,6 +4684,8 @@ aarch64_layout_frame (void)
116 last_fp_reg = regno;
117 }
118
119+ cfun->machine->frame.bytes_below_hard_fp = crtl->outgoing_args_size;
120+
121 if (cfun->machine->frame.emit_frame_chain)
122 {
123 /* FP and LR are placed in the linkage record. */
124@@ -4751,11 +4753,11 @@ aarch64_layout_frame (void)
125 STACK_BOUNDARY / BITS_PER_UNIT);
126
127 /* Both these values are already aligned. */
128- gcc_assert (multiple_p (crtl->outgoing_args_size,
129+ gcc_assert (multiple_p (cfun->machine->frame.bytes_below_hard_fp,
130 STACK_BOUNDARY / BITS_PER_UNIT));
131 cfun->machine->frame.frame_size
132 = (cfun->machine->frame.hard_fp_offset
133- + crtl->outgoing_args_size);
134+ + cfun->machine->frame.bytes_below_hard_fp);
135
136 cfun->machine->frame.locals_offset = cfun->machine->frame.saved_varargs_size;
137
138@@ -4775,23 +4777,23 @@ aarch64_layout_frame (void)
139 cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size;
140 else if (cfun->machine->frame.frame_size.is_constant (&const_size)
141 && const_size < max_push_offset
142- && known_eq (crtl->outgoing_args_size, 0))
143+ && known_eq (cfun->machine->frame.bytes_below_hard_fp, 0))
144 {
145- /* Simple, small frame with no outgoing arguments:
146+ /* Simple, small frame with no data below the saved registers.
147 stp reg1, reg2, [sp, -frame_size]!
148 stp reg3, reg4, [sp, 16] */
149 cfun->machine->frame.callee_adjust = const_size;
150 }
151- else if (known_lt (crtl->outgoing_args_size
152+ else if (known_lt (cfun->machine->frame.bytes_below_hard_fp
153 + cfun->machine->frame.saved_regs_size, 512)
154 && !(cfun->calls_alloca
155 && known_lt (cfun->machine->frame.hard_fp_offset,
156 max_push_offset)))
157 {
158- /* Frame with small outgoing arguments:
159+ /* Frame with small area below the saved registers:
160 sub sp, sp, frame_size
161- stp reg1, reg2, [sp, outgoing_args_size]
162- stp reg3, reg4, [sp, outgoing_args_size + 16] */
163+ stp reg1, reg2, [sp, bytes_below_hard_fp]
164+ stp reg3, reg4, [sp, bytes_below_hard_fp + 16] */
165 cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size;
166 cfun->machine->frame.callee_offset
167 = cfun->machine->frame.frame_size - cfun->machine->frame.hard_fp_offset;
168@@ -4799,22 +4801,23 @@ aarch64_layout_frame (void)
169 else if (cfun->machine->frame.hard_fp_offset.is_constant (&const_fp_offset)
170 && const_fp_offset < max_push_offset)
171 {
172- /* Frame with large outgoing arguments but a small local area:
173+ /* Frame with large area below the saved registers, but with a
174+ small area above:
175 stp reg1, reg2, [sp, -hard_fp_offset]!
176 stp reg3, reg4, [sp, 16]
177- sub sp, sp, outgoing_args_size */
178+ sub sp, sp, bytes_below_hard_fp */
179 cfun->machine->frame.callee_adjust = const_fp_offset;
180 cfun->machine->frame.final_adjust
181 = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust;
182 }
183 else
184 {
185- /* Frame with large local area and outgoing arguments using frame pointer:
186+ /* General case:
187 sub sp, sp, hard_fp_offset
188 stp x29, x30, [sp, 0]
189 add x29, sp, 0
190 stp reg3, reg4, [sp, 16]
191- sub sp, sp, outgoing_args_size */
192+ sub sp, sp, bytes_below_hard_fp */
193 cfun->machine->frame.initial_adjust = cfun->machine->frame.hard_fp_offset;
194 cfun->machine->frame.final_adjust
195 = cfun->machine->frame.frame_size - cfun->machine->frame.initial_adjust;
196@@ -5243,9 +5246,11 @@ aarch64_get_separate_components (void)
197 if (aarch64_register_saved_on_entry (regno))
198 {
199 poly_int64 offset = cfun->machine->frame.reg_offset[regno];
200+
201+ /* Get the offset relative to the register we'll use. */
202 if (!frame_pointer_needed)
203- offset += cfun->machine->frame.frame_size
204- - cfun->machine->frame.hard_fp_offset;
205+ offset += cfun->machine->frame.bytes_below_hard_fp;
206+
207 /* Check that we can access the stack slot of the register with one
208 direct load with no adjustments needed. */
209 if (offset_12bit_unsigned_scaled_p (DImode, offset))
210@@ -5367,8 +5372,8 @@ aarch64_process_components (sbitmap components, bool prologue_p)
211 rtx reg = gen_rtx_REG (mode, regno);
212 poly_int64 offset = cfun->machine->frame.reg_offset[regno];
213 if (!frame_pointer_needed)
214- offset += cfun->machine->frame.frame_size
215- - cfun->machine->frame.hard_fp_offset;
216+ offset += cfun->machine->frame.bytes_below_hard_fp;
217+
218 rtx addr = plus_constant (Pmode, ptr_reg, offset);
219 rtx mem = gen_frame_mem (mode, addr);
220
221@@ -5410,8 +5415,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
222 /* REGNO2 can be saved/restored in a pair with REGNO. */
223 rtx reg2 = gen_rtx_REG (mode, regno2);
224 if (!frame_pointer_needed)
225- offset2 += cfun->machine->frame.frame_size
226- - cfun->machine->frame.hard_fp_offset;
227+ offset2 += cfun->machine->frame.bytes_below_hard_fp;
228 rtx addr2 = plus_constant (Pmode, ptr_reg, offset2);
229 rtx mem2 = gen_frame_mem (mode, addr2);
230 rtx set2 = prologue_p ? gen_rtx_SET (mem2, reg2)
231@@ -5478,10 +5482,10 @@ aarch64_stack_clash_protection_alloca_probe_range (void)
232 registers. If POLY_SIZE is not large enough to require a probe this function
233 will only adjust the stack. When allocating the stack space
234 FRAME_RELATED_P is then used to indicate if the allocation is frame related.
235- FINAL_ADJUSTMENT_P indicates whether we are allocating the outgoing
236- arguments. If we are then we ensure that any allocation larger than the ABI
237- defined buffer needs a probe so that the invariant of having a 1KB buffer is
238- maintained.
239+ FINAL_ADJUSTMENT_P indicates whether we are allocating the area below
240+ the saved registers. If we are then we ensure that any allocation
241+ larger than the ABI defined buffer needs a probe so that the
242+ invariant of having a 1KB buffer is maintained.
243
244 We emit barriers after each stack adjustment to prevent optimizations from
245 breaking the invariant that we never drop the stack more than a page. This
246@@ -5671,7 +5675,7 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
247 /* Handle any residuals. Residuals of at least MIN_PROBE_THRESHOLD have to
248 be probed. This maintains the requirement that each page is probed at
249 least once. For initial probing we probe only if the allocation is
250- more than GUARD_SIZE - buffer, and for the outgoing arguments we probe
251+ more than GUARD_SIZE - buffer, and below the saved registers we probe
252 if the amount is larger than buffer. GUARD_SIZE - buffer + buffer ==
253 GUARD_SIZE. This works that for any allocation that is large enough to
254 trigger a probe here, we'll have at least one, and if they're not large
255diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
256index af0bc3f1881..95831637ba7 100644
257--- a/gcc/config/aarch64/aarch64.h
258+++ b/gcc/config/aarch64/aarch64.h
259@@ -712,9 +712,13 @@ struct GTY (()) aarch64_frame
260 HOST_WIDE_INT saved_varargs_size;
261
262 /* The size of the saved callee-save int/FP registers. */
263-
264 HOST_WIDE_INT saved_regs_size;
265
266+ /* The number of bytes between the bottom of the static frame (the bottom
267+ of the outgoing arguments) and the hard frame pointer. This value is
268+ always a multiple of STACK_BOUNDARY. */
269+ poly_int64 bytes_below_hard_fp;
270+
271 /* Offset from the base of the frame (incomming SP) to the
272 top of the locals area. This value is always a multiple of
273 STACK_BOUNDARY. */
274--
2752.34.1
276
277
278From 4604c4cd0a6c4c26d6594ec9a0383b4d9197d9df Mon Sep 17 00:00:00 2001
279From: Richard Sandiford <richard.sandiford@arm.com>
280Date: Tue, 27 Jun 2023 11:25:40 +0100
281Subject: [PATCH 03/10] aarch64: Rename locals_offset to bytes_above_locals
282MIME-Version: 1.0
283Content-Type: text/plain; charset=UTF-8
284Content-Transfer-Encoding: 8bit
285
286locals_offset was described as:
287
288 /* Offset from the base of the frame (incomming SP) to the
289 top of the locals area. This value is always a multiple of
290 STACK_BOUNDARY. */
291
292This is implicitly an “upside down” view of the frame: the incoming
293SP is at offset 0, and anything N bytes below the incoming SP is at
294offset N (rather than -N).
295
296However, reg_offset instead uses a “right way up” view; that is,
297it views offsets in address terms. Something above X is at a
298positive offset from X and something below X is at a negative
299offset from X.
300
301Also, even on FRAME_GROWS_DOWNWARD targets like AArch64,
302target-independent code views offsets in address terms too:
303locals are allocated at negative offsets to virtual_stack_vars.
304
305It seems confusing to have *_offset fields of the same structure
306using different polarities like this. This patch tries to avoid
307that by renaming locals_offset to bytes_above_locals.
308
309gcc/
310 * config/aarch64/aarch64.h (aarch64_frame::locals_offset): Rename to...
311 (aarch64_frame::bytes_above_locals): ...this.
312 * config/aarch64/aarch64.c (aarch64_layout_frame)
313 (aarch64_initial_elimination_offset): Update accordingly.
314---
315 gcc/config/aarch64/aarch64.c | 9 +++++----
316 gcc/config/aarch64/aarch64.h | 6 +++---
317 2 files changed, 8 insertions(+), 7 deletions(-)
318
319diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
320index 25cf10cc4b9..dcaf491af42 100644
321--- a/gcc/config/aarch64/aarch64.c
322+++ b/gcc/config/aarch64/aarch64.c
323@@ -4759,7 +4759,8 @@ aarch64_layout_frame (void)
324 = (cfun->machine->frame.hard_fp_offset
325 + cfun->machine->frame.bytes_below_hard_fp);
326
327- cfun->machine->frame.locals_offset = cfun->machine->frame.saved_varargs_size;
328+ cfun->machine->frame.bytes_above_locals
329+ = cfun->machine->frame.saved_varargs_size;
330
331 cfun->machine->frame.initial_adjust = 0;
332 cfun->machine->frame.final_adjust = 0;
333@@ -8566,14 +8567,14 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to)
334
335 if (from == FRAME_POINTER_REGNUM)
336 return cfun->machine->frame.hard_fp_offset
337- - cfun->machine->frame.locals_offset;
338+ - cfun->machine->frame.bytes_above_locals;
339 }
340
341 if (to == STACK_POINTER_REGNUM)
342 {
343 if (from == FRAME_POINTER_REGNUM)
344- return cfun->machine->frame.frame_size
345- - cfun->machine->frame.locals_offset;
346+ return cfun->machine->frame.frame_size
347+ - cfun->machine->frame.bytes_above_locals;
348 }
349
350 return cfun->machine->frame.frame_size;
351diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
352index 95831637ba7..a079a88b4f4 100644
353--- a/gcc/config/aarch64/aarch64.h
354+++ b/gcc/config/aarch64/aarch64.h
355@@ -719,10 +719,10 @@ struct GTY (()) aarch64_frame
356 always a multiple of STACK_BOUNDARY. */
357 poly_int64 bytes_below_hard_fp;
358
359- /* Offset from the base of the frame (incomming SP) to the
360- top of the locals area. This value is always a multiple of
361+ /* The number of bytes between the top of the locals area and the top
362+ of the frame (the incomming SP). This value is always a multiple of
363 STACK_BOUNDARY. */
364- poly_int64 locals_offset;
365+ poly_int64 bytes_above_locals;
366
367 /* Offset from the base of the frame (incomming SP) to the
368 hard_frame_pointer. This value is always a multiple of
369--
3702.34.1
371
372
373From 16016465ff28a75f5e0540cbaeb4eb102fdc3230 Mon Sep 17 00:00:00 2001
374From: Richard Sandiford <richard.sandiford@arm.com>
375Date: Tue, 27 Jun 2023 11:28:11 +0100
376Subject: [PATCH 04/10] aarch64: Rename hard_fp_offset to bytes_above_hard_fp
377MIME-Version: 1.0
378Content-Type: text/plain; charset=UTF-8
379Content-Transfer-Encoding: 8bit
380
381Similarly to the previous locals_offset patch, hard_fp_offset
382was described as:
383
384 /* Offset from the base of the frame (incomming SP) to the
385 hard_frame_pointer. This value is always a multiple of
386 STACK_BOUNDARY. */
387 poly_int64 hard_fp_offset;
388
389which again took an “upside-down” view: higher offsets meant lower
390addresses. This patch renames the field to bytes_above_hard_fp instead.
391
392gcc/
393 * config/aarch64/aarch64.h (aarch64_frame::hard_fp_offset): Rename
394 to...
395 (aarch64_frame::bytes_above_hard_fp): ...this.
396 * config/aarch64/aarch64.c (aarch64_layout_frame)
397 (aarch64_expand_prologue): Update accordingly.
398 (aarch64_initial_elimination_offset): Likewise.
399---
400 gcc/config/aarch64/aarch64.c | 21 +++++++++++----------
401 gcc/config/aarch64/aarch64.h | 6 +++---
402 2 files changed, 14 insertions(+), 13 deletions(-)
403
404diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
405index dcaf491af42..2681e0c2bb9 100644
406--- a/gcc/config/aarch64/aarch64.c
407+++ b/gcc/config/aarch64/aarch64.c
408@@ -4747,7 +4747,7 @@ aarch64_layout_frame (void)
409 HOST_WIDE_INT varargs_and_saved_regs_size
410 = offset + cfun->machine->frame.saved_varargs_size;
411
412- cfun->machine->frame.hard_fp_offset
413+ cfun->machine->frame.bytes_above_hard_fp
414 = aligned_upper_bound (varargs_and_saved_regs_size
415 + get_frame_size (),
416 STACK_BOUNDARY / BITS_PER_UNIT);
417@@ -4756,7 +4756,7 @@ aarch64_layout_frame (void)
418 gcc_assert (multiple_p (cfun->machine->frame.bytes_below_hard_fp,
419 STACK_BOUNDARY / BITS_PER_UNIT));
420 cfun->machine->frame.frame_size
421- = (cfun->machine->frame.hard_fp_offset
422+ = (cfun->machine->frame.bytes_above_hard_fp
423 + cfun->machine->frame.bytes_below_hard_fp);
424
425 cfun->machine->frame.bytes_above_locals
426@@ -4788,7 +4788,7 @@ aarch64_layout_frame (void)
427 else if (known_lt (cfun->machine->frame.bytes_below_hard_fp
428 + cfun->machine->frame.saved_regs_size, 512)
429 && !(cfun->calls_alloca
430- && known_lt (cfun->machine->frame.hard_fp_offset,
431+ && known_lt (cfun->machine->frame.bytes_above_hard_fp,
432 max_push_offset)))
433 {
434 /* Frame with small area below the saved registers:
435@@ -4797,14 +4797,14 @@ aarch64_layout_frame (void)
436 stp reg3, reg4, [sp, bytes_below_hard_fp + 16] */
437 cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size;
438 cfun->machine->frame.callee_offset
439- = cfun->machine->frame.frame_size - cfun->machine->frame.hard_fp_offset;
440+ = cfun->machine->frame.frame_size - cfun->machine->frame.bytes_above_hard_fp;
441 }
442- else if (cfun->machine->frame.hard_fp_offset.is_constant (&const_fp_offset)
443+ else if (cfun->machine->frame.bytes_above_hard_fp.is_constant (&const_fp_offset)
444 && const_fp_offset < max_push_offset)
445 {
446 /* Frame with large area below the saved registers, but with a
447 small area above:
448- stp reg1, reg2, [sp, -hard_fp_offset]!
449+ stp reg1, reg2, [sp, -bytes_above_hard_fp]!
450 stp reg3, reg4, [sp, 16]
451 sub sp, sp, bytes_below_hard_fp */
452 cfun->machine->frame.callee_adjust = const_fp_offset;
453@@ -4814,12 +4814,13 @@ aarch64_layout_frame (void)
454 else
455 {
456 /* General case:
457- sub sp, sp, hard_fp_offset
458+ sub sp, sp, bytes_above_hard_fp
459 stp x29, x30, [sp, 0]
460 add x29, sp, 0
461 stp reg3, reg4, [sp, 16]
462 sub sp, sp, bytes_below_hard_fp */
463- cfun->machine->frame.initial_adjust = cfun->machine->frame.hard_fp_offset;
464+ cfun->machine->frame.initial_adjust
465+ = cfun->machine->frame.bytes_above_hard_fp;
466 cfun->machine->frame.final_adjust
467 = cfun->machine->frame.frame_size - cfun->machine->frame.initial_adjust;
468 }
469@@ -8563,10 +8564,10 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to)
470 if (to == HARD_FRAME_POINTER_REGNUM)
471 {
472 if (from == ARG_POINTER_REGNUM)
473- return cfun->machine->frame.hard_fp_offset;
474+ return cfun->machine->frame.bytes_above_hard_fp;
475
476 if (from == FRAME_POINTER_REGNUM)
477- return cfun->machine->frame.hard_fp_offset
478+ return cfun->machine->frame.bytes_above_hard_fp
479 - cfun->machine->frame.bytes_above_locals;
480 }
481
482diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
483index a079a88b4f4..eab6da84a02 100644
484--- a/gcc/config/aarch64/aarch64.h
485+++ b/gcc/config/aarch64/aarch64.h
486@@ -724,10 +724,10 @@ struct GTY (()) aarch64_frame
487 STACK_BOUNDARY. */
488 poly_int64 bytes_above_locals;
489
490- /* Offset from the base of the frame (incomming SP) to the
491- hard_frame_pointer. This value is always a multiple of
492+ /* The number of bytes between the hard_frame_pointer and the top of
493+ the frame (the incomming SP). This value is always a multiple of
494 STACK_BOUNDARY. */
495- poly_int64 hard_fp_offset;
496+ poly_int64 bytes_above_hard_fp;
497
498 /* The size of the frame. This value is the offset from base of the
499 frame (incomming SP) to the stack_pointer. This value is always
500--
5012.34.1
502
503
504From eb2271eb6bb68ec3c9aa9ae4746ea1ee5f18874a Mon Sep 17 00:00:00 2001
505From: Richard Sandiford <richard.sandiford@arm.com>
506Date: Thu, 22 Jun 2023 22:26:30 +0100
507Subject: [PATCH 05/10] aarch64: Tweak frame_size comment
508MIME-Version: 1.0
509Content-Type: text/plain; charset=UTF-8
510Content-Transfer-Encoding: 8bit
511
512This patch fixes another case in which a value was described with
513an “upside-down” view.
514
515gcc/
516 * config/aarch64/aarch64.h (aarch64_frame::frame_size): Tweak comment.
517---
518 gcc/config/aarch64/aarch64.h | 4 ++--
519 1 file changed, 2 insertions(+), 2 deletions(-)
520
521diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
522index eab6da84a02..7c4b65ec55b 100644
523--- a/gcc/config/aarch64/aarch64.h
524+++ b/gcc/config/aarch64/aarch64.h
525@@ -729,8 +729,8 @@ struct GTY (()) aarch64_frame
526 STACK_BOUNDARY. */
527 poly_int64 bytes_above_hard_fp;
528
529- /* The size of the frame. This value is the offset from base of the
530- frame (incomming SP) to the stack_pointer. This value is always
531+ /* The size of the frame, i.e. the number of bytes between the bottom
532+ of the outgoing arguments and the incoming SP. This value is always
533 a multiple of STACK_BOUNDARY. */
534 poly_int64 frame_size;
535
536--
5372.34.1
538
539
540From cfed3b87e9351edff1568ade4ef666edc9887639 Mon Sep 17 00:00:00 2001
541From: Richard Sandiford <richard.sandiford@arm.com>
542Date: Tue, 15 Aug 2023 19:05:30 +0100
543Subject: [PATCH 06/10] Backport check-function-bodies support
544
545---
546 gcc/testsuite/lib/scanasm.exp | 191 ++++++++++++++++++++++++++++++++++
547 1 file changed, 191 insertions(+)
548
549diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
550index 35ccbc86fc0..c9af27bf47a 100644
551--- a/gcc/testsuite/lib/scanasm.exp
552+++ b/gcc/testsuite/lib/scanasm.exp
553@@ -546,3 +546,194 @@ proc scan-lto-assembler { args } {
554 verbose "output_file: $output_file"
555 dg-scan "scan-lto-assembler" 1 $testcase $output_file $args
556 }
557+
558+# Read assembly file FILENAME and store a mapping from function names
559+# to function bodies in array RESULT. FILENAME has already been uploaded
560+# locally where necessary and is known to exist.
561+
562+proc parse_function_bodies { filename result } {
563+ upvar $result up_result
564+
565+ # Regexp for the start of a function definition (name in \1).
566+ set label {^([a-zA-Z_]\S+):$}
567+
568+ # Regexp for the end of a function definition.
569+ set terminator {^\s*\.size}
570+
571+ # Regexp for lines that aren't interesting.
572+ set fluff {^\s*(?:\.|//|@|$)}
573+
574+ set fd [open $filename r]
575+ set in_function 0
576+ while { [gets $fd line] >= 0 } {
577+ if { [regexp $label $line dummy function_name] } {
578+ set in_function 1
579+ set function_body ""
580+ } elseif { $in_function } {
581+ if { [regexp $terminator $line] } {
582+ set up_result($function_name) $function_body
583+ set in_function 0
584+ } elseif { ![regexp $fluff $line] } {
585+ append function_body $line "\n"
586+ }
587+ }
588+ }
589+ close $fd
590+}
591+
592+# FUNCTIONS is an array that maps function names to function bodies.
593+# Return true if it contains a definition of function NAME and if
594+# that definition matches BODY_REGEXP.
595+
596+proc check_function_body { functions name body_regexp } {
597+ upvar $functions up_functions
598+
599+ if { ![info exists up_functions($name)] } {
600+ return 0
601+ }
602+ set fn_res [regexp "^$body_regexp\$" $up_functions($name)]
603+ if { !$fn_res } {
604+ verbose -log "body: $body_regexp"
605+ verbose -log "against: $up_functions($name)"
606+ }
607+ return $fn_res
608+}
609+
610+# Check the implementations of functions against expected output. Used as:
611+#
612+# { dg-do { check-function-bodies PREFIX TERMINATOR[ OPTION[ SELECTOR]] } }
613+#
614+# See sourcebuild.texi for details.
615+
616+proc check-function-bodies { args } {
617+ if { [llength $args] < 2 } {
618+ error "too few arguments to check-function-bodies"
619+ }
620+ if { [llength $args] > 4 } {
621+ error "too many arguments to check-function-bodies"
622+ }
623+
624+ if { [llength $args] >= 3 } {
625+ set required_flags [lindex $args 2]
626+
627+ upvar 2 dg-extra-tool-flags extra_tool_flags
628+ set flags $extra_tool_flags
629+
630+ global torture_current_flags
631+ if { [info exists torture_current_flags] } {
632+ append flags " " $torture_current_flags
633+ }
634+ foreach required_flag $required_flags {
635+ switch -- $required_flag {
636+ target -
637+ xfail {
638+ error "misplaced $required_flag in check-function-bodies"
639+ }
640+ }
641+ }
642+ foreach required_flag $required_flags {
643+ if { ![regexp " $required_flag " $flags] } {
644+ return
645+ }
646+ }
647+ }
648+
649+ set xfail_all 0
650+ if { [llength $args] >= 4 } {
651+ switch [dg-process-target [lindex $args 3]] {
652+ "S" { }
653+ "N" { return }
654+ "F" { set xfail_all 1 }
655+ "P" { }
656+ }
657+ }
658+
659+ set testcase [testname-for-summary]
660+ # The name might include a list of options; extract the file name.
661+ set filename [lindex $testcase 0]
662+
663+ global srcdir
664+ set input_filename "$srcdir/$filename"
665+ set output_filename "[file rootname [file tail $filename]].s"
666+
667+ set prefix [lindex $args 0]
668+ set prefix_len [string length $prefix]
669+ set terminator [lindex $args 1]
670+ if { [string equal $terminator ""] } {
671+ set terminator "*/"
672+ }
673+ set terminator_len [string length $terminator]
674+
675+ set have_bodies 0
676+ if { [is_remote host] } {
677+ remote_upload host "$filename"
678+ }
679+ if { [file exists $output_filename] } {
680+ parse_function_bodies $output_filename functions
681+ set have_bodies 1
682+ } else {
683+ verbose -log "$testcase: output file does not exist"
684+ }
685+
686+ set count 0
687+ set function_regexp ""
688+ set label {^(\S+):$}
689+
690+ set lineno 1
691+ set fd [open $input_filename r]
692+ set in_function 0
693+ while { [gets $fd line] >= 0 } {
694+ if { [string equal -length $prefix_len $line $prefix] } {
695+ set line [string trim [string range $line $prefix_len end]]
696+ if { !$in_function } {
697+ if { [regexp "^(.*?\\S)\\s+{(.*)}\$" $line dummy \
698+ line selector] } {
699+ set selector [dg-process-target $selector]
700+ } else {
701+ set selector "P"
702+ }
703+ if { ![regexp $label $line dummy function_name] } {
704+ close $fd
705+ error "check-function-bodies: line $lineno does not have a function label"
706+ }
707+ set in_function 1
708+ set function_regexp ""
709+ } elseif { [string equal $line "("] } {
710+ append function_regexp "(?:"
711+ } elseif { [string equal $line "|"] } {
712+ append function_regexp "|"
713+ } elseif { [string equal $line ")"] } {
714+ append function_regexp ")"
715+ } elseif { [string equal $line "..."] } {
716+ append function_regexp ".*"
717+ } else {
718+ append function_regexp "\t" $line "\n"
719+ }
720+ } elseif { [string equal -length $terminator_len $line $terminator] } {
721+ if { ![string equal $selector "N"] } {
722+ if { $xfail_all || [string equal $selector "F"] } {
723+ setup_xfail "*-*-*"
724+ }
725+ set testname "$testcase check-function-bodies $function_name"
726+ if { !$have_bodies } {
727+ unresolved $testname
728+ } elseif { [check_function_body functions $function_name \
729+ $function_regexp] } {
730+ pass $testname
731+ } else {
732+ fail $testname
733+ }
734+ }
735+ set in_function 0
736+ incr count
737+ }
738+ incr lineno
739+ }
740+ close $fd
741+ if { $in_function } {
742+ error "check-function-bodies: missing \"$terminator\""
743+ }
744+ if { $count == 0 } {
745+ error "check-function-bodies: no matches found"
746+ }
747+}
748--
7492.34.1
750
751
752From 4dd8925d95d3d6d89779b494b5f4cfadcf9fa96e Mon Sep 17 00:00:00 2001
753From: Richard Sandiford <richard.sandiford@arm.com>
754Date: Tue, 27 Jun 2023 15:11:44 +0100
755Subject: [PATCH 07/10] aarch64: Tweak stack clash boundary condition
756
757The AArch64 ABI says that, when stack clash protection is used,
758there can be a maximum of 1KiB of unprobed space at sp on entry
759to a function. Therefore, we need to probe when allocating
760>= guard_size - 1KiB of data (>= rather than >). This is what
761GCC does.
762
763If an allocation is exactly guard_size bytes, it is enough to allocate
764those bytes and probe once at offset 1024. It isn't possible to use a
765single probe at any other offset: higher would conmplicate later code,
766by leaving more unprobed space than usual, while lower would risk
767leaving an entire page unprobed. For simplicity, the code probes all
768allocations at offset 1024.
769
770Some register saves also act as probes. If we need to allocate
771more space below the last such register save probe, we need to
772probe the allocation if it is > 1KiB. Again, this allocation is
773then sometimes (but not always) probed at offset 1024. This sort of
774allocation is currently only used for outgoing arguments, which are
775rarely this big.
776
777However, the code also probed if this final outgoing-arguments
778allocation was == 1KiB, rather than just > 1KiB. This isn't
779necessary, since the register save then probes at offset 1024
780as required. Continuing to probe allocations of exactly 1KiB
781would complicate later patches.
782
783gcc/
784 * config/aarch64/aarch64.c (aarch64_allocate_and_probe_stack_space):
785 Don't probe final allocations that are exactly 1KiB in size (after
786 unprobed space above the final allocation has been deducted).
787
788gcc/testsuite/
789 * gcc.target/aarch64/stack-check-prologue-17.c: New test.
790---
791 gcc/config/aarch64/aarch64.c | 6 +-
792 .../aarch64/stack-check-prologue-17.c | 55 +++++++++++++++++++
793 2 files changed, 60 insertions(+), 1 deletion(-)
794 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
795
796diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
797index 2681e0c2bb9..4c9e11cd7cf 100644
798--- a/gcc/config/aarch64/aarch64.c
799+++ b/gcc/config/aarch64/aarch64.c
800@@ -5506,6 +5506,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
801 HOST_WIDE_INT guard_size
802 = 1 << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE);
803 HOST_WIDE_INT guard_used_by_caller = STACK_CLASH_CALLER_GUARD;
804+ HOST_WIDE_INT byte_sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
805+ gcc_assert (multiple_p (poly_size, byte_sp_alignment));
806 /* When doing the final adjustment for the outgoing argument size we can't
807 assume that LR was saved at position 0. So subtract it's offset from the
808 ABI safe buffer so that we don't accidentally allow an adjustment that
809@@ -5513,7 +5515,9 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
810 probing. */
811 HOST_WIDE_INT min_probe_threshold
812 = final_adjustment_p
813- ? guard_used_by_caller - cfun->machine->frame.reg_offset[LR_REGNUM]
814+ ? (guard_used_by_caller
815+ + byte_sp_alignment
816+ - cfun->machine->frame.reg_offset[LR_REGNUM])
817 : guard_size - guard_used_by_caller;
818
819 poly_int64 frame_size = cfun->machine->frame.frame_size;
820diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
821new file mode 100644
822index 00000000000..0d8a25d73a2
823--- /dev/null
824+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
825@@ -0,0 +1,55 @@
826+/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12" } */
827+/* { dg-final { check-function-bodies "**" "" } } */
828+
829+void f(int, ...);
830+void g();
831+
832+/*
833+** test1:
834+** ...
835+** str x30, \[sp\]
836+** sub sp, sp, #1024
837+** cbnz w0, .*
838+** bl g
839+** ...
840+*/
841+int test1(int z) {
842+ __uint128_t x = 0;
843+ int y[0x400];
844+ if (z)
845+ {
846+ f(0, 0, 0, 0, 0, 0, 0, &y,
847+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
848+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
849+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
850+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x);
851+ }
852+ g();
853+ return 1;
854+}
855+
856+/*
857+** test2:
858+** ...
859+** str x30, \[sp\]
860+** sub sp, sp, #1040
861+** str xzr, \[sp\]
862+** cbnz w0, .*
863+** bl g
864+** ...
865+*/
866+int test2(int z) {
867+ __uint128_t x = 0;
868+ int y[0x400];
869+ if (z)
870+ {
871+ f(0, 0, 0, 0, 0, 0, 0, &y,
872+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
873+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
874+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
875+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
876+ x);
877+ }
878+ g();
879+ return 1;
880+}
881--
8822.34.1
883
884
885From 12517baf6c88447e3bda3a459ac4c29d61f84e6c Mon Sep 17 00:00:00 2001
886From: Richard Sandiford <richard.sandiford@arm.com>
887Date: Tue, 27 Jun 2023 15:12:55 +0100
888Subject: [PATCH 08/10] aarch64: Put LR save probe in first 16 bytes
889
890-fstack-clash-protection uses the save of LR as a probe for the next
891allocation. The next allocation could be:
892
893* another part of the static frame, e.g. when allocating SVE save slots
894 or outgoing arguments
895
896* an alloca in the same function
897
898* an allocation made by a callee function
899
900However, when -fomit-frame-pointer is used, the LR save slot is placed
901above the other GPR save slots. It could therefore be up to 80 bytes
902above the base of the GPR save area (which is also the hard fp address).
903
904aarch64_allocate_and_probe_stack_space took this into account when
905deciding how much subsequent space could be allocated without needing
906a probe. However, it interacted badly with:
907
908 /* If doing a small final adjustment, we always probe at offset 0.
909 This is done to avoid issues when LR is not at position 0 or when
910 the final adjustment is smaller than the probing offset. */
911 else if (final_adjustment_p && rounded_size == 0)
912 residual_probe_offset = 0;
913
914which forces any allocation that is smaller than the guard page size
915to be probed at offset 0 rather than the usual offset 1024. It was
916therefore possible to construct cases in which we had:
917
918* a probe using LR at SP + 80 bytes (or some other value >= 16)
919* an allocation of the guard page size - 16 bytes
920* a probe at SP + 0
921
922which allocates guard page size + 64 consecutive unprobed bytes.
923
924This patch requires the LR probe to be in the first 16 bytes of the
925save area when stack clash protection is active. Doing it
926unconditionally would cause code-quality regressions.
927
928gcc/
929 * config/aarch64/aarch64.c (aarch64_layout_frame): Ensure that
930 the LR save slot is in the first 16 bytes of the register save area.
931 (aarch64_allocate_and_probe_stack_space): Remove workaround for
932 when LR was not in the first 16 bytes.
933
934gcc/testsuite/
935 * gcc.target/aarch64/stack-check-prologue-18.c: New test.
936---
937 gcc/config/aarch64/aarch64.c | 50 +++++----
938 .../aarch64/stack-check-prologue-18.c | 100 ++++++++++++++++++
939 2 files changed, 127 insertions(+), 23 deletions(-)
940 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
941
942diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
943index 4c9e11cd7cf..1e8467fdd03 100644
944--- a/gcc/config/aarch64/aarch64.c
945+++ b/gcc/config/aarch64/aarch64.c
946@@ -4686,15 +4686,31 @@ aarch64_layout_frame (void)
947
948 cfun->machine->frame.bytes_below_hard_fp = crtl->outgoing_args_size;
949
950+#define ALLOCATE_GPR_SLOT(REGNO) \
951+ do \
952+ { \
953+ cfun->machine->frame.reg_offset[REGNO] = offset; \
954+ if (cfun->machine->frame.wb_candidate1 == INVALID_REGNUM) \
955+ cfun->machine->frame.wb_candidate1 = (REGNO); \
956+ else if (cfun->machine->frame.wb_candidate2 == INVALID_REGNUM) \
957+ cfun->machine->frame.wb_candidate2 = (REGNO); \
958+ offset += UNITS_PER_WORD; \
959+ } \
960+ while (0)
961+
962 if (cfun->machine->frame.emit_frame_chain)
963 {
964 /* FP and LR are placed in the linkage record. */
965- cfun->machine->frame.reg_offset[R29_REGNUM] = 0;
966- cfun->machine->frame.wb_candidate1 = R29_REGNUM;
967- cfun->machine->frame.reg_offset[R30_REGNUM] = UNITS_PER_WORD;
968- cfun->machine->frame.wb_candidate2 = R30_REGNUM;
969- offset = 2 * UNITS_PER_WORD;
970+ ALLOCATE_GPR_SLOT (R29_REGNUM);
971+ ALLOCATE_GPR_SLOT (R30_REGNUM);
972 }
973+ else if (flag_stack_clash_protection
974+ && cfun->machine->frame.reg_offset[R30_REGNUM] == SLOT_REQUIRED)
975+ /* Put the LR save slot first, since it makes a good choice of probe
976+ for stack clash purposes. The idea is that the link register usually
977+ has to be saved before a call anyway, and so we lose little by
978+ stopping it from being individually shrink-wrapped. */
979+ ALLOCATE_GPR_SLOT (R30_REGNUM);
980
981 /* With stack-clash, LR must be saved in non-leaf functions. */
982 gcc_assert (crtl->is_leaf
983@@ -4704,14 +4720,9 @@ aarch64_layout_frame (void)
984 /* Now assign stack slots for them. */
985 for (regno = R0_REGNUM; regno <= R30_REGNUM; regno++)
986 if (cfun->machine->frame.reg_offset[regno] == SLOT_REQUIRED)
987- {
988- cfun->machine->frame.reg_offset[regno] = offset;
989- if (cfun->machine->frame.wb_candidate1 == INVALID_REGNUM)
990- cfun->machine->frame.wb_candidate1 = regno;
991- else if (cfun->machine->frame.wb_candidate2 == INVALID_REGNUM)
992- cfun->machine->frame.wb_candidate2 = regno;
993- offset += UNITS_PER_WORD;
994- }
995+ ALLOCATE_GPR_SLOT (regno);
996+
997+#undef ALLOCATE_GPR_SLOT
998
999 HOST_WIDE_INT max_int_offset = offset;
1000 offset = ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT);
1001@@ -5508,16 +5519,9 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1002 HOST_WIDE_INT guard_used_by_caller = STACK_CLASH_CALLER_GUARD;
1003 HOST_WIDE_INT byte_sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
1004 gcc_assert (multiple_p (poly_size, byte_sp_alignment));
1005- /* When doing the final adjustment for the outgoing argument size we can't
1006- assume that LR was saved at position 0. So subtract it's offset from the
1007- ABI safe buffer so that we don't accidentally allow an adjustment that
1008- would result in an allocation larger than the ABI buffer without
1009- probing. */
1010 HOST_WIDE_INT min_probe_threshold
1011 = final_adjustment_p
1012- ? (guard_used_by_caller
1013- + byte_sp_alignment
1014- - cfun->machine->frame.reg_offset[LR_REGNUM])
1015+ ? guard_used_by_caller + byte_sp_alignment
1016 : guard_size - guard_used_by_caller;
1017
1018 poly_int64 frame_size = cfun->machine->frame.frame_size;
1019@@ -5697,8 +5701,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1020 if (final_adjustment_p && rounded_size != 0)
1021 min_probe_threshold = 0;
1022 /* If doing a small final adjustment, we always probe at offset 0.
1023- This is done to avoid issues when LR is not at position 0 or when
1024- the final adjustment is smaller than the probing offset. */
1025+ This is done to avoid issues when the final adjustment is smaller
1026+ than the probing offset. */
1027 else if (final_adjustment_p && rounded_size == 0)
1028 residual_probe_offset = 0;
1029
1030diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1031new file mode 100644
1032index 00000000000..82447d20fff
1033--- /dev/null
1034+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1035@@ -0,0 +1,100 @@
1036+/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12" } */
1037+/* { dg-final { check-function-bodies "**" "" } } */
1038+
1039+void f(int, ...);
1040+void g();
1041+
1042+/*
1043+** test1:
1044+** ...
1045+** str x30, \[sp\]
1046+** sub sp, sp, #4064
1047+** str xzr, \[sp\]
1048+** cbnz w0, .*
1049+** bl g
1050+** ...
1051+** str x26, \[sp, #?4128\]
1052+** ...
1053+*/
1054+int test1(int z) {
1055+ __uint128_t x = 0;
1056+ int y[0x400];
1057+ if (z)
1058+ {
1059+ asm volatile ("" :::
1060+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
1061+ f(0, 0, 0, 0, 0, 0, 0, &y,
1062+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1063+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1064+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1065+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1066+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1067+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1068+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1069+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1070+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1071+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1072+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1073+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1074+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1075+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1076+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1077+ x, x, x, x, x, x, x, x, x, x, x, x, x, x);
1078+ }
1079+ g();
1080+ return 1;
1081+}
1082+
1083+/*
1084+** test2:
1085+** ...
1086+** str x30, \[sp\]
1087+** sub sp, sp, #1040
1088+** str xzr, \[sp\]
1089+** cbnz w0, .*
1090+** bl g
1091+** ...
1092+*/
1093+int test2(int z) {
1094+ __uint128_t x = 0;
1095+ int y[0x400];
1096+ if (z)
1097+ {
1098+ asm volatile ("" :::
1099+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
1100+ f(0, 0, 0, 0, 0, 0, 0, &y,
1101+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1102+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1103+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1104+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1105+ x);
1106+ }
1107+ g();
1108+ return 1;
1109+}
1110+
1111+/*
1112+** test3:
1113+** ...
1114+** str x30, \[sp\]
1115+** sub sp, sp, #1024
1116+** cbnz w0, .*
1117+** bl g
1118+** ...
1119+*/
1120+int test3(int z) {
1121+ __uint128_t x = 0;
1122+ int y[0x400];
1123+ if (z)
1124+ {
1125+ asm volatile ("" :::
1126+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
1127+ f(0, 0, 0, 0, 0, 0, 0, &y,
1128+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1129+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1130+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1131+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x);
1132+ }
1133+ g();
1134+ return 1;
1135+}
1136--
11372.34.1
1138
1139
1140From f2684e63652bb251d22c79e40081c646df1f36b6 Mon Sep 17 00:00:00 2001
1141From: Richard Sandiford <richard.sandiford@arm.com>
1142Date: Tue, 8 Aug 2023 01:57:26 +0100
1143Subject: [PATCH 09/10] aarch64: Simplify probe of final frame allocation
1144
1145Previous patches ensured that the final frame allocation only needs
1146a probe when the size is strictly greater than 1KiB. It's therefore
1147safe to use the normal 1024 probe offset in all cases.
1148
1149The main motivation for doing this is to simplify the code and
1150remove the number of special cases.
1151
1152gcc/
1153 * config/aarch64/aarch64.c (aarch64_allocate_and_probe_stack_space):
1154 Always probe the residual allocation at offset 1024, asserting
1155 that that is in range.
1156
1157gcc/testsuite/
1158 * gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe
1159 to be at offset 1024 rather than offset 0.
1160 * gcc.target/aarch64/stack-check-prologue-18.c: Likewise.
1161---
1162 gcc/config/aarch64/aarch64.c | 12 ++++--------
1163 .../gcc.target/aarch64/stack-check-prologue-17.c | 2 +-
1164 .../gcc.target/aarch64/stack-check-prologue-18.c | 7 +++++--
1165 3 files changed, 10 insertions(+), 11 deletions(-)
1166
1167diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
1168index 1e8467fdd03..705f719a2ea 100644
1169--- a/gcc/config/aarch64/aarch64.c
1170+++ b/gcc/config/aarch64/aarch64.c
1171@@ -5695,16 +5695,12 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1172 are still safe. */
1173 if (residual)
1174 {
1175- HOST_WIDE_INT residual_probe_offset = guard_used_by_caller;
1176+ gcc_assert (guard_used_by_caller + byte_sp_alignment <= size);
1177+
1178 /* If we're doing final adjustments, and we've done any full page
1179 allocations then any residual needs to be probed. */
1180 if (final_adjustment_p && rounded_size != 0)
1181 min_probe_threshold = 0;
1182- /* If doing a small final adjustment, we always probe at offset 0.
1183- This is done to avoid issues when the final adjustment is smaller
1184- than the probing offset. */
1185- else if (final_adjustment_p && rounded_size == 0)
1186- residual_probe_offset = 0;
1187
1188 aarch64_sub_sp (temp1, temp2, residual, frame_related_p);
1189 if (residual >= min_probe_threshold)
1190@@ -5715,8 +5711,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1191 HOST_WIDE_INT_PRINT_DEC " bytes, probing will be required."
1192 "\n", residual);
1193
1194- emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
1195- residual_probe_offset));
1196+ emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
1197+ guard_used_by_caller));
1198 emit_insn (gen_blockage ());
1199 }
1200 }
1201diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1202index 0d8a25d73a2..f0ec1389771 100644
1203--- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1204+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1205@@ -33,7 +33,7 @@ int test1(int z) {
1206 ** ...
1207 ** str x30, \[sp\]
1208 ** sub sp, sp, #1040
1209-** str xzr, \[sp\]
1210+** str xzr, \[sp, #?1024\]
1211 ** cbnz w0, .*
1212 ** bl g
1213 ** ...
1214diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1215index 82447d20fff..71d33ba34e9 100644
1216--- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1217+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1218@@ -8,8 +8,9 @@ void g();
1219 ** test1:
1220 ** ...
1221 ** str x30, \[sp\]
1222+** ...
1223 ** sub sp, sp, #4064
1224-** str xzr, \[sp\]
1225+** str xzr, \[sp, #?1024\]
1226 ** cbnz w0, .*
1227 ** bl g
1228 ** ...
1229@@ -49,8 +50,9 @@ int test1(int z) {
1230 ** test2:
1231 ** ...
1232 ** str x30, \[sp\]
1233+** ...
1234 ** sub sp, sp, #1040
1235-** str xzr, \[sp\]
1236+** str xzr, \[sp, #?1024\]
1237 ** cbnz w0, .*
1238 ** bl g
1239 ** ...
1240@@ -77,6 +79,7 @@ int test2(int z) {
1241 ** test3:
1242 ** ...
1243 ** str x30, \[sp\]
1244+** ...
1245 ** sub sp, sp, #1024
1246 ** cbnz w0, .*
1247 ** bl g
1248--
12492.34.1
1250
1251
1252From bf3eeaa0182a92987570d9c787bd45079eebf528 Mon Sep 17 00:00:00 2001
1253From: Richard Sandiford <richard.sandiford@arm.com>
1254Date: Thu, 15 Jun 2023 19:16:52 +0100
1255Subject: [PATCH 10/10] aarch64: Make stack smash canary protect saved
1256 registers
1257
1258AArch64 normally puts the saved registers near the bottom of the frame,
1259immediately above any dynamic allocations. But this means that a
1260stack-smash attack on those dynamic allocations could overwrite the
1261saved registers without needing to reach as far as the stack smash
1262canary.
1263
1264The same thing could also happen for variable-sized arguments that are
1265passed by value, since those are allocated before a call and popped on
1266return.
1267
1268This patch avoids that by putting the locals (and thus the canary) below
1269the saved registers when stack smash protection is active.
1270
1271The patch fixes CVE-2023-4039.
1272
1273gcc/
1274 * config/aarch64/aarch64.c (aarch64_save_regs_above_locals_p):
1275 New function.
1276 (aarch64_layout_frame): Use it to decide whether locals should
1277 go above or below the saved registers.
1278 (aarch64_expand_prologue): Update stack layout comment.
1279 Emit a stack tie after the final adjustment.
1280
1281gcc/testsuite/
1282 * gcc.target/aarch64/stack-protector-8.c: New test.
1283 * gcc.target/aarch64/stack-protector-9.c: Likewise.
1284---
1285 gcc/config/aarch64/aarch64.c | 46 +++++++++++++--
1286 .../gcc.target/aarch64/stack-protector-8.c | 58 +++++++++++++++++++
1287 .../gcc.target/aarch64/stack-protector-9.c | 33 +++++++++++
1288 3 files changed, 133 insertions(+), 4 deletions(-)
1289 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
1290 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
1291
1292diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
1293index 705f719a2ea..3d094214fac 100644
1294--- a/gcc/config/aarch64/aarch64.c
1295+++ b/gcc/config/aarch64/aarch64.c
1296@@ -4622,6 +4622,20 @@ aarch64_needs_frame_chain (void)
1297 return aarch64_use_frame_pointer;
1298 }
1299
1300+/* Return true if the current function should save registers above
1301+ the locals area, rather than below it. */
1302+
1303+static bool
1304+aarch64_save_regs_above_locals_p ()
1305+{
1306+ /* When using stack smash protection, make sure that the canary slot
1307+ comes between the locals and the saved registers. Otherwise,
1308+ it would be possible for a carefully sized smash attack to change
1309+ the saved registers (particularly LR and FP) without reaching the
1310+ canary. */
1311+ return crtl->stack_protect_guard;
1312+}
1313+
1314 /* Mark the registers that need to be saved by the callee and calculate
1315 the size of the callee-saved registers area and frame record (both FP
1316 and LR may be omitted). */
1317@@ -4686,6 +4700,16 @@ aarch64_layout_frame (void)
1318
1319 cfun->machine->frame.bytes_below_hard_fp = crtl->outgoing_args_size;
1320
1321+ bool regs_at_top_p = aarch64_save_regs_above_locals_p ();
1322+
1323+ if (regs_at_top_p)
1324+ {
1325+ cfun->machine->frame.bytes_below_hard_fp += get_frame_size ();
1326+ cfun->machine->frame.bytes_below_hard_fp
1327+ = aligned_upper_bound (cfun->machine->frame.bytes_below_hard_fp,
1328+ STACK_BOUNDARY / BITS_PER_UNIT);
1329+ }
1330+
1331 #define ALLOCATE_GPR_SLOT(REGNO) \
1332 do \
1333 { \
1334@@ -4758,9 +4782,11 @@ aarch64_layout_frame (void)
1335 HOST_WIDE_INT varargs_and_saved_regs_size
1336 = offset + cfun->machine->frame.saved_varargs_size;
1337
1338+ cfun->machine->frame.bytes_above_hard_fp = varargs_and_saved_regs_size;
1339+ if (!regs_at_top_p)
1340+ cfun->machine->frame.bytes_above_hard_fp += get_frame_size ();
1341 cfun->machine->frame.bytes_above_hard_fp
1342- = aligned_upper_bound (varargs_and_saved_regs_size
1343- + get_frame_size (),
1344+ = aligned_upper_bound (cfun->machine->frame.bytes_above_hard_fp,
1345 STACK_BOUNDARY / BITS_PER_UNIT);
1346
1347 /* Both these values are already aligned. */
1348@@ -4772,6 +4798,9 @@ aarch64_layout_frame (void)
1349
1350 cfun->machine->frame.bytes_above_locals
1351 = cfun->machine->frame.saved_varargs_size;
1352+ if (regs_at_top_p)
1353+ cfun->machine->frame.bytes_above_locals
1354+ += cfun->machine->frame.saved_regs_size;
1355
1356 cfun->machine->frame.initial_adjust = 0;
1357 cfun->machine->frame.final_adjust = 0;
1358@@ -5764,10 +5793,10 @@ aarch64_add_cfa_expression (rtx_insn *insn, unsigned int reg,
1359 | for register varargs |
1360 | |
1361 +-------------------------------+
1362- | local variables | <-- frame_pointer_rtx
1363+ | local variables (1) | <-- frame_pointer_rtx
1364 | |
1365 +-------------------------------+
1366- | padding | \
1367+ | padding (1) | \
1368 +-------------------------------+ |
1369 | callee-saved registers | | frame.saved_regs_size
1370 +-------------------------------+ |
1371@@ -5775,6 +5804,10 @@ aarch64_add_cfa_expression (rtx_insn *insn, unsigned int reg,
1372 +-------------------------------+ |
1373 | FP' | / <- hard_frame_pointer_rtx (aligned)
1374 +-------------------------------+
1375+ | local variables (2) |
1376+ +-------------------------------+
1377+ | padding (2) |
1378+ +-------------------------------+
1379 | dynamic allocation |
1380 +-------------------------------+
1381 | padding |
1382@@ -5784,6 +5817,9 @@ aarch64_add_cfa_expression (rtx_insn *insn, unsigned int reg,
1383 +-------------------------------+
1384 | | <-- stack_pointer_rtx (aligned)
1385
1386+ The regions marked (1) and (2) are mutually exclusive. (2) is used
1387+ when aarch64_save_regs_above_locals_p is true.
1388+
1389 Dynamic stack allocations via alloca() decrease stack_pointer_rtx
1390 but leave frame_pointer_rtx and hard_frame_pointer_rtx
1391 unchanged.
1392@@ -5937,6 +5973,8 @@ aarch64_expand_prologue (void)
1393 that is assumed by the called. */
1394 aarch64_allocate_and_probe_stack_space (tmp1_rtx, tmp0_rtx, final_adjust,
1395 !frame_pointer_needed, true);
1396+ if (emit_frame_chain && maybe_ne (final_adjust, 0))
1397+ emit_insn (gen_stack_tie (stack_pointer_rtx, hard_frame_pointer_rtx));
1398 }
1399
1400 /* Return TRUE if we can use a simple_return insn.
1401diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
1402new file mode 100644
1403index 00000000000..c5e7deef6c1
1404--- /dev/null
1405+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
1406@@ -0,0 +1,58 @@
1407+/* { dg-options " -O -fstack-protector-strong -mstack-protector-guard=sysreg -mstack-protector-guard-reg=tpidr2_el0 -mstack-protector-guard-offset=16" } */
1408+/* { dg-final { check-function-bodies "**" "" } } */
1409+
1410+void g(void *);
1411+
1412+/*
1413+** test1:
1414+** sub sp, sp, #288
1415+** stp x29, x30, \[sp, #?272\]
1416+** add x29, sp, #?272
1417+** mrs (x[0-9]+), tpidr2_el0
1418+** ldr (x[0-9]+), \[\1, #?16\]
1419+** str \2, \[sp, #?264\]
1420+** mov \2, *0
1421+** add x0, sp, #?8
1422+** bl g
1423+** ...
1424+** mrs .*
1425+** ...
1426+** bne .*
1427+** ...
1428+** ldp x29, x30, \[sp, #?272\]
1429+** add sp, sp, #?288
1430+** ret
1431+** bl __stack_chk_fail
1432+*/
1433+int test1() {
1434+ int y[0x40];
1435+ g(y);
1436+ return 1;
1437+}
1438+
1439+/*
1440+** test2:
1441+** stp x29, x30, \[sp, #?-16\]!
1442+** mov x29, sp
1443+** sub sp, sp, #1040
1444+** mrs (x[0-9]+), tpidr2_el0
1445+** ldr (x[0-9]+), \[\1, #?16\]
1446+** str \2, \[sp, #?1032\]
1447+** mov \2, *0
1448+** add x0, sp, #?8
1449+** bl g
1450+** ...
1451+** mrs .*
1452+** ...
1453+** bne .*
1454+** ...
1455+** add sp, sp, #?1040
1456+** ldp x29, x30, \[sp\], #?16
1457+** ret
1458+** bl __stack_chk_fail
1459+*/
1460+int test2() {
1461+ int y[0x100];
1462+ g(y);
1463+ return 1;
1464+}
1465diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
1466new file mode 100644
1467index 00000000000..58f322aa480
1468--- /dev/null
1469+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
1470@@ -0,0 +1,33 @@
1471+/* { dg-options "-O2 -mcpu=neoverse-v1 -fstack-protector-all" } */
1472+/* { dg-final { check-function-bodies "**" "" } } */
1473+
1474+/*
1475+** main:
1476+** ...
1477+** stp x29, x30, \[sp, #?-[0-9]+\]!
1478+** ...
1479+** sub sp, sp, #[0-9]+
1480+** ...
1481+** str x[0-9]+, \[x29, #?-8\]
1482+** ...
1483+*/
1484+int f(const char *);
1485+void g(void *);
1486+int main(int argc, char* argv[])
1487+{
1488+ int a;
1489+ int b;
1490+ char c[2+f(argv[1])];
1491+ int d[0x100];
1492+ char y;
1493+
1494+ y=42; a=4; b=10;
1495+ c[0] = 'h'; c[1] = '\0';
1496+
1497+ c[f(argv[2])] = '\0';
1498+
1499+ __builtin_printf("%d %d\n%s\n", a, b, c);
1500+ g(d);
1501+
1502+ return 0;
1503+}
1504--
15052.34.1
1506