diff options
-rw-r--r-- | system/gcc/APKBUILD | 7 | ||||
-rw-r--r-- | system/gcc/backport-r267157-posix-conformant-snprintf.patch | 80 | ||||
-rw-r--r-- | system/gcc/backport-r268048-memcpy-bounds.patch | 21 |
3 files changed, 107 insertions, 1 deletions
diff --git a/system/gcc/APKBUILD b/system/gcc/APKBUILD index a8ac557b5..96bd3f8df 100644 --- a/system/gcc/APKBUILD +++ b/system/gcc/APKBUILD @@ -177,6 +177,9 @@ source="https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz add-classic_table-support.patch disable-multiarch-ppc32.patch gcc-5.4.0-locale.patch + + backport-r267157-posix-conformant-snprintf.patch + backport-r268048-memcpy-bounds.patch " # we build out-of-tree @@ -562,4 +565,6 @@ de0cc0f9356c9ee5ea7b0f954441b59115f4a8f8f63573d0c17b6537e6f37641cf137531b496fc19 c2916948b028e1e990e1953875b884561c0f8dd105c1ec03073795df9a47ec2c627cbc95ca0ec98ab9177bf2b7c8458bf3fd09f780fa6c301995846f6317e366 337-gccgo-signal-sig34.patch 1860593584f629d24d5b6db14b0a3412e9f93449b663aaa4981301a0923db0159314905e694f27366fbfef72dce06636ab6df86862b7e9e9564847e03bee82c1 add-classic_table-support.patch db8c4ab3eae7c01943a61e9e3e20af45d4f6d196184eee5b94068b212900ccdeecaf4fb4145983226954f64e7c989fcd13e0b506176d2b3e781c2e9dc8b5a5a8 disable-multiarch-ppc32.patch -67a75a94fdba69de96b98dbc2978a50cb197857c464b81f7c956176da7066b3be937e40cb15e0870fc1e7382d662c5101bcd18cf457fc4112de41802042b51c4 gcc-5.4.0-locale.patch" +67a75a94fdba69de96b98dbc2978a50cb197857c464b81f7c956176da7066b3be937e40cb15e0870fc1e7382d662c5101bcd18cf457fc4112de41802042b51c4 gcc-5.4.0-locale.patch +65a4d8bf9cefcbc79e86015ef4376b2794492d6cae77065359b35bb4ed630dde6256982cd5e43ed837cbbdab366ea376da9f1c83f80ddf6dc53ab017b378c3cd backport-r267157-posix-conformant-snprintf.patch +23c20f258d1a21d0d706945376df8b93c0277a8dcd5183cc0b15c9f22250ef179833c725f877279f74e89364d772148526af5544ab7758172bfb758618554ad3 backport-r268048-memcpy-bounds.patch" diff --git a/system/gcc/backport-r267157-posix-conformant-snprintf.patch b/system/gcc/backport-r267157-posix-conformant-snprintf.patch new file mode 100644 index 000000000..adedf0ce9 --- /dev/null +++ b/system/gcc/backport-r267157-posix-conformant-snprintf.patch @@ -0,0 +1,80 @@ +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87096 + +GCC's "optimised" snprintf is not POSIX conformant + +--- trunk/gcc/gimple-ssa-sprintf.c 2018/12/07 17:02:11 266897 ++++ trunk/gcc/gimple-ssa-sprintf.c 2018/12/14 22:38:08 267157 +@@ -3899,6 +3899,7 @@ + /* True when the destination size is constant as opposed to the lower + or upper bound of a range. */ + bool dstsize_cst_p = true; ++ bool posunder4k = true; + + if (idx_dstsize == HOST_WIDE_INT_M1U) + { +@@ -3931,11 +3932,20 @@ + "specified bound %wu exceeds maximum object size " + "%wu", + dstsize, target_size_max () / 2); ++ /* POSIX requires snprintf to fail if DSTSIZE is greater ++ than INT_MAX. Even though not all POSIX implementations ++ conform to the requirement, avoid folding in this case. */ ++ posunder4k = false; + } + else if (dstsize > target_int_max ()) +- warning_at (gimple_location (info.callstmt), info.warnopt (), +- "specified bound %wu exceeds %<INT_MAX%>", +- dstsize); ++ { ++ warning_at (gimple_location (info.callstmt), info.warnopt (), ++ "specified bound %wu exceeds %<INT_MAX%>", ++ dstsize); ++ /* POSIX requires snprintf to fail if DSTSIZE is greater ++ than INT_MAX. Avoid folding in that case. */ ++ posunder4k = false; ++ } + } + else if (TREE_CODE (size) == SSA_NAME) + { +@@ -3944,9 +3954,29 @@ + if (vr->type == VR_RANGE + && TREE_CODE (vr->min) == INTEGER_CST + && TREE_CODE (vr->max) == INTEGER_CST) +- dstsize = (warn_level < 2 +- ? TREE_INT_CST_LOW (vr->max) +- : TREE_INT_CST_LOW (vr->min)); ++ { ++ unsigned HOST_WIDE_INT minsize = TREE_INT_CST_LOW (vr->min); ++ unsigned HOST_WIDE_INT maxsize = TREE_INT_CST_LOW (vr->max); ++ dstsize = warn_level < 2 ? maxsize : minsize; ++ ++ if (minsize > target_int_max ()) ++ warning_at (gimple_location (info.callstmt), info.warnopt (), ++ "specified bound range [%wu, %wu] exceeds " ++ "%<INT_MAX%>", ++ minsize, maxsize); ++ ++ /* POSIX requires snprintf to fail if DSTSIZE is greater ++ than INT_MAX. Avoid folding if that's possible. */ ++ if (maxsize > target_int_max ()) ++ posunder4k = false; ++ } ++ else if (vr->type == VR_VARYING) ++ { ++ /* POSIX requires snprintf to fail if DSTSIZE is greater ++ than INT_MAX. Since SIZE's range is unknown, avoid ++ folding. */ ++ posunder4k = false; ++ } + + /* The destination size is not constant. If the function is + bounded (e.g., snprintf) a lower bound of zero doesn't +@@ -4033,7 +4073,7 @@ + the call. Avoid this optimization when -frounding-math is in effect + and the format string contains a floating point directive. */ + bool call_removed = false; +- if (success && optimize > 0) ++ if (!posunder4k && success && optimize > 0) + { + /* Save a copy of the iterator pointing at the call. The iterator + may change to point past the call in try_substitute_return_value diff --git a/system/gcc/backport-r268048-memcpy-bounds.patch b/system/gcc/backport-r268048-memcpy-bounds.patch new file mode 100644 index 000000000..eebecd832 --- /dev/null +++ b/system/gcc/backport-r268048-memcpy-bounds.patch @@ -0,0 +1,21 @@ +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88273 + +GCC 8.2+ fails to build 32-bit PowerPC kernel due to this. + +--- trunk/gcc/gimple-ssa-warn-restrict.c 2019/01/17 16:33:55 268037 ++++ trunk/gcc/gimple-ssa-warn-restrict.c 2019/01/17 22:52:47 268048 +@@ -319,13 +319,9 @@ + offrange[0] += offset_int::from (min, SIGNED); + offrange[1] += offset_int::from (max, SIGNED); + } +- else if (rng == VR_ANTI_RANGE) +- { +- offrange[0] += offset_int::from (max + 1, SIGNED); +- offrange[1] += offset_int::from (min - 1, SIGNED); +- } + else + { ++ /* Handle an anti-range the same as no range at all. */ + gimple *stmt = SSA_NAME_DEF_STMT (offset); + tree type; + if (is_gimple_assign (stmt) |