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 7401EC433F5 for ; Thu, 14 Apr 2022 14:01:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A7C0083EE8; Thu, 14 Apr 2022 16:00:43 +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="DsM/dy2y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB1A983ED6; Thu, 14 Apr 2022 16:00:17 +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 C0FFD83EA1 for ; Thu, 14 Apr 2022 16:00:02 +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=34ShYYgYKBqwMeOgXXSaaSXQ.OaYg-NaafXUefe.PQZj.PQ@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id i184-20020a1c3bc1000000b0038e4c5968b5so4577325wma.0 for ; Thu, 14 Apr 2022 07:00:02 -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=A/F5sdO4lKEMgMB9P5brC/TmPQkeiDRPcvRTIaGqFv8=; b=DsM/dy2yFxdW4mmwVBwfDi3rdF8nK7YrFkuuqg+j8ShGfAyM1sqmOk2+tQjE34Rt/t ISLSXK/nIAIKY0NkiJGodkUmPu2gKe1lBSrTmAXz8EvxNFvCIux/JnVdWGmNG075wclX R4lawM3o1iW1O1B/zxh+Uu5L1aDgqn9FYGYoagXgmIXMoAdwWwo4FJPYjZ/9c3iLupRD 7I8XsjAg0zSABFRW63SHhFOAkwfXo4SqHNFYSndUcIELphnfdL756IghNzHspi7bTciX sB1mnfyL1xGmBoglg8g4htshWVpYwSqsAvp9Qz5LVzQXSk3j5ALU7W3792b3vGKM1Dx5 vYrA== 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=A/F5sdO4lKEMgMB9P5brC/TmPQkeiDRPcvRTIaGqFv8=; b=GxNpUzKAujwdlRMoXE6LWDTsyVLCliVc31/5prtjqK6r918IX+3PnJg2DS51llTH6v ke+u6iGliSw8RbH9/CjPPkuyvMj7EZek2plLCRvrc4UGzDPqhIhfvvYglV6j9Ov17ado ytyD5/kOvRIjpKDc9N4oN3SG+dQkaCCyvQYAdajtszHJ0GHrDvo2uirt2D4agwDucgVh 06ZPIQ5kFxaQn5SAPGzxZh9e4KX71qxEdtNLjip9eKp4Vcoff8Z3qInDo1GTDO2JwLdy zdqQe/1wo/TcnKosM8tPgltfQHasJGMXM803sMMeRBWZzP3xiCHAFCFS2dYACtyi2Mrs x/dg== X-Gm-Message-State: AOAM533o9JmWaIMzP+duDsNc4J0suwqqv2s7PEqps+qR0ogseYSL/Y4e Woxo+Q1OGDKpV1iu2K6NENByAWHX9oVTGiE7YYFXZjxxCVUpsVgYqPWS0/2oo62lFXUCpaLD6VW LG/3Z3bQNq9o9/zhbnkQGPkmqYWIZORswVeVSfTHOIeD7fidEFNcpAkIDB+M= X-Google-Smtp-Source: ABdhPJybB9hf52y0pCWfEWHoeO+SlXnPm4xE01bjh8YFSzPsT270teaoj64KAJG49FdEuenDXMQPvwfMxxU= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a05:600c:1e08:b0:38e:c0e4:e500 with SMTP id ay8-20020a05600c1e0800b0038ec0e4e500mr3868703wmb.28.1649944801512; Thu, 14 Apr 2022 07:00:01 -0700 (PDT) Date: Thu, 14 Apr 2022 13:59:37 +0000 In-Reply-To: <20220414135941.1732585-1-ascull@google.com> Message-Id: <20220414135941.1732585-9-ascull@google.com> Mime-Version: 1.0 References: <20220414135941.1732585-1-ascull@google.com> X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v2 08/12] sandbox: Decouple program entry from sandbox init From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, xypron.glpk@gmx.de, 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 72a72029f2..5ea4135741 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -1000,3 +1001,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 6bcb8ffa28..40430c8c11 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.35.1.1178.g4f1659d476-goog