binfmt/, binfmt/libelf/, include/nuttx, libs/libc/machine, libs/libc/modlib, and others: Move elf related arch function to include/nuttx/elf.h because the implementation is located in libs/libc/machine and in order to avoid the conflict with the 3rd party libraries and clean up the file inclusion: (1) Remove redundant elf32.h, (2) Remove nuttx/binfmt/elf.h in libs/libc/machine, (2) Remove nuttx/binfmt/elf.h in modlib, and (4) Rmove nuttx/module.h in modlib.

This commit is contained in:
Xiang Xiao
2019-01-26 11:18:45 -06:00
committed by Gregory Nutt
parent 763ba51b78
commit 095e28d45e
37 changed files with 33 additions and 124 deletions
+2 -2
View File
@@ -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 <gnutt@nuttx.org>
@@ -60,7 +60,7 @@
* Name: exec_dtors
*
* Description:
* Execute C++ static constructors.
* Execute C++ static destructors.
*
* Input Parameters:
* binp - Load state information
+1 -1
View File
@@ -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
-3
View File
@@ -42,12 +42,9 @@
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/binfmt.h>
#include <nuttx/binfmt/elf.h>
+2 -3
View File
@@ -43,7 +43,6 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
@@ -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
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -41,11 +41,11 @@
#include <stdint.h>
#include <string.h>
#include <elf32.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/elf.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/binfmt/symtab.h>
@@ -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
-1
View File
@@ -44,7 +44,6 @@
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
+1 -1
View File
@@ -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 <gnutt@nuttx.org>
-1
View File
@@ -45,7 +45,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <elf32.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
-1
View File
@@ -43,7 +43,6 @@
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
+2 -3
View File
@@ -41,7 +41,6 @@
#include <stdlib.h>
#include <string.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
@@ -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);
+1
View File
@@ -43,6 +43,7 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/elf.h>
#include <nuttx/binfmt/elf.h>
/****************************************************************************
+4 -49
View File
@@ -105,10 +105,6 @@
#include <stdbool.h>
#include <sched.h>
#if defined(CONFIG_ELF) || defined(CONFIG_MODULE)
# include <elf32.h>
#endif
#include <arch/arch.h>
/****************************************************************************
@@ -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
-1
View File
@@ -43,7 +43,6 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <nxflat.h>
#include <nuttx/arch.h>
#include <nuttx/sched.h>
+2 -5
View File
@@ -46,7 +46,7 @@
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/module.h>
#include <nuttx/symtab.h>
/****************************************************************************
* 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
****************************************************************************/
+1 -3
View File
@@ -40,13 +40,11 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <arch/elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Pre-processor Definitions
+1 -3
View File
@@ -40,13 +40,11 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <arch/elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Pre-processor Definitions
+1 -3
View File
@@ -40,13 +40,11 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <arch/elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Public Functions
+1 -3
View File
@@ -40,13 +40,11 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <arch/elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Public Function Prototypes
+1 -3
View File
@@ -40,13 +40,11 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <arch/elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Pre-processor Definitions
+1 -3
View File
@@ -40,12 +40,10 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Pre-processor Definitions
+1 -3
View File
@@ -40,12 +40,10 @@
#include <nuttx/config.h>
#include <stdlib.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/elf.h>
/****************************************************************************
* Pre-processor Definitions
+2 -3
View File
@@ -43,10 +43,9 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
* 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
+1 -3
View File
@@ -41,14 +41,12 @@
#include <stdint.h>
#include <string.h>
#include <elf32.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/elf.h>
#include <nuttx/lib/modlib.h>
#include <nuttx/binfmt/symtab.h>
#include "modlib/modlib.h"
-1
View File
@@ -43,7 +43,6 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
-2
View File
@@ -44,11 +44,9 @@
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/module.h>
#include <nuttx/fs/fs.h>
#include <nuttx/lib/modlib.h>
-1
View File
@@ -42,7 +42,6 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
-2
View File
@@ -45,12 +45,10 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <elf32.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
-2
View File
@@ -43,11 +43,9 @@
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/module.h>
#include <nuttx/fs/fs.h>
#include <nuttx/lib/modlib.h>
+2 -3
View File
@@ -45,7 +45,6 @@
#include <errno.h>
#include <nuttx/semaphore.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
@@ -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.
*/
-1
View File
@@ -45,7 +45,6 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
+2 -5
View File
@@ -41,13 +41,10 @@
#include <stdlib.h>
#include <string.h>
#include <elf32.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include <nuttx/binfmt/symtab.h>
#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);
-1
View File
@@ -42,7 +42,6 @@
#include <assert.h>
#include <nuttx/symtab.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
-2
View File
@@ -43,8 +43,6 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
-1
View File
@@ -42,7 +42,6 @@
#include <stdlib.h>
#include <debug.h>
#include <nuttx/module.h>
#include <nuttx/lib/modlib.h>
#include "libc.h"
+1 -1
View File
@@ -40,11 +40,11 @@
#include <nuttx/config.h>
#include <string.h>
#include <elf32.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/elf.h>
#include <nuttx/lib/modlib.h>
/****************************************************************************
-1
View File
@@ -42,7 +42,6 @@
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <elf32.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>