Save argv in runtime

Ensure that the runtime captures argv so that it can be accessed later
in the process without needing to be explicitly passed around.

Signed-off-by: Curtis Millar <curtis@curtism.me>
diff --git a/include/sel4runtime.h b/include/sel4runtime.h
index b8175a1..05ab119 100644
--- a/include/sel4runtime.h
+++ b/include/sel4runtime.h
@@ -29,6 +29,16 @@
 char const *sel4runtime_process_name(void);
 
 /*
+ * Get the argument vector passed to main.
+ */
+char const *const *sel4runtime_argv(void);
+
+/*
+ * Get the length of argument vector passed to main.
+ */
+int sel4runtime_argc(void);
+
+/*
  * Get the address of the TLS base register.
  */
 static inline uintptr_t sel4runtime_get_tls_base(void);
diff --git a/src/env.c b/src/env.c
index 9e914ef..56b5d2b 100644
--- a/src/env.c
+++ b/src/env.c
@@ -80,6 +80,10 @@
         size_t offset;
     } tls;
 
+    // Argument vector
+    char const *const *argv;
+    int argc;
+
     // Auxiliary vector
     auxv_t const *auxv;
 
@@ -116,6 +120,16 @@
     return env.process_name;
 }
 
+char const *const *sel4runtime_argv(void)
+{
+    return env.argv;
+}
+
+int sel4runtime_argc(void)
+{
+    return env.argc;
+}
+
 seL4_BootInfo *sel4runtime_bootinfo(void)
 {
     return env.bootinfo;
@@ -232,16 +246,23 @@
 }
 
 void __sel4runtime_load_env(
-    char const *arg0,
-    char const *const *envp,
+    int argc,
+    char const * const *argv,
+    char const * const *envp,
     auxv_t const auxv[]
 )
 {
     empty_tls();
     parse_auxv(auxv);
     parse_phdrs();
-    name_process(arg0);
+    if (argc > 0) {
+        name_process(argv[0]);
+    }
     try_init_static_tls();
+
+    env.argc = argc;
+    env.argv = argv;
+
     __sel4runtime_run_constructors();
 
     env.auxv = auxv;
diff --git a/src/start.c b/src/start.c
index 5f505b9..0822def 100644
--- a/src/start.c
+++ b/src/start.c
@@ -20,7 +20,7 @@
     char const * const *envp,
     auxv_t const auxv[]
 ) {
-    __sel4runtime_load_env(argv[0], envp, auxv);
+    __sel4runtime_load_env(argc, argv, envp, auxv);
 
     sel4runtime_exit(main(argc, argv, envp));
 }
diff --git a/src/start.h b/src/start.h
index 2f59206..d505b5d 100644
--- a/src/start.h
+++ b/src/start.h
@@ -21,7 +21,8 @@
  * functions.
  */
 void __sel4runtime_load_env(
-    char const *arg0,
+    int argc,
+    char const * const *argv,
     char const * const *envp,
     auxv_t const auxv[]
 );