diff --git a/binfmt/binfmt_unloadmodule.c b/binfmt/binfmt_unloadmodule.c index bf1711c36ce..360deedf144 100644 --- a/binfmt/binfmt_unloadmodule.c +++ b/binfmt/binfmt_unloadmodule.c @@ -1,5 +1,5 @@ /**************************************************************************** - * binfmt/binfmt_loadmodule.c + * binfmt/binfmt_unloadmodule.c * * Copyright (C) 2009, 2012-2013, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -60,7 +60,7 @@ * Name: exec_dtors * * Description: - * Execute C++ static constructors. + * Execute C++ static destructors. * * Input Parameters: * binp - Load state information diff --git a/binfmt/binfmt_unregister.c b/binfmt/binfmt_unregister.c index e0a6fe80e64..16cd1237b66 100644 --- a/binfmt/binfmt_unregister.c +++ b/binfmt/binfmt_unregister.c @@ -58,7 +58,7 @@ * Name: unregister_binfmt * * Description: - * Register a loader for a binary format + * Unregister a loader for a binary format * * Returned Value: * This is a NuttX internal function so it follows the convention that diff --git a/binfmt/elf.c b/binfmt/elf.c index 8b0b061627d..1a96bea0277 100644 --- a/binfmt/elf.c +++ b/binfmt/elf.c @@ -42,12 +42,9 @@ #include #include #include -#include #include #include -#include - #include #include #include diff --git a/binfmt/libelf/libelf.h b/binfmt/libelf/libelf.h index a61f38017a9..350b3c50079 100644 --- a/binfmt/libelf/libelf.h +++ b/binfmt/libelf/libelf.h @@ -43,7 +43,6 @@ #include #include -#include #include #include @@ -137,7 +136,7 @@ int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo); * Name: elf_readsym * * Description: - * Read the ELFT symbol structure at the specfied index into memory. + * Read the ELF symbol structure at the specfied index into memory. * * Input Parameters: * loadinfo - Load state information @@ -294,7 +293,7 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize, * Name: elf_addrenv_select * * Description: - * Temporarily select the task's address environemnt. + * Temporarily select the task's address environment. * * Input Parameters: * loadinfo - Load state information diff --git a/binfmt/libelf/libelf_addrenv.c b/binfmt/libelf/libelf_addrenv.c index 5e358f58e47..97114ddcf38 100644 --- a/binfmt/libelf/libelf_addrenv.c +++ b/binfmt/libelf/libelf_addrenv.c @@ -121,7 +121,7 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize, ret = up_addrenv_vdata(&loadinfo->addrenv, textsize, &vdata); if (ret < 0) { - berr("ERROR: up_adup_addrenv_vdatadrenv_vtext failed: %d\n", ret); + berr("ERROR: up_addrenv_vdata failed: %d\n", ret); return ret; } diff --git a/binfmt/libelf/libelf_bind.c b/binfmt/libelf/libelf_bind.c index 5239f0523c7..b9a6fc20b40 100644 --- a/binfmt/libelf/libelf_bind.c +++ b/binfmt/libelf/libelf_bind.c @@ -41,11 +41,11 @@ #include #include -#include #include #include #include +#include #include #include @@ -279,7 +279,7 @@ int elf_bind(FAR struct elf_loadinfo_s *loadinfo, if (ret < 0) { berr("elf_allocbuffer failed: %d\n", ret); - return -ENOMEM; + return ret; } #ifdef CONFIG_ARCH_ADDRENV diff --git a/binfmt/libelf/libelf_init.c b/binfmt/libelf/libelf_init.c index faaab96ab2c..97be242197f 100644 --- a/binfmt/libelf/libelf_init.c +++ b/binfmt/libelf/libelf_init.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include diff --git a/binfmt/libelf/libelf_iobuffer.c b/binfmt/libelf/libelf_iobuffer.c index 29abb492dee..2f2f418628c 100644 --- a/binfmt/libelf/libelf_iobuffer.c +++ b/binfmt/libelf/libelf_iobuffer.c @@ -1,5 +1,5 @@ /**************************************************************************** - * binfmt/libelf/elf_iobuffer.c + * binfmt/libelf/libelf_iobuffer.c * * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c index 5b589323f01..1ca4fc33a61 100644 --- a/binfmt/libelf/libelf_load.c +++ b/binfmt/libelf/libelf_load.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/binfmt/libelf/libelf_read.c b/binfmt/libelf/libelf_read.c index a240e107fbc..465dbeabaa4 100644 --- a/binfmt/libelf/libelf_read.c +++ b/binfmt/libelf/libelf_read.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/binfmt/libelf/libelf_symbols.c b/binfmt/libelf/libelf_symbols.c index b93bdfdb3a1..c4aef1d7546 100644 --- a/binfmt/libelf/libelf_symbols.c +++ b/binfmt/libelf/libelf_symbols.c @@ -41,7 +41,6 @@ #include #include -#include #include #include @@ -206,7 +205,7 @@ int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo) * Name: elf_readsym * * Description: - * Read the ELFT symbol structure at the specfied index into memory. + * Read the ELF symbol structure at the specified index into memory. * * Input Parameters: * loadinfo - Load state information @@ -322,7 +321,7 @@ int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym, /* Yes... add the exported symbol value to the ELF symbol table entry */ - binfo("SHN_ABS: name=%s %08x+%08x=%08x\n", + binfo("SHN_UNDEF: name=%s %08x+%08x=%08x\n", loadinfo->iobuffer, sym->st_value, symbol->sym_value, sym->st_value + symbol->sym_value); diff --git a/binfmt/libelf/libelf_verify.c b/binfmt/libelf/libelf_verify.c index 1db1e99371f..fe4723f2e3f 100644 --- a/binfmt/libelf/libelf_verify.c +++ b/binfmt/libelf/libelf_verify.c @@ -43,6 +43,7 @@ #include #include +#include #include /**************************************************************************** diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index ec9ea73dc28..4d15347cd35 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -105,10 +105,6 @@ #include #include -#if defined(CONFIG_ELF) || defined(CONFIG_MODULE) -# include -#endif - #include /**************************************************************************** @@ -1323,55 +1319,14 @@ int up_shmdt(uintptr_t vaddr, unsigned int npages); /**************************************************************************** * Interfaces required for ELF module support - ****************************************************************************/ -/**************************************************************************** - * Name: up_checkarch * - * Description: - * Given the ELF header in 'hdr', verify that the module is appropriate - * for the current, configured architecture. Every architecture that uses - * the module loader must provide this function. - * - * Input Parameters: - * hdr - The ELF header read from the module file. - * - * Returned Value: - * True if the architecture supports this module file. + * up_checkarch - Perform architecture-specific ELF check + * up_relocate - Perform architecture-specific ELF relocation + * up_relocateadd - Perform architecture-specific ELF relocation * ****************************************************************************/ -#if defined(CONFIG_ELF) || defined(CONFIG_MODULE) -bool up_checkarch(FAR const Elf32_Ehdr *hdr); -#endif - -/**************************************************************************** - * Name: up_relocate and up_relocateadd - * - * Description: - * Perform on architecture-specific ELF relocation. Every architecture - * that uses the module loader must provide this function. - * - * Input Parameters: - * rel - The relocation type - * sym - The ELF symbol structure containing the fully resolved value. - * There are a few relocation types for a few architectures that do - * not require symbol information. For those, this value will be - * NULL. Implementations of these functions must be able to handle - * that case. - * addr - The address that requires the relocation. - * - * Returned Value: - * Zero (OK) if the relocation was successful. Otherwise, a negated errno - * value indicating the cause of the relocation failure. - * - ****************************************************************************/ - -#if defined(CONFIG_ELF) || defined(CONFIG_MODULE) -int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym, - uintptr_t addr); -int up_relocateadd(FAR const Elf32_Rela *rel, - FAR const Elf32_Sym *sym, uintptr_t addr); -#endif +/* See prototype in include/nuttx/elf.h */ /**************************************************************************** * Name: up_coherent_dcache diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index 4be3b22b15a..5a6af0eaacb 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -43,7 +43,6 @@ #include #include -#include #include #include diff --git a/include/nuttx/lib/modlib.h b/include/nuttx/lib/modlib.h index e2c1feb0579..751f2a67a37 100644 --- a/include/nuttx/lib/modlib.h +++ b/include/nuttx/lib/modlib.h @@ -46,7 +46,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions @@ -136,7 +136,7 @@ struct mod_info_s mod_uninitializer_t uninitializer; /* Module uninitializer */ FAR void *arg; /* Uninitializer argument */ FAR const struct symtab_s *exports; /* Symbols exported by module */ - unsigned int nexports; /* Number of symobols in exports list */ + unsigned int nexports; /* Number of symbols in exports list */ }; /* A NuttX module is expected to export a function called module_initialize() @@ -161,7 +161,6 @@ typedef CODE int (*mod_callback_t)(FAR struct module_s *modp, FAR void *arg); /* This describes the file to be loaded. */ -struct symtab_s; struct module_s { FAR struct module_s *flink; /* Supports a singly linked list */ @@ -221,8 +220,6 @@ struct mod_loadinfo_s * Public Data ****************************************************************************/ -struct symtab_s; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/libs/libc/machine/arm/arm/arch_elf.c b/libs/libc/machine/arm/arm/arch_elf.c index 5dd1ebdfffe..7ac3ce31923 100644 --- a/libs/libc/machine/arm/arm/arch_elf.c +++ b/libs/libc/machine/arm/arm/arch_elf.c @@ -40,13 +40,11 @@ #include #include -#include #include #include #include -#include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/machine/arm/armv6-m/arch_elf.c b/libs/libc/machine/arm/armv6-m/arch_elf.c index 6adfe1578ab..2e9170eed84 100644 --- a/libs/libc/machine/arm/armv6-m/arch_elf.c +++ b/libs/libc/machine/arm/armv6-m/arch_elf.c @@ -40,13 +40,11 @@ #include #include -#include #include #include #include -#include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/machine/arm/armv7-a/arch_elf.c b/libs/libc/machine/arm/armv7-a/arch_elf.c index d93d2fa958f..a1ace2c5297 100644 --- a/libs/libc/machine/arm/armv7-a/arch_elf.c +++ b/libs/libc/machine/arm/armv7-a/arch_elf.c @@ -40,13 +40,11 @@ #include #include -#include #include #include #include -#include -#include +#include /**************************************************************************** * Public Functions diff --git a/libs/libc/machine/arm/armv7-m/arch_elf.c b/libs/libc/machine/arm/armv7-m/arch_elf.c index 61a909d92d0..b582189fca9 100644 --- a/libs/libc/machine/arm/armv7-m/arch_elf.c +++ b/libs/libc/machine/arm/armv7-m/arch_elf.c @@ -40,13 +40,11 @@ #include #include -#include #include #include #include -#include -#include +#include /**************************************************************************** * Public Function Prototypes diff --git a/libs/libc/machine/arm/armv7-r/arch_elf.c b/libs/libc/machine/arm/armv7-r/arch_elf.c index c04094c1475..efee7e96fa9 100644 --- a/libs/libc/machine/arm/armv7-r/arch_elf.c +++ b/libs/libc/machine/arm/armv7-r/arch_elf.c @@ -40,13 +40,11 @@ #include #include -#include #include #include #include -#include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/machine/sim/arch_elf.c b/libs/libc/machine/sim/arch_elf.c index 30bcd53788c..9404de3cc3d 100644 --- a/libs/libc/machine/sim/arch_elf.c +++ b/libs/libc/machine/sim/arch_elf.c @@ -40,12 +40,10 @@ #include #include -#include #include #include -#include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/machine/x86/arch_elf.c b/libs/libc/machine/x86/arch_elf.c index ca815451fd4..af167ad0c84 100644 --- a/libs/libc/machine/x86/arch_elf.c +++ b/libs/libc/machine/x86/arch_elf.c @@ -40,12 +40,10 @@ #include #include -#include #include #include -#include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/modlib/modlib.h b/libs/libc/modlib/modlib.h index cc0dda26668..1c4fb9ac93e 100644 --- a/libs/libc/modlib/modlib.h +++ b/libs/libc/modlib/modlib.h @@ -43,10 +43,9 @@ #include #include -#include #include -#include +#include /**************************************************************************** * Public Function Prototypes @@ -85,7 +84,7 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo); * Name: modlib_readsym * * Description: - * Read the ELFT symbol structure at the specfied index into memory. + * Read the ELF symbol structure at the specified index into memory. * * Input Parameters: * loadinfo - Load state information diff --git a/libs/libc/modlib/modlib_bind.c b/libs/libc/modlib/modlib_bind.c index 091e1941f83..606cf6b283b 100644 --- a/libs/libc/modlib/modlib_bind.c +++ b/libs/libc/modlib/modlib_bind.c @@ -41,14 +41,12 @@ #include #include -#include #include #include #include -#include +#include #include -#include #include "modlib/modlib.h" diff --git a/libs/libc/modlib/modlib_depend.c b/libs/libc/modlib/modlib_depend.c index 93709b62eac..ef00371937d 100644 --- a/libs/libc/modlib/modlib_depend.c +++ b/libs/libc/modlib/modlib_depend.c @@ -43,7 +43,6 @@ #include #include -#include #include /**************************************************************************** diff --git a/libs/libc/modlib/modlib_init.c b/libs/libc/modlib/modlib_init.c index 691efd0f0e3..fdf87712b4e 100644 --- a/libs/libc/modlib/modlib_init.c +++ b/libs/libc/modlib/modlib_init.c @@ -44,11 +44,9 @@ #include #include #include -#include #include #include -#include #include #include diff --git a/libs/libc/modlib/modlib_iobuffer.c b/libs/libc/modlib/modlib_iobuffer.c index b5a0e27c1fd..bbadcc992e1 100644 --- a/libs/libc/modlib/modlib_iobuffer.c +++ b/libs/libc/modlib/modlib_iobuffer.c @@ -42,7 +42,6 @@ #include #include -#include #include #include "libc.h" diff --git a/libs/libc/modlib/modlib_load.c b/libs/libc/modlib/modlib_load.c index d55a51da7fc..658ef1c2b3e 100644 --- a/libs/libc/modlib/modlib_load.c +++ b/libs/libc/modlib/modlib_load.c @@ -45,12 +45,10 @@ #include #include #include -#include #include #include #include -#include #include #include "libc.h" diff --git a/libs/libc/modlib/modlib_read.c b/libs/libc/modlib/modlib_read.c index f29d4f8afe8..224f897ba10 100644 --- a/libs/libc/modlib/modlib_read.c +++ b/libs/libc/modlib/modlib_read.c @@ -43,11 +43,9 @@ #include #include #include -#include #include #include -#include #include #include diff --git a/libs/libc/modlib/modlib_registry.c b/libs/libc/modlib/modlib_registry.c index 0521ea1fc4c..2b1712fa5ec 100644 --- a/libs/libc/modlib/modlib_registry.c +++ b/libs/libc/modlib/modlib_registry.c @@ -45,7 +45,6 @@ #include #include -#include #include /**************************************************************************** @@ -72,7 +71,7 @@ struct mod_registrylock_s static struct mod_registrylock_s g_modlock = { SEM_INITIALIZER(1), /* lock */ - 0, /* pid */ + NO_HOLDER, /* pid */ 0 /* count */ }; @@ -118,7 +117,7 @@ void modlib_registry_lock(void) { while ((ret = _SEM_WAIT(&g_modlock.lock)) < 0) { - /* The only case that an error should occr here is if + /* The only case that an error should occur here is if * the wait was awakened by a signal. */ diff --git a/libs/libc/modlib/modlib_sections.c b/libs/libc/modlib/modlib_sections.c index 9ae75bcd0d9..3b55882fce8 100644 --- a/libs/libc/modlib/modlib_sections.c +++ b/libs/libc/modlib/modlib_sections.c @@ -45,7 +45,6 @@ #include #include -#include #include #include "libc.h" diff --git a/libs/libc/modlib/modlib_symbols.c b/libs/libc/modlib/modlib_symbols.c index 8ef575e2125..12c0442bb08 100644 --- a/libs/libc/modlib/modlib_symbols.c +++ b/libs/libc/modlib/modlib_symbols.c @@ -41,13 +41,10 @@ #include #include -#include #include #include -#include #include -#include #include "modlib/modlib.h" @@ -271,7 +268,7 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo) * Name: modlib_readsym * * Description: - * Read the ELFT symbol structure at the specfied index into memory. + * Read the ELF symbol structure at the specified index into memory. * * Input Parameters: * loadinfo - Load state information @@ -421,7 +418,7 @@ int modlib_symvalue(FAR struct module_s *modp, /* Yes... add the exported symbol value to the ELF symbol table entry */ - binfo("SHN_ABS: name=%s %08x+%08x=%08x\n", + binfo("SHN_UNDEF: name=%s %08x+%08x=%08x\n", loadinfo->iobuffer, sym->st_value, symbol->sym_value, sym->st_value + symbol->sym_value); diff --git a/libs/libc/modlib/modlib_symtab.c b/libs/libc/modlib/modlib_symtab.c index f69c0a2895c..400afd78d73 100644 --- a/libs/libc/modlib/modlib_symtab.c +++ b/libs/libc/modlib/modlib_symtab.c @@ -42,7 +42,6 @@ #include #include -#include #include /**************************************************************************** diff --git a/libs/libc/modlib/modlib_uninit.c b/libs/libc/modlib/modlib_uninit.c index 16ae20183b1..48b9574de11 100644 --- a/libs/libc/modlib/modlib_uninit.c +++ b/libs/libc/modlib/modlib_uninit.c @@ -43,8 +43,6 @@ #include #include -#include -#include #include #include "libc.h" diff --git a/libs/libc/modlib/modlib_unload.c b/libs/libc/modlib/modlib_unload.c index 4bf9351a384..6288971ae41 100644 --- a/libs/libc/modlib/modlib_unload.c +++ b/libs/libc/modlib/modlib_unload.c @@ -42,7 +42,6 @@ #include #include -#include #include #include "libc.h" diff --git a/libs/libc/modlib/modlib_verify.c b/libs/libc/modlib/modlib_verify.c index f01f55b9783..12040db8c03 100644 --- a/libs/libc/modlib/modlib_verify.c +++ b/libs/libc/modlib/modlib_verify.c @@ -40,11 +40,11 @@ #include #include -#include #include #include #include +#include #include /**************************************************************************** diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c index 4b4b5dba982..d4e8826e248 100644 --- a/sched/module/mod_insmod.c +++ b/sched/module/mod_insmod.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include