Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7409293rwl; Mon, 9 Jan 2023 23:55:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+VFv+bQM58Gb8+rMt5TgSv+TVFTxt45/fgf5sA6QaoDfxAG5p7J9gTtNWViVkTcHYhEuD X-Received: by 2002:a17:902:7c90:b0:18f:6b2b:e88d with SMTP id y16-20020a1709027c9000b0018f6b2be88dmr67843456pll.36.1673337330875; Mon, 09 Jan 2023 23:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673337330; cv=none; d=google.com; s=arc-20160816; b=DQijbnhSsW9/JKR1/K7n3bWGkiDCq9DwH0MwGI7eg+WuNZb/kF/PDaR7MXhxejiw/9 uz1d7g4wZ2IH54474bYSxd7fbOByF7tp3r6u8q+kR6Y09o0aZL/XYjZOX8oRBTUnYGCa x1lSm+8W6C7GxzRn3WQSb8WXfoZMMI05biCwYVFwz6X+hzhl9L8oR/L6e2jrRCfFg8vM nDu4opyxn03reC6mFPMJUWAVn6JJPczMKKxAHYbdlt9FPHRKb65RXNJsg2jykPwpMTFT S9w75R8ETM+gQf8uQ6/UzHBRGKGAy/pp7iyZOP1Xbw6lhMZfstrWVrdMm12GSI3xmX76 YztA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=yicj30unrWhOnguMrg/2rAqnwszumPucZifzYkDv0uU=; b=xCljnHeoJ2osHByICWeaJM7450UBWZJvHzGiWbI6ow/HX7tAzrUh8PnDHQvOCIqDkr WN+hEIJkl1nUk3N/StjAVnEgGUJIA7QEmxSWjedwgUCFpo/hlc18Bk+jHr/kOiC/DdW3 Coca5q/1mgAHP+SFWtJcGVomdyY6hjd0rmdzMkSRi7OrzirhYpiRJ8MPnpQuXwzaANTl A8Qh2aR28aqQpJIspu7OZAI8FzcUhtzhavvWVKCyabD9iNjoQZmni9kt3nwg6+O8Gmzq HnetCEkpkNH7Kk9DzutFpXlQ8bgXCzriCAJJhlAg8XG/4KxX017V3zrUKqnjX66FXyaI hq5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a170903018600b001787f1922a7si12015204plg.19.2023.01.09.23.55.24; Mon, 09 Jan 2023 23:55:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237779AbjAJH0S (ORCPT + 53 others); Tue, 10 Jan 2023 02:26:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237780AbjAJHZe (ORCPT ); Tue, 10 Jan 2023 02:25:34 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E5CF54A95F for ; Mon, 9 Jan 2023 23:25:24 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30A7OdlZ003945; Tue, 10 Jan 2023 08:24:39 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH v2 18/22] tools/nolibc: add auxiliary vector retrieval for mips Date: Tue, 10 Jan 2023 08:24:30 +0100 Message-Id: <20230110072434.3863-19-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230110072434.3863-1-w@1wt.eu> References: <20230110072434.3863-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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-mips.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 { }) char **environ __attribute__((weak)); +const unsigned long *_auxv __attribute__((weak)); /* 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=*(t0); + "bne $a3, $0, 0b\n" // } while (a3); + "addiu $t0, $t0, 4\n" // delayed slot: t0+=4; + "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! -- 2.17.5