summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Gaisler <jiri@gaisler.se>2019-07-02 21:06:47 +0200
committerJiri Gaisler <jiri@gaisler.se>2019-07-02 21:06:47 +0200
commit787997a6e90e22537d61f4c155ac0a5bf2018109 (patch)
treea4e7cd14ef4d3bfc8751217954fb991449d1cede
parent4c33d10a1fbe19299cbd0e9954196b36b1c60ae3 (diff)
elf_load() failed in interactive shell.
-rw-r--r--elf.c23
-rw-r--r--sis.h2
2 files changed, 11 insertions, 14 deletions
diff --git a/elf.c b/elf.c
index 2a73ce3..f0240dc 100644
--- a/elf.c
+++ b/elf.c
@@ -112,7 +112,7 @@ read_elf_body ()
FILE *fp = efile.fp;
fseek (fp, ehdr.e_shoff + ((ehdr.e_shstrndx) * ehdr.e_shentsize), SEEK_SET);
- if (fread (&ssh, sizeof (ssh), 1, fp) != 1)
+ if ((!fp) || (fread (&ssh, sizeof (ssh), 1, fp) != 1))
{
return (-1);
}
@@ -217,26 +217,23 @@ read_elf_body ()
}
int
-elf_load (char *fname, int readsym)
+elf_load (char *fname, int load)
{
FILE *fp;
int res;
- if (!readsym)
+ if ((fp = fopen (fname, "r")) == NULL)
{
- if ((fp = fopen (fname, "r")) == NULL)
- {
- printf ("file not found\n");
- return (-1);
- }
+ printf ("file not found\n");
+ return (-1);
+ }
- res = read_elf_header (fp);
- if (res < 0)
- printf ("File read error\n");
+ res = read_elf_header (fp);
+ if (res < 0)
+ printf ("File read error\n");
- }
- else
+ if (load && (res >= 0))
{
res = read_elf_body ();
if (res < 0)
diff --git a/sis.h b/sis.h
index a15a83f..8ddb6bb 100644
--- a/sis.h
+++ b/sis.h
@@ -292,7 +292,7 @@ extern int check_wpw (struct pstate *sregs, int32 address,
extern void reset_all (void);
extern void sys_reset (void);
extern void sys_halt (void);
-extern int elf_load (char *fname, int readsym);
+extern int elf_load (char *fname, int load);
extern double get_time (void);
extern int nouartrx;
//extern host_callback *sim_callback;