From 0be42b21591a6087939a33ab408beab2fd918c59 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 24 Jul 2024 15:57:51 -0500 Subject: system/gcc: Fixes for 32-bit Arm platforms * The san library needs some adjustments to handle the fact we need frame pointers (r7 is used for the syscall number, and the FP). * Fix GCC Go __go_mmap external linking since they changed the signature upstream for the C side. This closes #1201. --- system/gcc/336-gccgo-mmap64.patch | 20 ------------------ system/gcc/APKBUILD | 4 +--- system/gcc/sanitation.patch | 43 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 26 deletions(-) delete mode 100644 system/gcc/336-gccgo-mmap64.patch diff --git a/system/gcc/336-gccgo-mmap64.patch b/system/gcc/336-gccgo-mmap64.patch deleted file mode 100644 index 0d4ab19b8..000000000 --- a/system/gcc/336-gccgo-mmap64.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- gcc-8.3.0/libgo/go/runtime/mem_gccgo.go.old 2018-01-09 01:23:08.000000000 +0000 -+++ gcc-8.3.0/libgo/go/runtime/mem_gccgo.go 2019-03-03 05:15:33.010000000 +0000 -@@ -15,7 +15,7 @@ - //go:linkname sysFree - - //extern __go_mmap --func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer -+func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer - - //extern munmap - func munmap(addr unsafe.Pointer, length uintptr) int32 -@@ -37,7 +37,7 @@ - } - } - --func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { -+func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) { - p := sysMmap(addr, n, prot, flags, fd, off) - if uintptr(p) == _MAP_FAILED { - return nil, errno() diff --git a/system/gcc/APKBUILD b/system/gcc/APKBUILD index 4164de239..afcde96ea 100644 --- a/system/gcc/APKBUILD +++ b/system/gcc/APKBUILD @@ -178,7 +178,6 @@ source="https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz 332-gccgo-sysinfo.patch 334-gccgo-signal-shell.patch 335-gccgo-signal-ppc32.patch - 336-gccgo-mmap64.patch 341-gccgo-libucontext-stack.patch 342-gccgo-reflect-underscore.patch libgo-musl-1.2.3.patch @@ -603,12 +602,11 @@ ce69e4cceb212e7b8e9af72a97b336dc3f38d7a30fc0c656a56ab3b431679a07efd746fd1cc39f91 2b833b6bcba8eb8914499f3432679635eb1e186f0ab1b0cd2b0012edfe6c296f89c05097476817c9947a0f17ebe031cc1708335e6baa8d3d211116e10cbc7865 332-gccgo-sysinfo.patch dc03c7b660f0142aa16e78e4e50581c883f6632f4794131f1131e0dc8fd500ba5d6a0046a36dc621c618a558b69e426a9bd1baea63faa5f64d7663915c062bbe 334-gccgo-signal-shell.patch 00f43d3d3f23c106ff020699397e82cf63ef30820e74ff3f7a82bcf55e5245011bb4a8ef84f0704287201ec8138692c548d4b6dae2d3e2aaf56e40d57ca2873d 335-gccgo-signal-ppc32.patch -5ead34140ff01e2918554c9c3f8378fe02cdf41f5b965053c126238dc157a1e2558d58465395b750e85b1d7167c4fc79d8a7f34894146507d7366d79a69d4ee7 336-gccgo-mmap64.patch 3cbe5e879902a73121b22d903be605c7100e607864b0e305d6825a4083502fbe94be9a4166fb833b28e5d18cd7548f317719e28e3579194ea3e1b626450c943b 341-gccgo-libucontext-stack.patch 76d141a9e245595eab66cc4ddbfda57330790e04960de5d1c4e1e97efb52291d18087840f7494c0310afc3f093e1fad8c6070928f489c97201f32782f67559fd 342-gccgo-reflect-underscore.patch fa59b0fb081d97f8f63506b8793699588a95c602b5d468140eb1e80456597e52e1cc45dc0b234ac8e60e2b0cd606d94d111c8b0ae64c0a2be1bc1b8a184ceb93 libgo-musl-1.2.3.patch 1860593584f629d24d5b6db14b0a3412e9f93449b663aaa4981301a0923db0159314905e694f27366fbfef72dce06636ab6df86862b7e9e9564847e03bee82c1 add-classic_table-support.patch a09b3181002798d1b17b8374eba6bec18e67d4d4f30677311c330b599e231e97cf02c1b9b79c0829952f5027016e01146743b665b19558ed2693c60a567823fb gcc-5.4.0-locale.patch -5b830a37130808ea7a27b030445362c3a9963e29166228fcc94ca6e92b6446a995c633f8062a4c3f8749b41e6562bdd3d14ef096d86049c68c037d083d59b5c2 sanitation.patch +7fa3f66a9147e13091da7fdf15197aca85e0500756392e1c75eb2e2f77dce6d148277aea2a8cb463770f7b46424a94cb5f60514529a565b4ebb23236dcc7c366 sanitation.patch ff6159633f04d26eadc79895dc24ccb46671a04fdc728cbbac86964a14ce17e2e51cd7668947dfe06b9168bb9b8575a80955012e5f51295ea02f4f3169e07541 match-split.patch ee626cbe4bdda5b868980c86ca066d33167d06517db676e43d0719c4ad7d11e99b3a0151927f15c93ab89f6c76dd12bd48d402d25771fa3fd175273248824eda insn-split.patch" diff --git a/system/gcc/sanitation.patch b/system/gcc/sanitation.patch index 861f5d08e..984b60498 100644 --- a/system/gcc/sanitation.patch +++ b/system/gcc/sanitation.patch @@ -1,5 +1,5 @@ ---- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp.old 2024-05-21 07:47:42.000000000 +0000 -+++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp 2024-06-20 23:28:49.290053800 +0000 +--- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp.old 2024-05-21 02:47:42.000000000 -0500 ++++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp 2024-07-24 15:56:06.119891718 -0500 @@ -82,6 +82,10 @@ # include #endif @@ -71,7 +71,24 @@ // Doesn't set sa_restorer if the caller did not set it, so use with caution //(see below). int internal_sigaction_norestorer(int signum, const void *act, void *oldact) { -@@ -2173,11 +2170,20 @@ +@@ -1677,6 +1674,8 @@ + return res; + } + #elif defined(__arm__) ++#pragma GCC push_options ++#pragma GCC optimize("omit-frame-pointer") + uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg, + int *parent_tidptr, void *newtls, int *child_tidptr) { + unsigned int res; +@@ -1742,6 +1741,7 @@ + : "memory"); + return res; + } ++#pragma GCC pop_options + #endif + #endif // SANITIZER_LINUX + +@@ -2173,11 +2173,20 @@ *bp = ucontext->uc_mcontext.mc_frame[31]; # else ucontext_t *ucontext = (ucontext_t*)context; @@ -145,3 +162,23 @@ // GLIBC 2.20+ sys/user does not include asm/ptrace.h # include #endif +--- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_syscall_linux_arm.inc.old 2024-05-21 02:47:42.000000000 -0500 ++++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_syscall_linux_arm.inc 2024-07-24 15:56:06.129890658 -0500 +@@ -12,6 +12,9 @@ + + #define SYSCALL(name) __NR_ ## name + ++#pragma GCC push_options ++#pragma GCC optimize("omit-frame-pointer") ++ + static uptr __internal_syscall(u32 nr) { + register u32 r8 asm("r7") = nr; + register u32 r0 asm("r0"); +@@ -115,6 +118,7 @@ + #define __internal_syscall6(n, a1, a2, a3, a4, a5, a6) \ + (__internal_syscall)(n, (u32)(a1), (long)(a2), (long)(a3), (long)(a4), \ + (u32)(a5), (long)(a6)) ++#pragma GCC pop_options + + #define __SYSCALL_NARGS_X(a1, a2, a3, a4, a5, a6, a7, a8, n, ...) n + #define __SYSCALL_NARGS(...) \ -- cgit v1.2.3-70-g09d2