summaryrefslogtreecommitdiff
path: root/apps/examples/elf
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-19 21:16:03 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-19 21:16:03 +0000
commit1f5151d2c5574cbb57e57ea32416ca8970e0dec4 (patch)
tree96a1a335193aa75f1690a4226655ddbf2dc7bb73 /apps/examples/elf
parent913f876fac94f21a683809d9f648e4793f61e237 (diff)
downloadnuttx-1f5151d2c5574cbb57e57ea32416ca8970e0dec4.tar.gz
nuttx-1f5151d2c5574cbb57e57ea32416ca8970e0dec4.tar.bz2
nuttx-1f5151d2c5574cbb57e57ea32416ca8970e0dec4.zip
Some minor fixes for CONFIG_ADDRENV=y
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5444 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/elf')
-rw-r--r--apps/examples/elf/elf_main.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/apps/examples/elf/elf_main.c b/apps/examples/elf/elf_main.c
index 669de430d..66a47592c 100644
--- a/apps/examples/elf/elf_main.c
+++ b/apps/examples/elf/elf_main.c
@@ -70,6 +70,10 @@
# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file"
#endif
+#ifdef CONFIG_BINFMT_DISABLE
+# error "The binary loader is disabled (CONFIG_BINFMT_DISABLE)!"
+#endif
+
#ifndef CONFIG_ELF
# error "You must select CONFIG_ELF in your configuration file"
#endif
@@ -136,7 +140,9 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */
static const char delimiter[] =
"****************************************************************************";
-static char path[128];
+#ifndef CONFIG_BINFMT_EXEPATH
+static char fullpath[128];
+#endif
/****************************************************************************
* Symbols from Auto-Generated Code
@@ -264,19 +270,46 @@ int elf_main(int argc, char *argv[])
mm_update(&g_mmstep, "after mount");
+ /* Does the system support the PATH variable? Has the PATH variable
+ * already been set? If YES and NO, then set the PATH variable to
+ * the ROMFS mountpoint.
+ */
+
+#if defined(CONFIG_BINFMT_EXEPATH) && !defined(CONFIG_PATH_INITIAL)
+ (void)setenv("PATH", MOUNTPT, 1);
+#endif
+
/* Now excercise every program in the ROMFS file system */
for (i = 0; dirlist[i]; i++)
{
+ /* Output a seperated so that we can clearly discrinmate the output of
+ * this program from the others.
+ */
+
testheader(dirlist[i]);
+ /* Initialize the binary_s structure */
+
memset(&bin, 0, sizeof(struct binary_s));
- snprintf(path, 128, "%s/%s", MOUNTPT, dirlist[i]);
- bin.filename = path;
+ /* If the binary loader does not support the PATH variable, then
+ * create the full path to the executable program. Otherwise,
+ * use the relative path so that the binary loader will have to
+ * search the PATH variable to find the executable.
+ */
+
+#ifdef CONFIG_BINFMT_EXEPATH
+ bin.filename = dirlist[i];
+#else
+ snprintf(fullpath, 128, "%s/%s", MOUNTPT, dirlist[i]);
+ bin.filename = fullpath;
+#endif
bin.exports = exports;
bin.nexports = nexports;
+ /* Load the ELF module */
+
ret = load_module(&bin);
if (ret < 0)
{
@@ -286,6 +319,8 @@ int elf_main(int argc, char *argv[])
mm_update(&g_mmstep, "after load_module");
+ /* Execute the ELF module */
+
ret = exec_module(&bin, 50);
mm_update(&g_mmstep, "after exec_module");