static void
usage (void)
{
- fprintf (stderr, "Usage: %s [options] program [program args]\n", myname);
+ fprintf (stderr, "Usage: %s [options] [--] program [program args]\n", myname);
fprintf (stderr, "Run `%s --help' for full list of options.\n", myname);
exit (1);
}
OPTION_VERSION,
OPTION_LOAD_LMA,
OPTION_LOAD_VMA,
- OPTION_SYSROOT
+ OPTION_SYSROOT,
+ OPTION_ARGV0,
} STANDARD_OPTIONS;
static const OPTION standard_options[] =
"Root for system calls with absolute file-names and cwd at start",
standard_option_handler, NULL },
+ { {"argv0", required_argument, NULL, OPTION_ARGV0},
+ '\0', "ARGV0", "Set argv[0] to the specified string",
+ standard_option_handler, NULL },
+
{ {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL, NULL }
};
else
simulator_sysroot = "";
break;
+
+ case OPTION_ARGV0:
+ free (STATE_PROG_ARGV0 (sd));
+ STATE_PROG_ARGV0 (sd) = xstrdup (arg);
+ break;
}
return SIM_RC_OK;
{
if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
{
+ char **new_argv = dupargv (argv + optind);
+
STATE_PROG_FILE (sd) = xstrdup (argv[optind]);
- STATE_PROG_ARGV (sd) = dupargv (argv + optind);
+ if (STATE_PROG_ARGV0 (sd) != NULL)
+ {
+ free (new_argv[0]);
+ new_argv[0] = xstrdup (STATE_PROG_ARGV0 (sd));
+ }
+ freeargv (STATE_PROG_ARGV (sd));
+ STATE_PROG_ARGV (sd) = new_argv;
}
break;
}
sim_print_help (SIM_DESC sd, int is_command)
{
if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
- sim_io_printf (sd, "Usage: %s [options] program [program args]\n",
+ sim_io_printf (sd, "Usage: %s [options] [--] program [program args]\n",
STATE_MY_NAME (sd));
/* Initialize duplicate argument checker. */