Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
b63eea45
Commit
b63eea45
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Improved binfmt debug output
parent
089a49d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
binfmt/binfmt_exec.c
+35
-16
35 additions, 16 deletions
binfmt/binfmt_exec.c
binfmt/binfmt_loadmodule.c
+2
-3
2 additions, 3 deletions
binfmt/binfmt_loadmodule.c
binfmt/libelf/libelf_load.c
+0
-1
0 additions, 1 deletion
binfmt/libelf/libelf_load.c
with
37 additions
and
20 deletions
binfmt/binfmt_exec.c
+
35
−
16
View file @
b63eea45
...
...
@@ -102,6 +102,7 @@ int exec(FAR const char *filename, FAR char * const *argv,
#if defined(CONFIG_SCHED_ONEXIT) && defined(CONFIG_SCHED_HAVE_PARENT)
FAR
struct
binary_s
*
bin
;
int
pid
;
int
err
;
int
ret
;
/* Allocate the load information */
...
...
@@ -109,8 +110,9 @@ int exec(FAR const char *filename, FAR char * const *argv,
bin
=
(
FAR
struct
binary_s
*
)
kmm_zalloc
(
sizeof
(
struct
binary_s
));
if
(
!
bin
)
{
set_errno
(
ENOMEM
);
return
ERROR
;
bdbg
(
"ERROR: Failed to allocate binary_s
\n
"
);
err
=
ENOMEM
;
goto
errout
;
}
/* Load the module into memory */
...
...
@@ -123,9 +125,9 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret
=
load_module
(
bin
);
if
(
ret
<
0
)
{
bdbg
(
"ERROR: Failed to load program '%s'
\n
"
,
filename
);
kmm_free
(
bin
);
return
ERROR
;
err
=
get_errno
(
);
bdbg
(
"ERROR: Failed to load program '%s': %d
\n
"
,
filename
,
err
);
goto
errout_with_bin
;
}
/* Disable pre-emption so that the executed module does
...
...
@@ -140,11 +142,9 @@ int exec(FAR const char *filename, FAR char * const *argv,
pid
=
exec_module
(
bin
);
if
(
pid
<
0
)
{
bdbg
(
"ERROR: Failed to execute program '%s'
\n
"
,
filename
);
sched_unlock
();
unload_module
(
bin
);
kmm_free
(
bin
);
return
ERROR
;
err
=
get_errno
();
bdbg
(
"ERROR: Failed to execute program '%s': %d
\n
"
,
filename
,
err
);
goto
errout_with_lock
;
}
/* Set up to unload the module (and free the binary_s structure)
...
...
@@ -154,13 +154,25 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret
=
schedule_unload
(
pid
,
bin
);
if
(
ret
<
0
)
{
bdbg
(
"ERROR: Failed to schedul unload '%s'
\n
"
,
filename
);
err
=
get_errno
();
bdbg
(
"ERROR: Failed to schedule unload '%s': %d
\n
"
,
filename
,
err
);
}
sched_unlock
();
return
pid
;
errout_with_lock:
sched_unlock
();
unload_module
(
bin
);
errout_with_bin:
kmm_free
(
bin
);
errout:
set_errno
(
err
);
return
ERROR
;
#else
struct
binary_s
bin
;
int
err
;
int
ret
;
/* Load the module into memory */
...
...
@@ -173,8 +185,9 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret
=
load_module
(
&
bin
);
if
(
ret
<
0
)
{
bdbg
(
"ERROR: Failed to load program '%s'
\n
"
,
filename
);
return
ERROR
;
err
=
get_errno
();
bdbg
(
"ERROR: Failed to load program '%s': %d
\n
"
,
filename
,
err
);
goto
errout
;
}
/* Then start the module */
...
...
@@ -182,14 +195,20 @@ int exec(FAR const char *filename, FAR char * const *argv,
ret
=
exec_module
(
&
bin
);
if
(
ret
<
0
)
{
bdbg
(
"ERROR: Failed to execute program '%s'
\n
"
,
filename
);
unload_module
(
&
bin
);
return
ERROR
;
err
=
get_errno
(
);
bdbg
(
"ERROR: Failed to execute program '%s': %d
\n
"
,
filename
,
err
);
goto
errout_with_module
;
}
/* TODO: How does the module get unloaded in this case? */
return
ret
;
errout_with_module:
unload_module
(
&
bin
);
errout:
set_errno
(
err
);
return
ERROR
;
#endif
}
...
...
This diff is collapsed.
Click to expand it.
binfmt/binfmt_loadmodule.c
+
2
−
3
View file @
b63eea45
...
...
@@ -120,7 +120,7 @@ static int load_absmodule(FAR struct binary_s *bin)
FAR
struct
binfmt_s
*
binfmt
;
int
ret
=
-
ENOENT
;
bdbg
(
"Loading %s
\n
"
,
bin
->
filename
);
b
v
dbg
(
"Loading %s
\n
"
,
bin
->
filename
);
/* Disabling pre-emption should be sufficient protection while accessing
* the list of registered binary format handlers.
...
...
@@ -262,7 +262,7 @@ int load_module(FAR struct binary_s *bin)
if
(
ret
<
0
)
{
bdbg
(
"Returning errno %d
\n
"
,
-
ret
);
bdbg
(
"
ERROR:
Returning errno %d
\n
"
,
-
ret
);
set_errno
(
-
ret
);
return
ERROR
;
}
...
...
@@ -271,4 +271,3 @@ int load_module(FAR struct binary_s *bin)
}
#endif
/* CONFIG_BINFMT_DISABLE */
This diff is collapsed.
Click to expand it.
binfmt/libelf/libelf_load.c
+
0
−
1
View file @
b63eea45
...
...
@@ -61,7 +61,6 @@
#define ELF_ALIGNUP(a) (((unsigned long)(a) + ELF_ALIGN_MASK) & ~ELF_ALIGN_MASK)
#define ELF_ALIGNDOWN(a) ((unsigned long)(a) & ~ELF_ALIGN_MASK)
#ifndef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment