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 9FFB2C433FE for ; Thu, 7 Apr 2022 09:43:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC1B183DB6; Thu, 7 Apr 2022 11:43:04 +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="pKbI8Pur"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD2E283D0D; Thu, 7 Apr 2022 11:42:08 +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 78EB283C6C for ; Thu, 7 Apr 2022 11:41: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=327FOYgYKBpIwEyG772AA270.yA8G-xAAF74EFE.z09J.z0@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id v62-20020a1cac41000000b0038cfe6edf3fso4330949wme.5 for ; Thu, 07 Apr 2022 02:41:47 -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=cMuBsWSGsXU0550XXfBBpVRIAU8/ID1dBe7Dr0RPi8g=; b=pKbI8PurXhYdCeish5QTYvkj+bx8nkuuGjAn6iUcIwMEnNvOZNZrkbkzwBg7JQ848X Jb6mAJj/6AWI7L4oa7zG8iJSbkruqXBnwLT2AjhwwW9WdaK8BloAZEGPgA4MOaaIxl0k FUE86mliu36+SvEVn0GDSmr+wRxov/h61W+LVwaCLzbz8n73PKIVhujfU7EGSHbd9AsH +q8HA+FWlsKqwjLMT9FAS/FNTVdGjjNpLjmi6ywyMKUL+na2bPuqeSYaa3kgqVAn/xfA rE+dTej4XZxFS9dXsbfpJwsVWSF7w+oHpT7aeysRGBkxAvRi6LBepRoNJU+7MYkPUIWx w5sQ== 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=cMuBsWSGsXU0550XXfBBpVRIAU8/ID1dBe7Dr0RPi8g=; b=DxkNCw0+rPG46uVUdf4LUwZC/vFQD9ZAe8wizojgmBZk4AdQhsIbiNZByzIc+ADroh NFDE4NWldN67eyLeNedt3qTuW0TksUPywbFRJyp7fy7jpUxBSuNjQjgFvwjscloB0V9F /nqdY4hQOJJjUMcLzgo4Wbyg423rCxQtfNIDhoi/aBp/H1rx/nLlf+NU9MPSlTDuBD9V fH0QzEPaK8uIhFwkyqPFR15iwxcrS7bdWtVFgslqdIgB1elramT2AeogHwE8xmsBufFj s+i1L85cZMzCQNJVQYagWYxQXZ39KDLGucMM5YDnGXdbcIzvIrRINx/3R+yJU4YiXWqN K9Og== X-Gm-Message-State: AOAM530qrlALFXN6Dt3RY4yWEVn/KetICjpEwxJ7dc93XWoMvY/fm5II CrkPV34+YWyHaL1Fe32iIoJE36FHZnOeYEL2utjZdZwaaz7TvrPPxrDTdZvJnQs/PqfTwHaaNwB fQc3rDFXqLwVbhGqwsiZLnFYLClNh6R8lNcapeuvtq1GH7juqlsq7iUWUN18= X-Google-Smtp-Source: ABdhPJwvwdVKzP7z6NkN6oiq+WrrmK/Rkm95ZncGnQh8T70eXAaunDhUBVffVLg/M/Wp6uy5EXVPswVDXAQ= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a7b:ce0a:0:b0:38e:761a:1c76 with SMTP id m10-20020a7bce0a000000b0038e761a1c76mr11434564wmc.198.1649324507004; Thu, 07 Apr 2022 02:41:47 -0700 (PDT) Date: Thu, 7 Apr 2022 09:41:19 +0000 In-Reply-To: <20220407094123.1752236-1-ascull@google.com> Message-Id: <20220407094123.1752236-8-ascull@google.com> Mime-Version: 1.0 References: <20220407094123.1752236-1-ascull@google.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH 07/11] sandbox: Decouple program entry from sandbox init From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, 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 --- 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 5cb47e1156..ba67f4fbd7 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -451,7 +451,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.1094.g7c7d902a7c-goog