This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 5961b8bd1af binfmt: Add a configuration flag to store the module
filename
5961b8bd1af is described below
commit 5961b8bd1aff7227468651423bc8ed775d355f1f
Author: Jukka Laitinen <[email protected]>
AuthorDate: Tue Sep 30 09:35:30 2025 +0300
binfmt: Add a configuration flag to store the module filename
This flag can be used to store the filename of a loaded module or
executable in binfmt. The filename is useful for example in debugging.
For example, gdb or a jtag debugger can be configured to automatically
fetch the symbols for the currently executing module.
Signed-off-by: Jukka Laitinen <[email protected]>
---
binfmt/Kconfig | 6 ++++++
binfmt/binfmt_loadmodule.c | 6 ++++++
include/nuttx/binfmt/binfmt.h | 5 +++++
3 files changed, 17 insertions(+)
diff --git a/binfmt/Kconfig b/binfmt/Kconfig
index fc8255b0217..93844898da0 100644
--- a/binfmt/Kconfig
+++ b/binfmt/Kconfig
@@ -89,3 +89,9 @@ config BINFMT_ELF_EXECUTABLE
Produce a full linked executable object as output.
endchoice
+
+config BINFMT_STORE_FILENAME
+ bool "Store the binary filename"
+ default n
+ ---help---
+ Store the filename of the loaded binary
diff --git a/binfmt/binfmt_loadmodule.c b/binfmt/binfmt_loadmodule.c
index 95daa44c8ec..03d460827f9 100644
--- a/binfmt/binfmt_loadmodule.c
+++ b/binfmt/binfmt_loadmodule.c
@@ -122,6 +122,12 @@ static int load_absmodule(FAR struct binary_s *bin, FAR
const char *filename,
binfo("Successfully loaded module %s\n", filename);
+ /* Save the filename of the loaded module */
+
+#ifdef CONFIG_BINFMT_STORE_FILENAME
+ strlcpy(bin->fname, filename, sizeof(bin->fname));
+#endif
+
/* Save the unload method for use by unload_module */
bin->unload = binfmt->unload;
diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h
index 5a8cfee79b2..bff5e008aae 100644
--- a/include/nuttx/binfmt/binfmt.h
+++ b/include/nuttx/binfmt/binfmt.h
@@ -96,6 +96,11 @@ struct binary_s
uint8_t priority; /* Task execution priority */
size_t stacksize; /* Size of the stack in bytes
(unallocated) */
+
+#ifdef CONFIG_BINFMT_STORE_FILENAME
+ char fname[NAME_MAX];
+#endif
+
#ifdef CONFIG_SCHED_USER_IDENTITY
uid_t uid; /* File owner user identity */
gid_t gid; /* File owner group user identity */