aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Scull <ascull@google.com>2022-05-30 10:00:10 +0000
committerTom Rini <trini@konsulko.com>2022-06-23 12:58:18 -0400
commit001c39a196c2f4414ddab8713fa113dd06a028eb (patch)
tree657e0e6aac951a08364ef2c85ac83bdf601725f0
parent36f641c54e1ad7f08552fe51f9826c1a27b662f9 (diff)
downloadu-boot-001c39a196c2f4414ddab8713fa113dd06a028eb.zip
u-boot-001c39a196c2f4414ddab8713fa113dd06a028eb.tar.gz
u-boot-001c39a196c2f4414ddab8713fa113dd06a028eb.tar.bz2
sandbox: Decouple program entry from sandbox init
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 <ascull@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/sandbox/cpu/os.c6
-rw-r--r--arch/sandbox/cpu/start.c2
-rw-r--r--arch/sandbox/include/asm/main.h18
3 files changed, 25 insertions, 1 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 5ea5417..f229d16 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -27,6 +27,7 @@
#include <linux/types.h>
#include <asm/getopt.h>
+#include <asm/main.h>
#include <asm/sections.h>
#include <asm/state.h>
#include <os.h>
@@ -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 0f5a873..90a84e9 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 0000000..7a2f0d3
--- /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 <ascull@google.com>
+ */
+
+#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 */