From nobody Fri Dec 19 20:09:00 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10214C5479D for ; Mon, 9 Jan 2023 08:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233977AbjAIIvb (ORCPT ); Mon, 9 Jan 2023 03:51:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237026AbjAIIr4 (ORCPT ); Mon, 9 Jan 2023 03:47:56 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DEB2A164B9 for ; Mon, 9 Jan 2023 00:43:33 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3098gFGJ027437; Mon, 9 Jan 2023 09:42:15 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 18/22] tools/nolibc: add auxiliary vector retrieval for mips Date: Mon, 9 Jan 2023 09:42:04 +0100 Message-Id: <20230109084208.27355-19-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109084208.27355-1-w@1wt.eu> References: <20230109084208.27355-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the _start block we now iterate over envp to find the auxiliary vector after the NULL. The pointer is saved into an _auxv variable that is marked as weak so that it's accessible from multiple units. Signed-off-by: Willy Tarreau --- tools/include/nolibc/arch-mips.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-m= ips.h index 7d22f7bc38b3..bf83432d23ed 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -177,6 +177,7 @@ struct sys_stat_struct { }) =20 char **environ __attribute__((weak)); +const unsigned long *_auxv __attribute__((weak)); =20 /* startup code, note that it's called __start on MIPS */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __start= (void) @@ -196,6 +197,16 @@ void __attribute__((weak,noreturn,optimize("omit-frame= -pointer"))) __start(void) "lui $a3, %hi(environ)\n" // load environ into a3 (hi) "addiu $a3, %lo(environ)\n" // load environ into a3 (lo) "sw $a2,($a3)\n" // store envp(a2) into environ + + "move $t0, $a2\n" // iterate t0 over envp, look for NULL + "0:" // do { + "lw $a3, ($t0)\n" // a3=3D*(t0); + "bne $a3, $0, 0b\n" // } while (a3); + "addiu $t0, $t0, 4\n" // delayed slot: t0+=3D4; + "lui $a3, %hi(_auxv)\n" // load _auxv into a3 (hi) + "addiu $a3, %lo(_auxv)\n" // load _auxv into a3 (lo) + "sw $t0, ($a3)\n" // store t0 into _auxv + "li $t0, -8\n" "and $sp, $sp, $t0\n" // sp must be 8-byte aligned "addiu $sp,$sp,-16\n" // the callee expects to save a0..a3 there! --=20 2.17.5