commit: e2031444b2e411a4e37c993429435f174815d6a3 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> AuthorDate: Fri Dec 26 09:33:18 2025 +0000 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> CommitDate: Fri Dec 26 09:33:18 2025 +0000 URL: https://gitweb.gentoo.org/proj/toolchain/glibc-patches.git/commit/?id=e2031444
Revert to working sparc32 startup implementation here too Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> 9999/0001-Disable-ldconfig-during-install.patch | 6 +- ...Adapt-to-Gentoo-specific-etc-mail-aliases.patch | 6 +- ...O0-in-conform-tests-to-survive-CC-changes.patch | 6 +- ...4-linux-Use-getdents64-on-non-LFS-readdir.patch | 6 +- 9999/0005-support-Add-xreallocarray.patch | 12 +-- ...nternal-DIR-filepos-as-off64_t-BZ-23960-B.patch | 10 +-- ...c-Fix-sparc32-Fix-argument-passing-to-__l.patch | 44 +++++++++++ ...rgument-passing-to-__libc_start_main-on-S.patch | 86 ++++++++++++++++++++++ 8 files changed, 153 insertions(+), 23 deletions(-) diff --git a/9999/0001-Disable-ldconfig-during-install.patch b/9999/0001-Disable-ldconfig-during-install.patch index 39a72f4..1cb051b 100644 --- a/9999/0001-Disable-ldconfig-during-install.patch +++ b/9999/0001-Disable-ldconfig-during-install.patch @@ -1,7 +1,7 @@ -From 65d5aeff17f11755e20b29748636a17db103d6e1 Mon Sep 17 00:00:00 2001 +From a3f3728ca9644335998ace8091651f362b63b1c7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger <[email protected]> Date: Tue, 3 Aug 2021 00:34:59 +0200 -Subject: [PATCH 1/6] Disable ldconfig during install +Subject: [PATCH 1/8] Disable ldconfig during install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -31,5 +31,5 @@ index cb927fb9f9..42bd789e4a 100644 $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \ $(slibdir) $(libdir) -- -2.49.0 +2.51.2 diff --git a/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch b/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch index a33a55e..56c1162 100644 --- a/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch +++ b/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch @@ -1,7 +1,7 @@ -From 4c2ba791aa33b1a2ebdd04febfd95e25958a6515 Mon Sep 17 00:00:00 2001 +From bfe7e98cff46af8bb257c3534cfdc368dfb6959b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <[email protected]> Date: Mon, 22 Oct 2018 22:34:13 +0200 -Subject: [PATCH 2/6] Adapt to Gentoo-specific /etc/mail/aliases +Subject: [PATCH 2/8] Adapt to Gentoo-specific /etc/mail/aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -106,5 +106,5 @@ index 92c2a453aa..fec6b4b680 100644 /* valgrind needs a temporary directory in the chroot. */ { -- -2.49.0 +2.51.2 diff --git a/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch b/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch index 63a803d..6e872fc 100644 --- a/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch +++ b/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch @@ -1,7 +1,7 @@ -From 4b76e16d6d8bf67a96047042061d21dbe45b4200 Mon Sep 17 00:00:00 2001 +From 4cf63a10f2ec351c3ae4c3898f43eae60440a43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <[email protected]> Date: Fri, 14 Dec 2018 20:43:04 +0100 -Subject: [PATCH 3/6] Force -O0 in conform tests to survive $CC changes +Subject: [PATCH 3/8] Force -O0 in conform tests to survive $CC changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -61,5 +61,5 @@ index d099cac027..ac9adbf4d5 100644 args.header) with tempfile.TemporaryDirectory() as temp_dir: -- -2.49.0 +2.51.2 diff --git a/9999/0004-linux-Use-getdents64-on-non-LFS-readdir.patch b/9999/0004-linux-Use-getdents64-on-non-LFS-readdir.patch index ba7c2fd..ab732f1 100644 --- a/9999/0004-linux-Use-getdents64-on-non-LFS-readdir.patch +++ b/9999/0004-linux-Use-getdents64-on-non-LFS-readdir.patch @@ -1,7 +1,7 @@ -From a26056272e8ae49a81aa4699af95bd457178ae52 Mon Sep 17 00:00:00 2001 +From db2b6dbc4bdb6cbd2cd966d676ac0b28e33831ef Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella <[email protected]> Date: Tue, 20 Oct 2020 13:37:15 -0300 -Subject: [PATCH 4/6] linux: Use getdents64 on non-LFS readdir +Subject: [PATCH 4/8] linux: Use getdents64 on non-LFS readdir It is similar to what non-LFS getdents do (including overflow check). @@ -132,5 +132,5 @@ index abd1ec5c45..0213de925c 100644 struct dirent * -- -2.49.0 +2.51.2 diff --git a/9999/0005-support-Add-xreallocarray.patch b/9999/0005-support-Add-xreallocarray.patch index b133ddc..ceec740 100644 --- a/9999/0005-support-Add-xreallocarray.patch +++ b/9999/0005-support-Add-xreallocarray.patch @@ -1,7 +1,7 @@ -From b27348f88a5025ed75f16fe2da62fc5c2d1e40d2 Mon Sep 17 00:00:00 2001 +From a3fdfff2a6ff67081395f11e4fcb193c9be7e6cd Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella <[email protected]> Date: Wed, 1 Mar 2023 14:41:23 -0300 -Subject: [PATCH 5/6] support: Add xreallocarray +Subject: [PATCH 5/8] support: Add xreallocarray As a wrapper over reallocarray. --- @@ -12,10 +12,10 @@ As a wrapper over reallocarray. create mode 100644 support/xreallocarray.c diff --git a/support/Makefile b/support/Makefile -index d41278eeab..81f8fbb222 100644 +index a7b1b39782..ab763ab2b0 100644 --- a/support/Makefile +++ b/support/Makefile -@@ -210,6 +210,7 @@ libsupport-routines = \ +@@ -213,6 +213,7 @@ libsupport-routines = \ xread \ xreadlink \ xrealloc \ @@ -24,7 +24,7 @@ index d41278eeab..81f8fbb222 100644 xsendto \ xsetlocale \ diff --git a/support/support.h b/support/support.h -index 4998a34894..c1b7070b1c 100644 +index 4e752de5a4..e44a360e42 100644 --- a/support/support.h +++ b/support/support.h @@ -107,6 +107,8 @@ extern void *xcalloc (size_t n, size_t s) @@ -72,5 +72,5 @@ index 0000000000..74fdaa421b + return r; +} -- -2.49.0 +2.51.2 diff --git a/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch b/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch index bbda169..6206c0f 100644 --- a/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch +++ b/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch @@ -1,7 +1,7 @@ -From 220967a1f6f6b50698b8c0f2bd32439171f44421 Mon Sep 17 00:00:00 2001 +From 768f4899440d7c8370899d010217003e624e8db2 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella <[email protected]> Date: Mon, 13 Apr 2020 18:09:20 -0300 -Subject: [PATCH 6/6] linux: Set internal DIR filepos as off64_t (BZ #23960, BZ +Subject: [PATCH 6/8] linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -64,10 +64,10 @@ index d7567f5e86..17827176ba 100644 # include <sys/stat.h> # include <stdbool.h> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile -index 0aec783f1e..b0052a5b04 100644 +index 955d316362..4f641767f8 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile -@@ -603,6 +603,8 @@ sysdep_routines += \ +@@ -606,6 +606,8 @@ sysdep_routines += \ tests += \ tst-getdents64 \ @@ -575,5 +575,5 @@ index 0000000000..216ecf123f + +#include <support/test-driver.c> -- -2.49.0 +2.51.2 diff --git a/9999/0007-Revert-sparc-Fix-sparc32-Fix-argument-passing-to-__l.patch b/9999/0007-Revert-sparc-Fix-sparc32-Fix-argument-passing-to-__l.patch new file mode 100644 index 0000000..05267bc --- /dev/null +++ b/9999/0007-Revert-sparc-Fix-sparc32-Fix-argument-passing-to-__l.patch @@ -0,0 +1,44 @@ +From 5aed18efe31f30fc0dda4c000c0a199289933846 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <[email protected]> +Date: Mon, 1 Dec 2025 23:53:01 -0300 +Subject: [PATCH 7/8] Revert "sparc: Fix sparc32 Fix argument passing to + __libc_start_main (BZ 32981)" + +This reverts commit 8b37c99ef19c79b2bfe84be3b5a4348ef09b0d76. + +(cherry picked from commit 1edc76ee1fb1e9d9a300bd0439580de91bea92e8) +--- + sysdeps/sparc/sparc32/start.S | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S +index 8393760da6..cef7c96cac 100644 +--- a/sysdeps/sparc/sparc32/start.S ++++ b/sysdeps/sparc/sparc32/start.S +@@ -35,7 +35,6 @@ + + #include <sysdep.h> + +-#define FRAME_SIZE 104 + + .section ".text" + .align 4 +@@ -49,12 +48,12 @@ _start: + /* Terminate the stack frame, and reserve space for functions to + drop their arguments. */ + mov %g0, %fp +- sub %sp, FRAME_SIZE, %sp ++ sub %sp, 6*4, %sp + + /* Extract the arguments and environment as encoded on the stack. The + argument info starts after one register window (16 words) past the SP. */ +- ld [%sp+168], %o1 +- add %sp, 172, %o2 ++ ld [%sp+22*4], %o1 ++ add %sp, 23*4, %o2 + + /* Load the addresses of the user entry points. */ + #ifndef PIC +-- +2.51.2 + diff --git a/9999/0008-sparc-Fix-argument-passing-to-__libc_start_main-on-S.patch b/9999/0008-sparc-Fix-argument-passing-to-__libc_start_main-on-S.patch new file mode 100644 index 0000000..b93b6a7 --- /dev/null +++ b/9999/0008-sparc-Fix-argument-passing-to-__libc_start_main-on-S.patch @@ -0,0 +1,86 @@ +From dc3b6d13e68aa2c76d85b302d684e5361e0d59ae Mon Sep 17 00:00:00 2001 +From: Ludwig Rydberg <[email protected]> +Date: Fri, 13 Jun 2025 12:22:41 +0200 +Subject: [PATCH 8/8] sparc: Fix argument passing to __libc_start_main on + SPARC32 + +Use a custom __libc_start_main function so the highest stack address can +be provided to __libc_start_main_impl without altering the content of +the stack (as there is no room for adding arguments to the stack). + +The __libc_stack_end was written to [%sp+23*4] but that address is +already in use (holds the pointer to argv) which led to corruption. + +Fixes: d952c6efaa87 ("sparc: Fix argument passing to __libc_start_main (BZ 32981)") +Signed-off-by: Ludwig Rydberg <[email protected]> +(cherry picked from commit c8305ccf787df8b16a5db18254a3737069a390b7) +--- + sysdeps/sparc/sparc32/start.S | 6 ++-- + .../sysv/linux/sparc/sparc32/libc-start.c | 30 +++++++++++++++++++ + 2 files changed, 32 insertions(+), 4 deletions(-) + create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/libc-start.c + +diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S +index cef7c96cac..9d97a2943e 100644 +--- a/sysdeps/sparc/sparc32/start.S ++++ b/sysdeps/sparc/sparc32/start.S +@@ -64,18 +64,16 @@ _start: + xor %o0, %gdop_lox10(main), %o0 + ld [%l7 + %o0], %o0, %gdop(main) + #endif +- mov 0, %o3 /* Used to be init. */ +- mov 0, %o4 /* Used to be fini. */ + + /* When starting a binary via the dynamic linker, %g1 contains the + address of the shared library termination function, which will be + registered with atexit(). If we are statically linked, this will + be NULL. */ +- mov %g1, %o5 ++ mov %g1, %o3 + + /* Provide the highest stack address to update the __libc_stack_end (used + to enable executable stacks if required). */ +- st %sp, [%sp+23*4] ++ mov %sp, %o4 + + /* Let libc do the rest of the initialization, and call main. */ + call __libc_start_main +diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc-start.c b/sysdeps/unix/sysv/linux/sparc/sparc32/libc-start.c +new file mode 100644 +index 0000000000..c24c1539a4 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc-start.c +@@ -0,0 +1,30 @@ ++/* Copyright (C) 1998-2025 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <https://www.gnu.org/licenses/>. */ ++ ++#define LIBC_START_MAIN generic_start_main ++#include <csu/libc-start.c> ++ ++STATIC int ++__libc_start_main_impl (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), ++ int argc, char **argv, void (*rtld_fini) (void), ++ void *stack_end) ++{ ++ return generic_start_main (main, argc, argv, ++ NULL, NULL, rtld_fini, ++ stack_end); ++} ++DEFINE_LIBC_START_MAIN_VERSION +-- +2.51.2 +
