Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7408393rwl; Mon, 9 Jan 2023 23:54:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYUSJUzr0v8CutfaFIZ8ixWBfp9nAkKQunMmO8Qr8YeiDs6CdYYsA/7MjJj0X/gl0YmubG X-Received: by 2002:a05:6300:811c:b0:ad:4be8:5984 with SMTP id bs28-20020a056300811c00b000ad4be85984mr77839809pzc.27.1673337265439; Mon, 09 Jan 2023 23:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673337265; cv=none; d=google.com; s=arc-20160816; b=Y7VekNf2ovrqFettqBax6E0Mp36SMhvdJAgV0w9GadnM0NpkFHUbjD6vqMCSnJ5fIz GmIzm0IL8jlhRrO82yrl1qjNsaQABWoTA5XTnAMSVGdPC5SYLo+R+P9C8yZfd3a00+gs J4EQvxk2jsHF11OWFNrEjuxf9okft2HASJpEJlGcJ4RFLhStVHY1erp2y1hRSlC5ppLy JPSy9lHpPwL92oqqc/NEyaR3E6x9rSioLeiGN/yfvI2AR/jFii4k+4suYTjNb0J7ViOY Mk7l5fMmQAhwMusaTEqBnuPCy59X/LqGbAl96DN26+1XCUAKdLlMuqLj+UuUZM5EDbbT OFbg== 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=lxvq58IyFOGE99tR1asuwOZ7uDE28fVplUSym56673s=; b=biC2/+6OyKNa6zQ89G7cNOyqgPAHIil0wmWDv0yZhbK5gmzLsmLpGlAz6/L2pP51U5 sKxQG7yl6RqYMY+u6zWJjyP/cvwk/5u5+inG60CtIWrGl0VhRl2nNpLOLiSHseLGzRs7 K2+AbimaFDgBdiQAixXonz8FV5Zp0N7JbxCLrvYF1qdRXGt71q+CKwPy8rg6mUZulpEa WFDEqN8jMBlyy6WwXdIStB5qONtk8Ve1AE2m1Jwik+RcnAs09HEHcM3eePqxHh/MSr4+ W/l0t68S5MEsMyqP5Ed9VAmNYLpWA2lD0TeuyYTLaMeeKNyzrjaAALTjMPqGNWYbC/nt W9lw== 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 n64-20020a632743000000b00478e26efc95si10857256pgn.34.2023.01.09.23.54.18; Mon, 09 Jan 2023 23:54:25 -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 S229655AbjAJHZl (ORCPT + 53 others); Tue, 10 Jan 2023 02:25:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235434AbjAJHZD (ORCPT ); Tue, 10 Jan 2023 02:25:03 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D23534915B for ; Mon, 9 Jan 2023 23:25:00 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30A7Odpx003942; 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 15/22] tools/nolibc: add auxiliary vector retrieval for arm64 Date: Tue, 10 Jan 2023 08:24:27 +0100 Message-Id: <20230110072434.3863-16-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-aarch64.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 2e3d9adc4c4c..383baddef701 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -170,6 +170,7 @@ struct sys_stat_struct { }) char **environ __attribute__((weak)); +const unsigned long *_auxv __attribute__((weak)); /* startup code */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) @@ -182,6 +183,12 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) "add x2, x2, x1\n" // + argv "adrp x3, environ\n" // x3 = &environ (high bits) "str x2, [x3, #:lo12:environ]\n" // store envp into environ + "mov x4, x2\n" // search for auxv (follows NULL after last env) + "0:\n" + "ldr x5, [x4], 8\n" // x5 = *x4; x4 += 8 + "cbnz x5, 0b\n" // and stop at NULL after last env + "adrp x3, _auxv\n" // x3 = &_auxv (high bits) + "str x4, [x3, #:lo12:_auxv]\n" // store x4 into _auxv "and sp, x1, -16\n" // sp must be 16-byte aligned in the callee "bl main\n" // main() returns the status code, we'll exit with it. "mov x8, 93\n" // NR_exit == 93 -- 2.17.5