You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/07/10 20:03:23 UTC
[nuttx] branch master updated (899471c6bd -> 9dc59e9109)
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 899471c6bd add support for YT8512 phy
new 229293f9f8 binfmt: Move [elf|nxflat]_[un]initialize to private header file
new ebcb03dce9 libc/symtab: Don't include symtab.h in the header files
new 9dc59e9109 Fix error: Mixed case identifier found
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
binfmt/Makefile | 12 ++++
binfmt/binfmt.h | 67 ++++++++++++++++++++-
binfmt/binfmt_execsymtab.c | 2 +-
binfmt/binfmt_initialize.c | 3 -
binfmt/libelf/Make.defs | 4 --
binfmt/libnxflat/Make.defs | 4 --
.../olimex-stm32-p407/src/olimex-stm32-p407.h | 1 +
build-globals.sh | 18 +++---
include/nuttx/allsyms.h | 4 +-
include/nuttx/binfmt/elf.h | 47 +++------------
include/nuttx/binfmt/nxflat.h | 30 ----------
include/nuttx/binfmt/symtab.h | 4 +-
include/nuttx/lib/modlib.h | 44 +++++++-------
libs/libc/dlfcn/lib_dlsym.c | 1 +
libs/libc/modlib/modlib_globals.S | 12 ++--
libs/libc/modlib/modlib_symbols.c | 68 ++++++++++++----------
libs/libc/modlib/modlib_symtab.c | 1 +
libs/libc/stdio/lib_libvsprintf.c | 1 +
libs/libc/symtab/symtab_allsyms.c | 1 +
sched/module/mod_modsym.c | 1 +
20 files changed, 167 insertions(+), 158 deletions(-)
[nuttx] 03/03: Fix error: Mixed case identifier found
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9dc59e910974ffa76d7b68f3f551f57936ef7cc8
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jul 9 06:16:11 2023 +0800
Fix error: Mixed case identifier found
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
.../olimex-stm32-p407/src/olimex-stm32-p407.h | 1 +
build-globals.sh | 18 +++---
include/nuttx/lib/modlib.h | 40 ++++++-------
libs/libc/modlib/modlib_globals.S | 12 ++--
libs/libc/modlib/modlib_symbols.c | 67 ++++++++++++----------
5 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
index 6d4e2196d7..aebc2e7321 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
+++ b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <nuttx/compiler.h>
+#include <nuttx/symtab.h>
#include <stdint.h>
#include <arch/stm32/chip.h>
diff --git a/build-globals.sh b/build-globals.sh
index 9eb1d14fc4..6337966334 100755
--- a/build-globals.sh
+++ b/build-globals.sh
@@ -7,7 +7,7 @@
#
# Find an entrypoint using a binary search
#
-findEP()
+findep()
{
CHECK=$1
SIZE=${#SYM[@]}
@@ -50,7 +50,7 @@ getEP()
FUNC=(${FUNCS})
for ((j = 0; j < ${#FUNC[@]}; j++))
do
- findEP ${FUNC[$j]}
+ findep ${FUNC[$j]}
if [ $? -eq 1 ]; then
EP[${I_EP}]=${FUNC[$j]}
I_EP=$((I_EP + 1))
@@ -63,7 +63,7 @@ getEP()
#
# Symbols to ignore within the NuttX libraries
#
-FILTER="^lib_low|^FUNCTION|^STUB|^__start|^_vect|^arm_|^arp_|^bch|^binfmt|^blake|^block_|^cdcacm|^chksum|^clock_|^close_|^crypto_|^devif_|^devnull|^devuran|^devzero|^emerg|^epoll_|^elf_|^_dbgR|^dq_|^env_|^file_|^files_|^fs_|^ftl_|^g_|^get_|^group_|^global|^hcom|^i2c_|^inode_|^iob_|^irq_|^kmm_|^lfs_|^lib_|^local_|^mm_|^modlib_|^mpu_|^mq_|^nGlobals|^net_|^netdev_|^nx|^pipecommon|^posix_spawn_file|^psock_|^ramlog|^rammap|^readline_|^register_|^sched_|^sockfd|^spawn_|^sq_|^stm32|^symtab_|^sy [...]
+FILTER="^lib_low|^FUNCTION|^STUB|^__start|^_vect|^arm_|^arp_|^bch|^binfmt|^blake|^block_|^cdcacm|^chksum|^clock_|^close_|^crypto_|^devif_|^devnull|^devuran|^devzero|^emerg|^epoll_|^elf_|^_dbgR|^dq_|^env_|^file_|^files_|^fs_|^ftl_|^g_|^get_|^group_|^global|^hcom|^i2c_|^inode_|^iob_|^irq_|^kmm_|^lfs_|^lib_|^local_|^mm_|^modlib_|^mpu_|^mq_|^nglobals|^net_|^netdev_|^nx|^pipecommon|^posix_spawn_file|^psock_|^ramlog|^rammap|^readline_|^register_|^sched_|^sockfd|^spawn_|^sq_|^stm32|^symtab_|^sy [...]
if [ -z "${NM}" ]; then
NM="nm"
@@ -170,14 +170,14 @@ cat >>${GLOBALS} <<__EOF__
SIZE globalNames
.align ALIGN
- GLOBAL nGlobals
-SYMBOL(nGlobals):
+ GLOBAL nglobals
+SYMBOL(nglobals):
.word ${#EP[@]}
- SIZE nGlobals
+ SIZE nglobals
.align ALIGN
- GLOBAL globalTable
-SYMBOL(globalTable):
+ GLOBAL global_table
+SYMBOL(global_table):
__EOF__
for ((i = 0; i < ${#EP[@]}; i++))
@@ -186,7 +186,7 @@ do
done
cat >>${GLOBALS} <<__EOF__
- SIZE globalTable
+ SIZE global_table
__EOF__
echo "${#EP[@]} symbols defined"
diff --git a/include/nuttx/lib/modlib.h b/include/nuttx/lib/modlib.h
index e60e30d225..03e2f6dacf 100644
--- a/include/nuttx/lib/modlib.h
+++ b/include/nuttx/lib/modlib.h
@@ -188,26 +188,26 @@ struct mod_loadinfo_s
* after the module has been loaded.
*/
- uintptr_t textalloc; /* .text memory allocated when module was loaded */
- uintptr_t datastart; /* Start of.bss/.data memory in .text allocation */
- size_t textsize; /* Size of the module .text memory allocation */
- size_t datasize; /* Size of the module .bss/.data memory allocation */
- size_t textalign; /* Necessary alignment of .text */
- size_t dataalign; /* Necessary alignment of .bss/.text */
- off_t filelen; /* Length of the entire module file */
- Elf_Ehdr ehdr; /* Buffered module file header */
- FAR Elf_Phdr *phdr; /* Buffered module program headers */
- FAR Elf_Shdr *shdr; /* Buffered module section headers */
- FAR void *exported; /* Module exports */
- uint8_t *iobuffer; /* File I/O buffer */
- uintptr_t datasec; /* ET_DYN - data area start from Phdr */
- uintptr_t segpad; /* Padding between text and data */
- uint16_t symtabidx; /* Symbol table section index */
- uint16_t strtabidx; /* String table section index */
- uint16_t dsymtabidx; /* Dynamic symbol table section index */
- uint16_t buflen; /* size of iobuffer[] */
- int filfd; /* Descriptor for the file being loaded */
- int nexports; /* ET_DYN - Number of symbols exported */
+ uintptr_t textalloc; /* .text memory allocated when module was loaded */
+ uintptr_t datastart; /* Start of.bss/.data memory in .text allocation */
+ size_t textsize; /* Size of the module .text memory allocation */
+ size_t datasize; /* Size of the module .bss/.data memory allocation */
+ size_t textalign; /* Necessary alignment of .text */
+ size_t dataalign; /* Necessary alignment of .bss/.text */
+ off_t filelen; /* Length of the entire module file */
+ Elf_Ehdr ehdr; /* Buffered module file header */
+ FAR Elf_Phdr *phdr; /* Buffered module program headers */
+ FAR Elf_Shdr *shdr; /* Buffered module section headers */
+ FAR void *exported; /* Module exports */
+ uint8_t *iobuffer; /* File I/O buffer */
+ uintptr_t datasec; /* ET_DYN - data area start from Phdr */
+ uintptr_t segpad; /* Padding between text and data */
+ uint16_t symtabidx; /* Symbol table section index */
+ uint16_t strtabidx; /* String table section index */
+ uint16_t dsymtabidx; /* Dynamic symbol table section index */
+ uint16_t buflen; /* size of iobuffer[] */
+ int filfd; /* Descriptor for the file being loaded */
+ int nexports; /* ET_DYN - Number of symbols exported */
};
/****************************************************************************
diff --git a/libs/libc/modlib/modlib_globals.S b/libs/libc/modlib/modlib_globals.S
index f365046638..fe0b174feb 100644
--- a/libs/libc/modlib/modlib_globals.S
+++ b/libs/libc/modlib/modlib_globals.S
@@ -66,12 +66,12 @@ SYMBOL(globalNames):
SIZE globalNames
.align ALIGN
- GLOBAL nGlobals
-SYMBOL(nGlobals):
+ GLOBAL nglobals
+SYMBOL(nglobals):
.word 0
- SIZE nGlobals
+ SIZE nglobals
.align ALIGN
- GLOBAL globalTable
-SYMBOL(globalTable):
- SIZE globalTable
+ GLOBAL global_table
+SYMBOL(global_table):
+ SIZE global_table
diff --git a/libs/libc/modlib/modlib_symbols.c b/libs/libc/modlib/modlib_symbols.c
index 26784587bd..04cc9ae545 100644
--- a/libs/libc/modlib/modlib_symbols.c
+++ b/libs/libc/modlib/modlib_symbols.c
@@ -57,12 +57,19 @@ struct mod_exportinfo_s
FAR const struct symtab_s *symbol; /* Symbol info returned (if found) */
};
-struct epTable_s
+struct eptable_s
{
- uint8_t *epName; /* Name of global symbol */
- void *epAddr; /* Address of global symbol */
+ FAR uint8_t *epname; /* Name of global symbol */
+ FAR void *epaddr; /* Address of global symbol */
};
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+extern struct eptable_s global_table[];
+extern int nglobals;
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -456,12 +463,12 @@ int modlib_insertsymtab(FAR struct module_s *modp,
FAR Elf_Shdr *shdr, FAR Elf_Sym *sym)
{
FAR struct symtab_s *symbol;
- FAR Elf_Shdr *strTab = &loadinfo->shdr[shdr->sh_link];
+ FAR Elf_Shdr *strtab = &loadinfo->shdr[shdr->sh_link];
int ret = 0;
int i;
int j;
- int nSym;
- int symCount;
+ int nsym;
+ int symcount;
if (modp->modinfo.exports != NULL)
{
@@ -471,28 +478,28 @@ int modlib_insertsymtab(FAR struct module_s *modp,
/* Count the "live" symbols */
- nSym = shdr->sh_size / sizeof(Elf_Sym);
- for (i = 0, symCount = 0; i < nSym; i++)
+ nsym = shdr->sh_size / sizeof(Elf_Sym);
+ for (i = 0, symcount = 0; i < nsym; i++)
{
if (sym[i].st_name != 0)
- symCount++;
+ symcount++;
}
- if (symCount > 0)
+ if (symcount > 0)
{
modp->modinfo.exports = symbol =
loadinfo->exported =
- lib_malloc(sizeof(*symbol) * symCount);
+ lib_malloc(sizeof(*symbol) * symcount);
if (modp->modinfo.exports)
{
/* Build out module's symbol table */
- modp->modinfo.nexports = symCount;
- for (i = 0, j = 0; i < nSym; i++)
+ modp->modinfo.nexports = symcount;
+ for (i = 0, j = 0; i < nsym; i++)
{
if (sym[i].st_name != 0)
{
- ret = modlib_symname(loadinfo, &sym[i], strTab->sh_offset);
+ ret = modlib_symname(loadinfo, &sym[i], strtab->sh_offset);
if (ret < 0)
{
lib_free((FAR void *) modp->modinfo.exports);
@@ -517,7 +524,7 @@ int modlib_insertsymtab(FAR struct module_s *modp,
}
/****************************************************************************
- * Name: findEP
+ * Name: findep
*
* Description:
* Binary search comparison function
@@ -528,11 +535,11 @@ int modlib_insertsymtab(FAR struct module_s *modp,
*
****************************************************************************/
-static int findEP(const void *c1, const void *c2)
+static int findep(FAR const void *c1, FAR const void *c2)
{
- const struct epTable_s *m1 = (struct epTable_s *) c1;
- const struct epTable_s *m2 = (struct epTable_s *) c2;
- return strcmp((FAR const char *)m1->epName, (FAR const char *)m2->epName);
+ FAR const struct eptable_s *m1 = (FAR const struct eptable_s *)c1;
+ FAR const struct eptable_s *m2 = (FAR const struct eptable_s *)c2;
+ return strcmp((FAR const char *)m1->epname, (FAR const char *)m2->epname);
}
/****************************************************************************
@@ -547,26 +554,26 @@ static int findEP(const void *c1, const void *c2)
****************************************************************************/
void *modlib_findglobal(FAR struct module_s *modp,
- struct mod_loadinfo_s *loadinfo,
+ FAR struct mod_loadinfo_s *loadinfo,
FAR Elf_Shdr *shdr, FAR Elf_Sym *sym)
{
- FAR Elf_Shdr *strTab = &loadinfo->shdr[shdr->sh_link];
+ FAR Elf_Shdr *strtab = &loadinfo->shdr[shdr->sh_link];
int ret;
- struct epTable_s key;
- struct epTable_s *res;
- extern struct epTable_s globalTable[];
- extern int nGlobals;
+ struct eptable_s key;
+ FAR struct eptable_s *res;
- ret = modlib_symname(loadinfo, sym, strTab->sh_offset);
+ ret = modlib_symname(loadinfo, sym, strtab->sh_offset);
if (ret < 0)
+ {
return NULL;
+ }
- key.epName = loadinfo->iobuffer;
- res = bsearch(&key, globalTable, nGlobals,
- sizeof(struct epTable_s), findEP);
+ key.epname = loadinfo->iobuffer;
+ res = bsearch(&key, global_table, nglobals,
+ sizeof(struct eptable_s), findep);
if (res != NULL)
{
- return res->epAddr;
+ return res->epaddr;
}
else
{
[nuttx] 02/03: libc/symtab: Don't include symtab.h in the header files
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ebcb03dce9a952429fd3233cf02ecbc6c7ec38ef
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jul 9 05:23:32 2023 +0800
libc/symtab: Don't include symtab.h in the header files
to unify the inclusion of symtab.h only from the source files
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
binfmt/binfmt_execsymtab.c | 2 +-
include/nuttx/allsyms.h | 4 +---
include/nuttx/binfmt/elf.h | 18 ++++++++----------
include/nuttx/binfmt/symtab.h | 4 +---
include/nuttx/lib/modlib.h | 4 +---
libs/libc/dlfcn/lib_dlsym.c | 1 +
libs/libc/modlib/modlib_symbols.c | 1 +
libs/libc/modlib/modlib_symtab.c | 1 +
libs/libc/stdio/lib_libvsprintf.c | 1 +
libs/libc/symtab/symtab_allsyms.c | 1 +
sched/module/mod_modsym.c | 1 +
11 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/binfmt/binfmt_execsymtab.c b/binfmt/binfmt_execsymtab.c
index 2ecf4f29c2..ef810f7a1e 100644
--- a/binfmt/binfmt_execsymtab.c
+++ b/binfmt/binfmt_execsymtab.c
@@ -27,7 +27,7 @@
#include <assert.h>
#include <nuttx/irq.h>
-#include <nuttx/arch.h>
+#include <nuttx/symtab.h>
#include <nuttx/binfmt/symtab.h>
#ifdef CONFIG_LIBC_EXECFUNCS
diff --git a/include/nuttx/allsyms.h b/include/nuttx/allsyms.h
index 46272c04bc..e068d3eec2 100644
--- a/include/nuttx/allsyms.h
+++ b/include/nuttx/allsyms.h
@@ -25,9 +25,6 @@
* Included Files
****************************************************************************/
-#include <nuttx/compiler.h>
-#include <nuttx/symtab.h>
-
#include <stddef.h>
/****************************************************************************
@@ -55,6 +52,7 @@ extern "C"
*
****************************************************************************/
+struct symtab_s;
FAR const struct symtab_s *allsyms_findbyname(FAR const char *name,
FAR size_t *size);
diff --git a/include/nuttx/binfmt/elf.h b/include/nuttx/binfmt/elf.h
index 1484f2d47f..3f35f609c5 100644
--- a/include/nuttx/binfmt/elf.h
+++ b/include/nuttx/binfmt/elf.h
@@ -28,12 +28,10 @@
#include <nuttx/config.h>
#include <sys/types.h>
-
#include <stdint.h>
#include <stdbool.h>
#include <elf.h>
-#include <nuttx/arch.h>
#include <nuttx/binfmt/binfmt.h>
/****************************************************************************
@@ -92,15 +90,15 @@ struct elf_loadinfo_s
* after the ELF module has been loaded.
*/
- uintptr_t textalloc; /* .text memory allocated when ELF file was loaded */
- uintptr_t dataalloc; /* .bss/.data memory allocated when ELF file was loaded */
- size_t textsize; /* Size of the ELF .text memory allocation */
- size_t datasize; /* Size of the ELF .bss/.data memory allocation */
- size_t textalign; /* Necessary alignment of .text */
- size_t dataalign; /* Necessary alignment of .bss/.data */
- off_t filelen; /* Length of the entire ELF file */
+ uintptr_t textalloc; /* .text memory allocated when ELF file was loaded */
+ uintptr_t dataalloc; /* .bss/.data memory allocated when ELF file was loaded */
+ size_t textsize; /* Size of the ELF .text memory allocation */
+ size_t datasize; /* Size of the ELF .bss/.data memory allocation */
+ size_t textalign; /* Necessary alignment of .text */
+ size_t dataalign; /* Necessary alignment of .bss/.data */
+ off_t filelen; /* Length of the entire ELF file */
- Elf_Ehdr ehdr; /* Buffered ELF file header */
+ Elf_Ehdr ehdr; /* Buffered ELF file header */
FAR Elf_Shdr *shdr; /* Buffered ELF section headers */
uint8_t *iobuffer; /* File I/O buffer */
diff --git a/include/nuttx/binfmt/symtab.h b/include/nuttx/binfmt/symtab.h
index ef9f382352..9bbade8f1d 100644
--- a/include/nuttx/binfmt/symtab.h
+++ b/include/nuttx/binfmt/symtab.h
@@ -25,9 +25,6 @@
* Included Files
****************************************************************************/
-#include <nuttx/config.h>
-#include <nuttx/symtab.h>
-
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
@@ -58,6 +55,7 @@ extern "C"
*
****************************************************************************/
+struct symtab_s;
void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
/****************************************************************************
diff --git a/include/nuttx/lib/modlib.h b/include/nuttx/lib/modlib.h
index 505972d45e..e60e30d225 100644
--- a/include/nuttx/lib/modlib.h
+++ b/include/nuttx/lib/modlib.h
@@ -30,9 +30,6 @@
#include <sys/types.h>
#include <elf.h>
-#include <nuttx/arch.h>
-#include <nuttx/symtab.h>
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -117,6 +114,7 @@ typedef CODE int (*mod_uninitializer_t)(FAR void *arg);
* nexports - The number of symbols in the exported symbol table.
*/
+struct symtab_s;
struct mod_info_s
{
mod_uninitializer_t uninitializer; /* Module uninitializer */
diff --git a/libs/libc/dlfcn/lib_dlsym.c b/libs/libc/dlfcn/lib_dlsym.c
index ce116b180e..66fa6af077 100644
--- a/libs/libc/dlfcn/lib_dlsym.c
+++ b/libs/libc/dlfcn/lib_dlsym.c
@@ -29,6 +29,7 @@
#include <debug.h>
#include <errno.h>
+#include <nuttx/symtab.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
diff --git a/libs/libc/modlib/modlib_symbols.c b/libs/libc/modlib/modlib_symbols.c
index 21ddcd3d18..26784587bd 100644
--- a/libs/libc/modlib/modlib_symbols.c
+++ b/libs/libc/modlib/modlib_symbols.c
@@ -31,6 +31,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/symtab.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
diff --git a/libs/libc/modlib/modlib_symtab.c b/libs/libc/modlib/modlib_symtab.c
index af3292334a..203c4e5d9b 100644
--- a/libs/libc/modlib/modlib_symtab.c
+++ b/libs/libc/modlib/modlib_symtab.c
@@ -26,6 +26,7 @@
#include <assert.h>
+#include <nuttx/symtab.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c
index efef971194..a49fee0daa 100644
--- a/libs/libc/stdio/lib_libvsprintf.c
+++ b/libs/libc/stdio/lib_libvsprintf.c
@@ -51,6 +51,7 @@
#include <nuttx/compiler.h>
#include <nuttx/streams.h>
#include <nuttx/allsyms.h>
+#include <nuttx/symtab.h>
#include "lib_dtoa_engine.h"
#include "lib_ultoa_invert.h"
diff --git a/libs/libc/symtab/symtab_allsyms.c b/libs/libc/symtab/symtab_allsyms.c
index eb34ec1c80..436d0c5dbb 100644
--- a/libs/libc/symtab/symtab_allsyms.c
+++ b/libs/libc/symtab/symtab_allsyms.c
@@ -23,6 +23,7 @@
****************************************************************************/
#include <nuttx/allsyms.h>
+#include <nuttx/symtab.h>
/****************************************************************************
* Public Data
diff --git a/sched/module/mod_modsym.c b/sched/module/mod_modsym.c
index b694d557a1..31946a1b48 100644
--- a/sched/module/mod_modsym.c
+++ b/sched/module/mod_modsym.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <debug.h>
+#include <nuttx/symtab.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
[nuttx] 01/03: binfmt: Move [elf|nxflat]_[un]initialize to private header file
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 229293f9f8c0d27d67d142b2a9d3dc5212b8fc1f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Jul 9 04:39:31 2023 +0800
binfmt: Move [elf|nxflat]_[un]initialize to private header file
like what builtin binary format do
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
binfmt/Makefile | 12 ++++++++
binfmt/binfmt.h | 67 +++++++++++++++++++++++++++++++++++++++++--
binfmt/binfmt_initialize.c | 3 --
binfmt/libelf/Make.defs | 4 ---
binfmt/libnxflat/Make.defs | 4 ---
include/nuttx/binfmt/elf.h | 29 -------------------
include/nuttx/binfmt/nxflat.h | 30 -------------------
7 files changed, 76 insertions(+), 73 deletions(-)
diff --git a/binfmt/Makefile b/binfmt/Makefile
index 2050090dfb..9f8dbf8f05 100644
--- a/binfmt/Makefile
+++ b/binfmt/Makefile
@@ -41,6 +41,18 @@ ifeq ($(CONFIG_BUILTIN),y)
CSRCS += builtin.c
endif
+# ELF application interfaces
+
+ifeq ($(CONFIG_ELF),y)
+CSRCS += elf.c
+endif
+
+# NXFLAT application interfaces
+
+ifeq ($(CONFIG_NXFLAT),y)
+CSRCS += nxflat.c
+endif
+
# Add configured binary modules
include libnxflat/Make.defs
diff --git a/binfmt/binfmt.h b/binfmt/binfmt.h
index 647a34e455..a769ad93a5 100644
--- a/binfmt/binfmt.h
+++ b/binfmt/binfmt.h
@@ -165,6 +165,7 @@ void binfmt_freeargv(FAR char * const *argv);
# define binfmt_freeenv(envp)
#endif
+#ifdef CONFIG_BUILTIN
/****************************************************************************
* Name: builtin_initialize
*
@@ -179,9 +180,7 @@ void binfmt_freeargv(FAR char * const *argv);
*
****************************************************************************/
-#ifdef CONFIG_BUILTIN
int builtin_initialize(void);
-#endif
/****************************************************************************
* Name: builtin_uninitialize
@@ -194,10 +193,72 @@ int builtin_initialize(void);
*
****************************************************************************/
-#ifdef CONFIG_BUILTIN
void builtin_uninitialize(void);
#endif
+#ifdef CONFIG_ELF
+/****************************************************************************
+ * Name: elf_initialize
+ *
+ * Description:
+ * In order to use the ELF binary format, this function must be called
+ * during system initialization to register the ELF binary format.
+ *
+ * Returned Value:
+ * This is a NuttX internal function so it follows the convention that
+ * 0 (OK) is returned on success and a negated errno is returned on
+ * failure.
+ *
+ ****************************************************************************/
+
+int elf_initialize(void);
+
+/****************************************************************************
+ * Name: elf_uninitialize
+ *
+ * Description:
+ * Unregister the ELF binary loader
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void elf_uninitialize(void);
+#endif
+
+#ifdef CONFIG_NXFLAT
+/****************************************************************************
+ * Name: nxflat_initialize
+ *
+ * Description:
+ * In order to use the NxFLAT binary format, this function must be called
+ * during system initialization to register the NXFLAT binary
+ * format.
+ *
+ * Returned Value:
+ * This is a NuttX internal function so it follows the convention that
+ * 0 (OK) is returned on success and a negated errno is returned on
+ * failure.
+ *
+ ****************************************************************************/
+
+int nxflat_initialize(void);
+
+/****************************************************************************
+ * Name: nxflat_uninitialize
+ *
+ * Description:
+ * Unregister the NXFLAT binary loader
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void nxflat_uninitialize(void);
+#endif
+
#undef EXTERN
#if defined(__cplusplus)
}
diff --git a/binfmt/binfmt_initialize.c b/binfmt/binfmt_initialize.c
index dd1cbd10e8..0444fc9312 100644
--- a/binfmt/binfmt_initialize.c
+++ b/binfmt/binfmt_initialize.c
@@ -25,9 +25,6 @@
#include <nuttx/config.h>
#include <nuttx/binfmt/binfmt.h>
-#include <nuttx/binfmt/elf.h>
-#include <nuttx/binfmt/nxflat.h>
-#include <nuttx/lib/builtin.h>
#include <debug.h>
diff --git a/binfmt/libelf/Make.defs b/binfmt/libelf/Make.defs
index a32f93228e..0697ec1d5d 100644
--- a/binfmt/libelf/Make.defs
+++ b/binfmt/libelf/Make.defs
@@ -20,10 +20,6 @@
ifeq ($(CONFIG_ELF),y)
-# ELF application interfaces
-
-CSRCS += elf.c
-
# ELF library
CSRCS += libelf_bind.c libelf_init.c libelf_addrenv.c libelf_iobuffer.c
diff --git a/binfmt/libnxflat/Make.defs b/binfmt/libnxflat/Make.defs
index ffc1d53396..245b4dab36 100644
--- a/binfmt/libnxflat/Make.defs
+++ b/binfmt/libnxflat/Make.defs
@@ -20,10 +20,6 @@
ifeq ($(CONFIG_NXFLAT),y)
-# NXFLAT application interfaces
-
-CSRCS += nxflat.c
-
# NXFLAT library
CSRCS += libnxflat_init.c libnxflat_uninit.c libnxflat_addrenv.c
diff --git a/include/nuttx/binfmt/elf.h b/include/nuttx/binfmt/elf.h
index 2acca1c4e2..1484f2d47f 100644
--- a/include/nuttx/binfmt/elf.h
+++ b/include/nuttx/binfmt/elf.h
@@ -158,35 +158,6 @@ extern "C"
#define EXTERN extern
#endif
-/****************************************************************************
- * Name: elf_initialize
- *
- * Description:
- * In order to use the ELF binary format, this function must be called
- * during system initialization to register the ELF binary format.
- *
- * Returned Value:
- * This is a NuttX internal function so it follows the convention that
- * 0 (OK) is returned on success and a negated errno is returned on
- * failure.
- *
- ****************************************************************************/
-
-int elf_initialize(void);
-
-/****************************************************************************
- * Name: elf_uninitialize
- *
- * Description:
- * Unregister the ELF binary loader
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void elf_uninitialize(void);
-
/****************************************************************************
* Name: elf_init
*
diff --git a/include/nuttx/binfmt/nxflat.h b/include/nuttx/binfmt/nxflat.h
index 222fdadc33..e51a4f1ce1 100644
--- a/include/nuttx/binfmt/nxflat.h
+++ b/include/nuttx/binfmt/nxflat.h
@@ -112,36 +112,6 @@ extern "C"
#define EXTERN extern
#endif
-/****************************************************************************
- * Name: nxflat_initialize
- *
- * Description:
- * In order to use the NxFLAT binary format, this function must be called
- * during system initialization to register the NXFLAT binary
- * format.
- *
- * Returned Value:
- * This is a NuttX internal function so it follows the convention that
- * 0 (OK) is returned on success and a negated errno is returned on
- * failure.
- *
- ****************************************************************************/
-
-int nxflat_initialize(void);
-
-/****************************************************************************
- * Name: nxflat_uninitialize
- *
- * Description:
- * Unregister the NXFLAT binary loader
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void nxflat_uninitialize(void);
-
/****************************************************************************
* Name: nxflat_verifyheader
*