Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5901103rwl; Mon, 9 Jan 2023 01:07:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1fOvtd47TrD2bXznI9801HqnakCNU+ACqPqqSemc8rM51K8Z7Qrh3hzQqUr1Ts1U81c2Z X-Received: by 2002:a17:906:6b8c:b0:841:df6e:a32e with SMTP id l12-20020a1709066b8c00b00841df6ea32emr70037585ejr.25.1673255278464; Mon, 09 Jan 2023 01:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673255278; cv=none; d=google.com; s=arc-20160816; b=xOXKD6vXsRVmpv0wrNuy6BuXo2hKLnwSUfk1kJFuXwB9gW7zjiYyEBg/QpWm8BdQFQ lDfK1jfgGW8W/C0xZwiOC5zgiRUmC7As+2t+IFZHAnMrana1Qpd/il/BmQX+w9H97Zyh F4iPGGK1Xbs+sVa2C2osjVOpAb8D2bd1vP4g0kOjrX87S/dYE7scRYA7lx1NXJb0Pz+h dL0fED6CTZX5auOftAyeYayYUYn3a/p5HYWIPWBdRsfCMkAtZWNQ8lDTLyOM7Q7SngHa QJoN9tA7QcvlB05nHORBGT96R2GwvSKG69mq1TTeldF4mEguFiluK/6pmUlQ74NuA1X3 FUPQ== 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=NhiG7L5hVkdA7N1MjqZUPasEzhj4bn5BWpHQIRKpLpQxsWu8N2hc9QUyA4Mo5iQrBb hXul7fabMUIsvvb3Z7epN5b18L/jQNxPo1Nupp58x3ZgCOTTUV+oyXuE87zfVosRND8o l7XdnbbrAb234+cwf6B6FoTDvIiMs+G6uaAMzXbAG04pfOyPSQfF0iLsRcMJDUMUhfl4 dKIA1k3Rq5lnDUY4ON+/MZEifvp3jGVVBQjC4uO5eWJhWScQuYYTcRXOaE1vu+vh29OU /6uX8uKzBdC3Pr+qDG49j/yzkASVLhYPT4mM3ZXK6/djYb+umqTbCTYroauOiGGAWURa UAUw== 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 gb27-20020a170907961b00b0084c7e7eb6fdsi9689882ejc.131.2023.01.09.01.07.45; Mon, 09 Jan 2023 01:07:58 -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 S236628AbjAIIqq (ORCPT + 54 others); Mon, 9 Jan 2023 03:46:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236968AbjAIIp4 (ORCPT ); Mon, 9 Jan 2023 03:45:56 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DCD31140B4 for ; Mon, 9 Jan 2023 00:42:52 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3098gFrt027434; 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 15/22] tools/nolibc: add auxiliary vector retrieval for arm64 Date: Mon, 9 Jan 2023 09:42:01 +0100 Message-Id: <20230109084208.27355-16-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> 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