From abc1d8e1c8a44f674650bafec50bf25d75b2a22c Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sun, 28 Sep 2025 19:45:27 +0200 Subject: [PATCH] gcc: sync libasan mmap implementation with libroot --- sys-devel/gcc/gcc-13.3.0_2023_08_10.recipe | 2 +- .../patches/gcc-13.3.0_2023_08_10.patchset | 71 +++++++++++++++---- 2 files changed, 58 insertions(+), 15 deletions(-) diff --git a/sys-devel/gcc/gcc-13.3.0_2023_08_10.recipe b/sys-devel/gcc/gcc-13.3.0_2023_08_10.recipe index bdaf3fcb9..be2847df7 100644 --- a/sys-devel/gcc/gcc-13.3.0_2023_08_10.recipe +++ b/sys-devel/gcc/gcc-13.3.0_2023_08_10.recipe @@ -5,7 +5,7 @@ HOMEPAGE="https://gcc.gnu.org/" COPYRIGHT="1988-2023 Free Software Foundation, Inc." LICENSE="GNU GPL v3 GNU LGPL v3" -REVISION="4" +REVISION="5" gccVersion="${portVersion%%_*}" SOURCE_URI="https://ftpmirror.gnu.org/gcc/gcc-$gccVersion/gcc-$gccVersion.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-$gccVersion/gcc-$gccVersion.tar.xz" diff --git a/sys-devel/gcc/patches/gcc-13.3.0_2023_08_10.patchset b/sys-devel/gcc/patches/gcc-13.3.0_2023_08_10.patchset index ed8464883..d80a96028 100644 --- a/sys-devel/gcc/patches/gcc-13.3.0_2023_08_10.patchset +++ b/sys-devel/gcc/patches/gcc-13.3.0_2023_08_10.patchset @@ -1,4 +1,4 @@ -From 18b974306411da4abcd08a94fc778cae18bfa4c1 Mon Sep 17 00:00:00 2001 +From d6ace6690401ff696c84ae3f0329138486bb00ee Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Tue, 15 Aug 2023 06:19:59 +0100 Subject: Modifications for GCC 13.2.0 for Haiku (from buildtools repository) @@ -8222,10 +8222,10 @@ index b92e284..6a180a5 100644 hpux*) -- -2.45.2 +2.50.1 -From 6bbc307436eef13811173fc37072786972741f91 Mon Sep 17 00:00:00 2001 +From ac5646c3a470ce934ac4de4ca18e4ac86140455e Mon Sep 17 00:00:00 2001 From: Yn0ga Date: Thu, 5 Oct 2023 19:58:27 +0000 Subject: Update PPC toolchain, should fix #18474 @@ -8318,10 +8318,10 @@ index 2c78454..8dd05b6 100644 powerpc-*-netbsd*) tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff" -- -2.45.2 +2.50.1 -From d42622c32987c0c42c0e7418332cd1a678733405 Mon Sep 17 00:00:00 2001 +From 0edfe31c59765ba6e84434baa93fdf0a2a9af611 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 13 Dec 2023 13:54:29 +0100 Subject: gcc: remove obsolete macro definitions @@ -8401,10 +8401,10 @@ index 1b56931..3781045 100644 /* Output assembler code to FILE to call the profiler. */ #define NO_PROFILE_COUNTERS 1 -- -2.45.2 +2.50.1 -From 8f901f7ea21b2056fa8955b7cfd0006c8118a2fb Mon Sep 17 00:00:00 2001 +From d945a40211b3e6aeba885a8901e2e7e9e2a1d862 Mon Sep 17 00:00:00 2001 From: David Karoly Date: Thu, 28 Mar 2024 17:19:03 +0100 Subject: gcc/config/rs6000: fix typo @@ -8425,10 +8425,10 @@ index 59be0b8..f1f1317 100644 + } \ while (0) -- -2.45.2 +2.50.1 -From e576c232e8c97f538ace4710b55ab597325ed293 Mon Sep 17 00:00:00 2001 +From 9ec74b305e991ca8f1f2a8d62e7607c973fda35f Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Mon, 10 Jun 2024 16:41:43 +0200 Subject: gcc/config/i386: apply change from 13.x to haiku @@ -8469,10 +8469,10 @@ index 3781045..d9d99c3 100644 #define TARGET_OS_CPP_BUILTINS() \ do \ -- -2.45.2 +2.50.1 -From 42cdebf93c1df48e299a3ff2c7031dbeeb9c3b0e Mon Sep 17 00:00:00 2001 +From 04357320ebcb57f4b130b0a7a701424b4d97c080 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Mon, 10 Jun 2024 16:45:13 +0200 Subject: libstdc++: fix posix_memalign signature @@ -8492,10 +8492,10 @@ index 29767c1..3c06b5c 100644 void *aligned_alloc(size_t alignment, size_t size); # elif _GLIBCXX_HAVE__ALIGNED_MALLOC -- -2.45.2 +2.50.1 -From 8fd5c96f993b86ffc10ebf47f2e1a339c6690cbb Mon Sep 17 00:00:00 2001 +From e06b83662d94b23b533222d9497a98aec355250f Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Mon, 27 Jan 2025 22:06:02 +0100 Subject: Fix build of libasan and libubsan for Haiku @@ -9854,6 +9854,49 @@ index 6a8e82e..3f6901a 100644 - // SANITIZER_SOLARIS + // SANITIZER_SOLARIS || SANITIZER_HAIKU -- -2.45.2 +2.50.1 + + +From 94fdaf3ff7797a6452725ffb99bdb3434e2c6d1b Mon Sep 17 00:00:00 2001 +From: PulkoMandy +Date: Sun, 28 Sep 2025 16:42:44 +0200 +Subject: libasan: sync mmap implementation with libroot + +It was missing several checks. + +diff --git a/libsanitizer/sanitizer_common/sanitizer_netbsd.cpp b/libsanitizer/sanitizer_common/sanitizer_netbsd.cpp +index 940a2fc..6b53983 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_netbsd.cpp ++++ b/libsanitizer/sanitizer_common/sanitizer_netbsd.cpp +@@ -106,10 +106,27 @@ static void *GetRealLibcAddress(const char *symbol) { + uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd, + u64 offset) { + #if SANITIZER_HAIKU ++ // offset and length must be page-aligned ++ if (length == 0 || offset % B_PAGE_SIZE != 0) { ++ errno = B_BAD_VALUE; ++ return (uptr)MAP_FAILED; ++ } ++ ++ // check anonymous mapping + if ((flags & MAP_ANONYMOUS) != 0) { + fd = -1; ++ } else if (fd < 0) { ++ errno = EBADF; ++ return (uptr)MAP_FAILED; ++ } ++ ++ // either MAP_SHARED or MAP_PRIVATE must be specified ++ if (((flags & MAP_SHARED) != 0) == ((flags & MAP_PRIVATE) != 0)) { ++ errno = B_BAD_VALUE; ++ return (uptr)MAP_FAILED; + } + ++ // translate mapping, address specification, and protection + int mapping = (flags & MAP_SHARED) != 0 + ? REGION_NO_PRIVATE_MAP : REGION_PRIVATE_MAP; + +-- +2.50.1