summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-01-01 18:00:08 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-01-02 23:15:26 -0600
commite16b285c8e8c54bed0ec0eba419c2959e7e22b07 (patch)
tree632ddb138790b5d19010444d9eecb55462fb2c42
parent775611f4880c202bc3fd1a693d9c1ad006456372 (diff)
downloadpackages-e16b285c8e8c54bed0ec0eba419c2959e7e22b07.tar.gz
packages-e16b285c8e8c54bed0ec0eba419c2959e7e22b07.tar.bz2
packages-e16b285c8e8c54bed0ec0eba419c2959e7e22b07.tar.xz
packages-e16b285c8e8c54bed0ec0eba419c2959e7e22b07.zip
system/gcc: Finish fixing unwinding in GCC Go rt
We add more functions to the unwind string comparisons, and pull in the symbols for libucontext. Fixes: 0dd86764 ("system/gcc: Ensure gccgo doesn't run off the stack") Refs: #832
-rw-r--r--system/gcc/342-gccgo-more-unwinding.patch37
-rw-r--r--system/gcc/APKBUILD9
2 files changed, 44 insertions, 2 deletions
diff --git a/system/gcc/342-gccgo-more-unwinding.patch b/system/gcc/342-gccgo-more-unwinding.patch
new file mode 100644
index 000000000..7f059b4dc
--- /dev/null
+++ b/system/gcc/342-gccgo-more-unwinding.patch
@@ -0,0 +1,37 @@
+The fix for #832 was incomplete. Since we strip libgo.so, filename is
+always NULL. This caused the unwinder to continue through
+runtime_mstart which caused the same issue.
+--- gcc-8.5.0/libgo/runtime/go-callers.c.old 2023-01-01 17:56:27.302982459 -0600
++++ gcc-8.5.0/libgo/runtime/go-callers.c 2023-01-01 17:58:00.612903483 -0600
+@@ -118,27 +118,11 @@
+ if (function != NULL)
+ {
+ if (__builtin_strcmp (function, "makecontext") == 0
+- || __builtin_strcmp (function, "libucontext_makecontext") == 0)
++ || __builtin_strcmp (function, "libucontext_makecontext") == 0
++ || __builtin_strcmp (function, "runtime_mstart") == 0
++ || __builtin_strcmp (function, "runtime.kickoff") == 0
++ || __builtin_strcmp (function, "runtime.main") == 0)
+ return 1;
+- if (filename != NULL)
+- {
+- const char *p;
+-
+- p = strrchr (filename, '/');
+- if (p == NULL)
+- p = filename;
+- if (__builtin_strcmp (p, "/proc.c") == 0)
+- {
+- if (__builtin_strcmp (function, "runtime_mstart") == 0)
+- return 1;
+- }
+- else if (__builtin_strcmp (p, "/proc.go") == 0)
+- {
+- if (__builtin_strcmp (function, "runtime.kickoff") == 0
+- || __builtin_strcmp (function, "runtime.main") == 0)
+- return 1;
+- }
+- }
+ }
+
+ return arg->index >= arg->max;
diff --git a/system/gcc/APKBUILD b/system/gcc/APKBUILD
index 6ce9887b6..36eae350c 100644
--- a/system/gcc/APKBUILD
+++ b/system/gcc/APKBUILD
@@ -6,7 +6,7 @@ pkgver=8.5.0
[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target=""
pkgname="$pkgname$_target"
-pkgrel=2
+pkgrel=3
pkgdesc="The GNU Compiler Collection"
url="https://gcc.gnu.org"
arch="all"
@@ -182,6 +182,7 @@ source="https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz
339-gccgo-errstr.patch
340-gccgo-time64-stat.patch
341-gccgo-libucontext-stack.patch
+ 342-gccgo-more-unwinding.patch
add-classic_table-support.patch
gcc-5.4.0-locale.patch
@@ -462,7 +463,10 @@ libgo() {
go() {
pkgdesc="Go support for GCC"
- depends="gcc=$_gccrel libgo=$_gccrel"
+ # Symbols for libucontext are required for proper operation.
+ # The unwinder may fail to work, causing stack smashing or hangs.
+ # See #832
+ depends="gcc=$_gccrel libgo=$_gccrel libucontext-dbg"
mkdir -p "$subpkgdir"/$_gcclibexec \
"$subpkgdir"/usr/lib \
@@ -582,6 +586,7 @@ c2916948b028e1e990e1953875b884561c0f8dd105c1ec03073795df9a47ec2c627cbc95ca0ec98a
b32d496a3a04c2357200b75dbf7f667fb57bf5af4f0c68926bc58f6600e4f23caa48aad2eaf073f1408168cacf27e8f11a6062c65bf5bb67458eedef698871d4 339-gccgo-errstr.patch
4db4a00dff1d3cb3ecbc713659316782ac839478ff1fd7166cfa64a2c7cee0ba2a0d3fa23cb858af7d8f59a6ac2bdf40e63a45c307b89eefe2a4e888707f615b 340-gccgo-time64-stat.patch
71ee2ce239c62bedc90d0688a40e3e381e641ba9e322c6319c2f6a4362c17d60a232dcb32fd08f5ff9ed5c058c0a010362197839cb391d85bc4a6446943ad4b2 341-gccgo-libucontext-stack.patch
+7bb23955ddd67319c2aaae10bb1545ea299b96e54f429423fa6db4ff9af119312f3c8a876b3912c8811403543fabb50e7c7b94b0d2145a4f4e6ef1959d456128 342-gccgo-more-unwinding.patch
1860593584f629d24d5b6db14b0a3412e9f93449b663aaa4981301a0923db0159314905e694f27366fbfef72dce06636ab6df86862b7e9e9564847e03bee82c1 add-classic_table-support.patch
67a75a94fdba69de96b98dbc2978a50cb197857c464b81f7c956176da7066b3be937e40cb15e0870fc1e7382d662c5101bcd18cf457fc4112de41802042b51c4 gcc-5.4.0-locale.patch
65a4d8bf9cefcbc79e86015ef4376b2794492d6cae77065359b35bb4ed630dde6256982cd5e43ed837cbbdab366ea376da9f1c83f80ddf6dc53ab017b378c3cd backport-r267157-posix-conformant-snprintf.patch