Skip to content

Commit

Permalink
add elfload2
Browse files Browse the repository at this point in the history
Yet another ELF loader.
  • Loading branch information
stsp committed Feb 27, 2025
1 parent b3e3457 commit bf5fc45
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bf5fc45

Please sign in to comment.