From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 69FD83858401 for ; Sun, 19 Dec 2021 21:58:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 69FD83858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Content-Type:From:Reply-To:Subject:Content-ID: Content-Description:In-Reply-To:References:X-Debbugs-Cc; bh=yomojI5PoGpGvXHQn2E33K920QxMW1EVs75IJLrL3P0=; b=lrQAeSMEBRf6DsNAi5hGduhNma 2S0doWufUh3DzhRWC3lSWEZ8nZBbX9xz91fyaon2gziGwfbVZA4VGxEq17zQGTQJ60J9SjWilf6Ud f7HhJjOo7xkYNNhTkjLsXTBFR/XkXCCjSA9kWcxguI9/lq86DmLES0PJrMBW1p1p2Zn6J6eb+xZBx 41J6oP5xX1BWrWMcznD/0OZs/Ii5UhfkLFuj5ssggZC744PKMbRxRlEB8iS5ST9VLvQ52ervHa7Zz c5vdIG7ARU2GWFo6UmyQYEa0YHaDFxyL3XNtjhQqIPCl0bevM3aCQS54qbm2ATQnBis9/oVzrab0I zSV4C95g==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mz4CG-0003Wn-3l; Sun, 19 Dec 2021 22:58:24 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.95) (envelope-from ) id 1mz4CF-005ATW-JJ; Sun, 19 Dec 2021 22:58:23 +0100 From: Aurelien Jarno To: libc-stable@sourceware.org Subject: [COMMITTED 2.34] linux: Add sparck brk implementation Date: Sun, 19 Dec 2021 22:58:20 +0100 Message-Id: <20211219215820.1231688-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Dec 2021 21:58:27 -0000 From: Adhemerval Zanella It turned that the generic implementation of brk() does not work for sparc, since on failure kernel will just return the previous input value without setting the conditional register. This patches adds back a sparc32 and sparc64 implementation removed by 720480934ab9107. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. (cherry picked from commit 5b86241a032c50462988bdd1439e078384690d34) --- sysdeps/unix/sysv/linux/sparc/brk.c | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/sparc/brk.c diff --git a/sysdeps/unix/sysv/linux/sparc/brk.c b/sysdeps/unix/sysv/linux/sparc/brk.c new file mode 100644 index 0000000000..aafe9673e3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/brk.c @@ -0,0 +1,58 @@ +/* Change data segment. Linux SPARC version. + Copyright (C) 2021 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 + . */ + +#include +#include +#include + +/* This must be initialized data because commons can't have aliases. */ +void *__curbrk = 0; + +#if HAVE_INTERNAL_BRK_ADDR_SYMBOL +/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt + to work around different old braindamage in the old Linux ELF dynamic + linker. */ +weak_alias (__curbrk, ___brk_addr) +#endif + +#ifdef __arch64__ +# define SYSCALL_NUM "0x6d" +#else +# define SYSCALL_NUM "0x10" +#endif + +int +__brk (void *addr) +{ + register long int g1 asm ("g1") = __NR_brk; + register long int o0 asm ("o0") = (long int) addr; + asm volatile ("ta " SYSCALL_NUM + : "=r"(o0) + : "r"(g1), "0"(o0) + : "cc"); + __curbrk = (void *) o0; + + if (__curbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + + return 0; +} +weak_alias (__brk, brk) -- 2.33.0