From bf5fc45b0f546aa65c58bb9611849a3bcee2e0d6 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Fri, 28 Feb 2025 01:39:43 +0300 Subject: [PATCH] add elfload2 Yet another ELF loader. --- src/command.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/command.c b/src/command.c index 9a09eeb..6c3cc87 100644 --- a/src/command.c +++ b/src/command.c @@ -205,6 +205,7 @@ static void perform_echo_dot(const char *arg); static void perform_echo(const char *arg); static void perform_elfexec(const char *arg); static void perform_elfload(const char *arg); +static void perform_elfload2(const char *arg); static void perform_exit(const char *arg); static void perform_for(const char *arg); static void perform_goto(const char *arg); @@ -261,6 +262,7 @@ struct built_in_cmd cmd_table[] = {"echo", perform_echo, "", "terminal output"}, {"elfexec", perform_elfexec, "", "execute elf file"}, {"elfload", perform_elfload, "", "load host's elf file"}, + {"elfload2", perform_elfload2, "", "load host's elf file"}, {"exit", perform_exit, "", "exit from interpreter"}, {"for", perform_for, "", "FOR loop"}, {"goto", perform_goto, "", "move to label"}, @@ -2779,6 +2781,32 @@ static void perform_elfload(const char *arg) #endif } +static void perform_elfload2(const char *arg) + { +#ifdef DJ64 + char *cs; +#endif + if (!arg || !arg[0]) + { + cprintf("Syntax error\r\n"); + reset_batfile_call_stack(); + return; + } +#ifdef DJ64 + cs = getenv("COMSPEC"); + if (!cs) + { + printf("COMSPEC not set\n"); + return; + } + setenv("ELFLOAD", arg, 1); + perform_external_cmd(false, false, cs); + unsetenv("ELFLOAD"); +#else + printf("elfload2 unsupported\n"); +#endif + } + static void perform_break(const char *arg) { if (stricmp(arg, "off") == 0)