From mboxrd@z Thu Jan 1 00:00:00 1970 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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3A39C433EF for ; Mon, 30 May 2022 10:02:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8792E843EF; Mon, 30 May 2022 12:01:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="bvAQNJdU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21BE6843A7; Mon, 30 May 2022 12:01:05 +0200 (CEST) Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 594D0843D4 for ; Mon, 30 May 2022 12:00:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=30JWUYgYKBmkHZJbSSNVVNSL.JVTb-IVVaSPZaZ.KLUe.KL@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id m26-20020a05600c3b1a00b00397220d6329so6720205wms.5 for ; Mon, 30 May 2022 03:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WGOoVKEaVf60IkM4sQLmloLTouOAiaT/jWxgG6H6Bis=; b=bvAQNJdUo7loBpvkjS33CFOqJ/2wnbGqzUL6F7Xb63Ai5AuB4IeSih1TSG8idVq2aT jBZRLjbwumTrHACDJVLbx8imCMsB9B1oNn0ZFLdczpq7L2T4ctFxSv+7NgDIlS+UTDgT uVnetfiz14CmICaAkoxchubcu7dV6eVyllXpexqo3KwxY7YArbeO80UQonIk4kO4kfMZ JeRKBCE7goRxoiSq6k3EyNcVoONqY8EYGI99/zmzyy0i14U7+vpsbRB/dg1RXZrWQgpJ grWzBBitb4wy1evXtO5iP+r6WUDcXC5tQ6qI4k+EKybx6Kn70lk1E1VPg6jxFCnSTEUx 8nrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WGOoVKEaVf60IkM4sQLmloLTouOAiaT/jWxgG6H6Bis=; b=EdoSoo8Riq9TDqAqq5ijFYRfjiIajyDFe0gTHF1Y/CRznDCVAAvTTKSOCol3QrPHIT ltUCI5KgqIOrAco7xsUGABZOxbipJlVTC4y8q9+U6yAg7QDn5c90GQdmQy+q4uWVeT0d dnQeAgMo/2jcwuQ9jwMu2Tx2tCyGwvuhzPw3VlLEeXjgakKCDkD5R+BNRCdqM2BGazyu cikslm40KGD9Eq9tTA9UTQv6vsYPvaCL+YX8htNg4k0YEycnCQ4zf0mS6QUJHO5lVgHV pA9YmaIpBLwMtN5CLWStG6fdvTqgyemIj/x3rIw055rdRi/seOxCLzJV4ubC6KISYk80 YF1Q== X-Gm-Message-State: AOAM531o2ch9V5J+awVFwwrP+T6EY+bX2RqF6AfjJkSVCwBV/kxSmy6g qZAAXa0DeixB2fW2y3cJrCXrcgl6qpG8tf/rWZeXin345ggMKzVJEnSat4a0plzGWTo5MCLBc2l cr0HIZhNCNqztNNVMefBOFFFbhPenwBqpxMe0rkG7Sn00mrIuDLlTRQurh98= X-Google-Smtp-Source: ABdhPJwZI94rbBGVMJ4AlexTCEQCS+7mTAsyLEtROdoF+PAvdUmSZOKYnrH3B8XqDtq2mOyDil9O1mMhhDA= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a05:600c:35cd:b0:397:7493:5efb with SMTP id r13-20020a05600c35cd00b0039774935efbmr18734484wmq.95.1653904848575; Mon, 30 May 2022 03:00:48 -0700 (PDT) Date: Mon, 30 May 2022 10:00:10 +0000 In-Reply-To: <20220530100013.3753780-1-ascull@google.com> Message-Id: <20220530100013.3753780-11-ascull@google.com> Mime-Version: 1.0 References: <20220530100013.3753780-1-ascull@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH v3 10/13] sandbox: Decouple program entry from sandbox init From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, trini@konsulko.com, xypron.glpk@gmx.de, jonbottarini@google.com, seanga2@gmail.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Move the program's entry point to os.c, in preparation for a separate fuzzing entry point to be added. Signed-off-by: Andrew Scull Reviewed-by: Simon Glass --- arch/sandbox/cpu/os.c | 6 ++++++ arch/sandbox/cpu/start.c | 2 +- arch/sandbox/include/asm/main.h | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 arch/sandbox/include/asm/main.h diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5ea5417917..f229d1621a 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -1001,3 +1002,8 @@ void os_relaunch(char *argv[]) execv(argv[0], argv); os_exit(1); } + +int main(int argc, char *argv[]) +{ + return sandbox_main(argc, argv); +} diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 0f5a87309d..90a84e93c7 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -453,7 +453,7 @@ void sandbox_reset(void) os_relaunch(os_argv); } -int main(int argc, char *argv[]) +int sandbox_main(int argc, char *argv[]) { struct sandbox_state *state; void * text_base; diff --git a/arch/sandbox/include/asm/main.h b/arch/sandbox/include/asm/main.h new file mode 100644 index 0000000000..7a2f0d3a8d --- /dev/null +++ b/arch/sandbox/include/asm/main.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2022 Google, Inc. + * Written by Andrew Scull + */ + +#ifndef __ASM_SANDBOX_MAIN_H +#define __ASM_SANDBOX_MAIN_H + +/** + * sandbox_main() - main entrypoint for sandbox + * + * @argc: the number of arguments passed to the program + * @argv: array of argc+1 pointers, of which the last one is null + */ +int sandbox_main(int argc, char *argv[]); + +#endif /* __ASM_SANDBOX_MAIN_H */ -- 2.36.1.124.g0e6072fb45-goog