Move module support from binfmt/ to sched/ so that it can be configured and built independently from binfmt features

This commit is contained in:
Gregory Nutt 2015-12-12 07:09:17 -06:00
parent 44e45f0f91
commit 49554fe4fc
22 changed files with 393 additions and 574 deletions

View file

@ -12,16 +12,6 @@ config BINFMT_DISABLE
if !BINFMT_DISABLE
config MODULE
bool "Enable loadable OS modules"
default n
---help---
Enable support for loadable OS modules. Default: n
if MODULE
source binfmt/libmodule/Kconfig
endif
config BINFMT_EXEPATH
bool "Support PATH variable"
default n

View file

@ -71,7 +71,6 @@ VPATH =
SUBDIRS =
DEPPATH = --dep-path .
include libmodule$(DELIM)Make.defs
include libnxflat$(DELIM)Make.defs
include libelf$(DELIM)Make.defs
include libbuiltin$(DELIM)Make.defs

View file

@ -1,35 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config MODULE_ALIGN_LOG2
int "Log2 Section Alignment"
default 2
---help---
Align all sections to this Log2 value: 0->1, 1->2, 2->4, etc.
config MODULE_BUFFERSIZE
int "Module I/O Buffer Size"
default 128
---help---
This is an I/O buffer that is used to access the module file.
Variable length items will need to be read (such as symbol names).
This is really just this initial size of the buffer; it will be
reallocated as necessary to hold large symbol names). Default: 128
config MODULE_BUFFERINCR
int "Module I/O Buffer Realloc Increment"
default 32
---help---
This is an I/O buffer that is used to access the module file.
Variable length items will need to be read (such as symbol names).
This value specifies the size increment to use each time the
buffer is reallocated. Default: 32
config MODULE_DUMPBUFFER
bool "Dump module buffers"
default n
depends on DEBUG && DEBUG_VERBOSE
---help---
Dump various module buffers for debug purposes

View file

@ -106,6 +106,10 @@
#include <stdbool.h>
#include <sched.h>
#if defined(CONFIG_ELF) || defined(CONFIG_MODULE)
# include <elf32.h>
#endif
#include <arch/arch.h>
/****************************************************************************
@ -1251,6 +1255,80 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr);
int up_shmdt(uintptr_t vaddr, unsigned int npages);
#endif
/****************************************************************************
* 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.
*
****************************************************************************/
#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
/****************************************************************************
* Name: up_coherent_dcache
*
* Description:
* Ensure that the I and D caches are coherent within specified region
* by cleaning the D cache (i.e., flushing the D cache contents to memory
* and invalidating the I cache. This is typically used when code has been
* written to a memory region, and will be executed.
*
* Input Parameters:
* addr - virtual start address of region
* len - Size of the address region in bytes
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_ARCH_HAVE_COHERENT_DCACHE
void up_coherent_dcache(uintptr_t addr, size_t len);
#endif
/****************************************************************************
* Name: up_interrupt_context
*

View file

@ -48,6 +48,7 @@
#include <stdbool.h>
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/binfmt.h>
/****************************************************************************
@ -271,97 +272,6 @@ int elf_initialize(void);
void elf_uninitialize(void);
/****************************************************************************
* These are APIs must be provided by architecture-specific logic.
* (These really belong in include/nuttx/arch.h):
****************************************************************************/
/****************************************************************************
* Name: up_checkarch
*
* Description:
* Given the ELF header in 'hdr', verify that the ELF file is appropriate
* for the current, configured architecture. Every architecture that uses
* the ELF loader must provide this function.
*
* Input Parameters:
* hdr - The ELF header read from the ELF file.
*
* Returned Value:
* True if the architecture supports this ELF file.
*
****************************************************************************/
bool up_checkarch(FAR const Elf32_Ehdr *hdr);
/****************************************************************************
* Name: up_relocate and up_relocateadd
*
* Description:
* Perform on architecture-specific ELF relocation. Every architecture
* that uses the ELF 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.
*
****************************************************************************/
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);
#ifdef CONFIG_UCLIBCXX_EXCEPTION
/****************************************************************************
* Name: up_init_exidx
*
* Description:
* Load the boundaries of the Exception Index ELF section in order to
* support exception handling for loaded ELF modules.
*
* Input Parameters:
* address - The ELF section address for the Exception Index
* size - The size of the ELF section.
*
* Returned Value:
* Always returns Zero (OK).
*
****************************************************************************/
int up_init_exidx(Elf32_Addr address, Elf32_Word size);
#endif
/****************************************************************************
* Name: up_coherent_dcache
*
* Description:
* Ensure that the I and D caches are coherent within specified region
* by cleaning the D cache (i.e., flushing the D cache contents to memory
* and invalidating the I cache. This is typically used when code has been
* written to a memory region, and will be executed.
*
* Input Parameters:
* addr - virtual start address of region
* len - Size of the address region in bytes
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_ARCH_HAVE_COHERENT_DCACHE
void up_coherent_dcache(uintptr_t addr, size_t len);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

View file

@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/binfmt/module.h
* include/nuttx/module.h
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_BINFMT_MODULE_H
#define __INCLUDE_NUTTX_BINFMT_MODULE_H
#ifndef __INCLUDE_NUTTX_MODULE_H
#define __INCLUDE_NUTTX_MODULE_H
/****************************************************************************
* Included Files
@ -48,6 +48,7 @@
#include <stdbool.h>
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/binfmt.h>
/****************************************************************************
@ -71,17 +72,6 @@
# define CONFIG_MODULE_BUFFERINCR 32
#endif
/* Allocation array size and indices */
#define LIBMODULE_MODULE_ALLOC 0
#ifdef CONFIG_BINFMT_CONSTRUCTORS
# define LIBMODULE_CTORS_ALLOC 1
# define LIBMODULE_CTPRS_ALLOC 2
# define LIBMODULE_NALLOC 3
#else
# define LIBMODULE_NALLOC 1
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@ -106,21 +96,14 @@
typedef CODE int (*mod_initializer_t)(void);
/* This describes the file to be loaded.
*
* NOTE 1: The 'filename' must be the full, absolute path to the file to be
* executed unless CONFIG_BINFMT_EXEPATH is defined. In that case,
* 'filename' may be a relative path; a set of candidate absolute paths
* will be generated using the PATH environment variable and load_module()
* will attempt to load each file that is found at those absolute paths.
*/
/* This describes the file to be loaded. */
struct symtab_s;
struct module_s
{
/* Information provided to insmod by the caller */
FAR const char *filename; /* Full path to the binary to be loaded (See NOTE 1 above) */
FAR const char *filename; /* Full path to the binary to be loaded */
FAR const struct symtab_s *exports; /* Table of exported symbols */
int nexports; /* The number of symbols in exports[] */
@ -156,80 +139,9 @@ extern "C"
int insmod(FAR struct module_s *modp);
/****************************************************************************
* These are APIs must be provided by architecture-specific logic.
* (These really belong in include/nuttx/arch.h):
****************************************************************************/
/****************************************************************************
* 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.
*
****************************************************************************/
bool up_checkarch(FAR const Elf32_Ehdr *hdr);
/****************************************************************************
* 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.
*
****************************************************************************/
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);
/****************************************************************************
* Name: up_coherent_dcache
*
* Description:
* Ensure that the I and D caches are coherent within specified region
* by cleaning the D cache (i.e., flushing the D cache contents to memory
* and invalidating the I cache. This is typically used when code has been
* written to a memory region, and will be executed.
*
* Input Parameters:
* addr - virtual start address of region
* len - Size of the address region in bytes
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_ARCH_HAVE_COHERENT_DCACHE
void up_coherent_dcache(uintptr_t addr, size_t len);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_BINFMT_MODULE_H */
#endif /* __INCLUDE_NUTTX_MODULE_H */

View file

@ -852,7 +852,48 @@ config MQ_MAXMSGSIZE
endmenu # POSIX Message Queue Options
menu "Work Queue Support"
menuconfig MODULE
bool "Enable loadable OS modules"
default n
---help---
Enable support for loadable OS modules. Default: n
if MODULE
config MODULE_ALIGN_LOG2
int "Log2 Section Alignment"
default 2
---help---
Align all sections to this Log2 value: 0->1, 1->2, 2->4, etc.
config MODULE_BUFFERSIZE
int "Module I/O Buffer Size"
default 128
---help---
This is an I/O buffer that is used to access the module file.
Variable length items will need to be read (such as symbol names).
This is really just this initial size of the buffer; it will be
reallocated as necessary to hold large symbol names). Default: 128
config MODULE_BUFFERINCR
int "Module I/O Buffer Realloc Increment"
default 32
---help---
This is an I/O buffer that is used to access the module file.
Variable length items will need to be read (such as symbol names).
This value specifies the size increment to use each time the
buffer is reallocated. Default: 32
config MODULE_DUMPBUFFER
bool "Dump module buffers"
default n
depends on DEBUG && DEBUG_VERBOSE
---help---
Dump various module buffers for debug purposes
endif
menu "Work queue support"
config SCHED_WORKQUEUE
# bool "Enable worker thread"

View file

@ -56,6 +56,7 @@ include mqueue/Make.defs
include clock/Make.defs
include timer/Make.defs
include environ/Make.defs
include module/Make.defs
include wqueue/Make.defs
AOBJS = $(ASRCS:.S=$(OBJEXT))

View file

@ -1,7 +1,7 @@
############################################################################
# binfmt/libmodule/Make.defs
# sched/module/Make.defs
#
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -37,19 +37,18 @@ ifeq ($(CONFIG_MODULE),y)
# OS module interfaces
BINFMT_CSRCS += insmod.c
CSRCS += mod_insmod.c
# loadable module library
BINFMT_CSRCS += libmodule_bind.c libmodule_init.c libmodule_iobuffer.c
BINFMT_CSRCS += libmodule_load.c libmodule_read.c libmodule_sections.c
BINFMT_CSRCS += libmodule_symbols.c libmodule_uninit.c libmodule_unload.c
BINFMT_CSRCS += libmodule_verify.c
CSRCS += mod_bind.c mod_init.c mod_iobuffer.c mod_load.c mod_read.c
CSRCS += mod_sections.c mod_symbols.c mod_uninit.c mod_unload.c
CSRCS += mod_verify.c
# Hook the libmodule subdirectory into the build
# Hook the module subdirectory into the build
VPATH += libmodule
SUBDIRS += libmodule
DEPPATH += --dep-path libmodule
VPATH += module
SUBDIRS += module
DEPPATH += --dep-path module
endif

View file

@ -1,5 +1,5 @@
/****************************************************************************
* binfmt/libmodule/gnu-elf.ld
* sched/module/gnu-elf.ld
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_bind.c
* sched/module/mod_bind.c
*
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -46,20 +46,20 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include <nuttx/binfmt/symtab.h>
#include "libmodule.h"
#include "module.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be
* defined or CONFIG_MODULE_DUMPBUFFER does nothing.
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_MODULE_DUMPBUFFER have to
* be defined or CONFIG_MODULE_DUMPBUFFER does nothing.
*/
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_MODULE_DUMPBUFFER)
# undef CONFIG_MODULE_DUMPBUFFER
#endif
@ -68,34 +68,26 @@
#endif
#ifdef CONFIG_MODULE_DUMPBUFFER
# define libmod_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
# define mod_dumpbuffer(m,b,n) svdbgdumpbuffer(m,b,n)
#else
# define libmod_dumpbuffer(m,b,n)
# define mod_dumpbuffer(m,b,n)
#endif
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_readrel
* Name: mod_readrel
*
* Description:
* Read the ELF32_Rel structure into memory.
*
****************************************************************************/
static inline int libmod_readrel(FAR struct libmod_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *relsec,
int index, FAR Elf32_Rel *rel)
static inline int mod_readrel(FAR struct mod_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *relsec,
int index, FAR Elf32_Rel *rel)
{
off_t offset;
@ -103,7 +95,7 @@ static inline int libmod_readrel(FAR struct libmod_loadinfo_s *loadinfo,
if (index < 0 || index > (relsec->sh_size / sizeof(Elf32_Rel)))
{
bdbg("Bad relocation symbol index: %d\n", index);
sdbg("Bad relocation symbol index: %d\n", index);
return -EINVAL;
}
@ -113,11 +105,11 @@ static inline int libmod_readrel(FAR struct libmod_loadinfo_s *loadinfo,
/* And, finally, read the symbol table entry into memory */
return libmod_read(loadinfo, (FAR uint8_t *)rel, sizeof(Elf32_Rel), offset);
return mod_read(loadinfo, (FAR uint8_t *)rel, sizeof(Elf32_Rel), offset);
}
/****************************************************************************
* Name: libmod_relocate and libmod_relocateadd
* Name: mod_relocate and mod_relocateadd
*
* Description:
* Perform all relocations associated with a section.
@ -128,8 +120,8 @@ static inline int libmod_readrel(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
FAR const struct symtab_s *exports, int nexports)
static int mod_relocate(FAR struct mod_loadinfo_s *loadinfo, int relidx,
FAR const struct symtab_s *exports, int nexports)
{
FAR Elf32_Shdr *relsec = &loadinfo->shdr[relidx];
@ -153,10 +145,10 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
/* Read the relocation entry into memory */
ret = libmod_readrel(loadinfo, relsec, i, &rel);
ret = mod_readrel(loadinfo, relsec, i, &rel);
if (ret < 0)
{
bdbg("Section %d reloc %d: Failed to read relocation entry: %d\n",
sdbg("Section %d reloc %d: Failed to read relocation entry: %d\n",
relidx, i, ret);
return ret;
}
@ -169,17 +161,17 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
/* Read the symbol table entry into memory */
ret = libmod_readsym(loadinfo, symidx, &sym);
ret = mod_readsym(loadinfo, symidx, &sym);
if (ret < 0)
{
bdbg("Section %d reloc %d: Failed to read symbol[%d]: %d\n",
sdbg("Section %d reloc %d: Failed to read symbol[%d]: %d\n",
relidx, i, symidx, ret);
return ret;
}
/* Get the value of the symbol (in sym.st_value) */
ret = libmod_symvalue(loadinfo, &sym, exports, nexports);
ret = mod_symvalue(loadinfo, &sym, exports, nexports);
if (ret < 0)
{
/* The special error -ESRCH is returned only in one condition: The
@ -194,13 +186,13 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
if (ret == -ESRCH)
{
bdbg("Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
sdbg("Section %d reloc %d: Undefined symbol[%d] has no name: %d\n",
relidx, i, symidx, ret);
psym = NULL;
}
else
{
bdbg("Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
sdbg("Section %d reloc %d: Failed to get value of symbol[%d]: %d\n",
relidx, i, symidx, ret);
return ret;
}
@ -210,7 +202,7 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
if (rel.r_offset < 0 || rel.r_offset > dstsec->sh_size - sizeof(uint32_t))
{
bdbg("Section %d reloc %d: Relocation address out of range, offset %d size %d\n",
sdbg("Section %d reloc %d: Relocation address out of range, offset %d size %d\n",
relidx, i, rel.r_offset, dstsec->sh_size);
return -EINVAL;
}
@ -222,7 +214,7 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
ret = up_relocate(&rel, psym, addr);
if (ret < 0)
{
bdbg("ERROR: Section %d reloc %d: Relocation failed: %d\n", relidx, i, ret);
sdbg("ERROR: Section %d reloc %d: Relocation failed: %d\n", relidx, i, ret);
return ret;
}
}
@ -230,10 +222,10 @@ static int libmod_relocate(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
return OK;
}
static int libmod_relocateadd(FAR struct libmod_loadinfo_s *loadinfo, int relidx,
static int mod_relocateadd(FAR struct mod_loadinfo_s *loadinfo, int relidx,
FAR const struct symtab_s *exports, int nexports)
{
bdbg("Not implemented\n");
sdbg("Not implemented\n");
return -ENOSYS;
}
@ -242,7 +234,7 @@ static int libmod_relocateadd(FAR struct libmod_loadinfo_s *loadinfo, int relidx
****************************************************************************/
/****************************************************************************
* Name: libmod_bind
* Name: mod_bind
*
* Description:
* Bind the imported symbol names in the loaded module described by
@ -254,28 +246,28 @@ static int libmod_relocateadd(FAR struct libmod_loadinfo_s *loadinfo, int relidx
*
****************************************************************************/
int libmod_bind(FAR struct libmod_loadinfo_s *loadinfo,
FAR const struct symtab_s *exports, int nexports)
int mod_bind(FAR struct mod_loadinfo_s *loadinfo,
FAR const struct symtab_s *exports, int nexports)
{
int ret;
int i;
/* Find the symbol and string tables */
ret = libmod_findsymtab(loadinfo);
ret = mod_findsymtab(loadinfo);
if (ret < 0)
{
return ret;
}
/* Allocate an I/O buffer. This buffer is used by libmod_symname() to
/* Allocate an I/O buffer. This buffer is used by mod_symname() to
* accumulate the variable length symbol name.
*/
ret = libmod_allocbuffer(loadinfo);
ret = mod_allocbuffer(loadinfo);
if (ret < 0)
{
bdbg("libmod_allocbuffer failed: %d\n", ret);
sdbg("mod_allocbuffer failed: %d\n", ret);
return -ENOMEM;
}
@ -304,11 +296,11 @@ int libmod_bind(FAR struct libmod_loadinfo_s *loadinfo,
if (loadinfo->shdr[i].sh_type == SHT_REL)
{
ret = libmod_relocate(loadinfo, i, exports, nexports);
ret = mod_relocate(loadinfo, i, exports, nexports);
}
else if (loadinfo->shdr[i].sh_type == SHT_RELA)
{
ret = libmod_relocateadd(loadinfo, i, exports, nexports);
ret = mod_relocateadd(loadinfo, i, exports, nexports);
}
if (ret < 0)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_init.c
* sched/module/mod_init.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -48,26 +48,26 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
#include "module.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_BINFMT have to be
* defined or CONFIG_MODULE_DUMPBUFFER does nothing.
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_MODULE_DUMPBUFFER have to
* be defined or CONFIG_MODULE_DUMPBUFFER does nothing.
*/
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_DEBUG_BINFMT)
#if !defined(CONFIG_DEBUG_VERBOSE) || !defined (CONFIG_MODULE_DUMPBUFFER)
# undef CONFIG_MODULE_DUMPBUFFER
#endif
#ifdef CONFIG_MODULE_DUMPBUFFER
# define libmod_dumpbuffer(m,b,n) bvdbgdumpbuffer(m,b,n)
# define mod_dumpbuffer(m,b,n) svdbgdumpbuffer(m,b,n)
#else
# define libmod_dumpbuffer(m,b,n)
# define mod_dumpbuffer(m,b,n)
#endif
/****************************************************************************
@ -79,7 +79,7 @@
****************************************************************************/
/****************************************************************************
* Name: libmod_filelen
* Name: mod_filelen
*
* Description:
* Get the size of the ELF file
@ -90,8 +90,8 @@
*
****************************************************************************/
static inline int libmod_filelen(FAR struct libmod_loadinfo_s *loadinfo,
FAR const char *filename)
static inline int mod_filelen(FAR struct mod_loadinfo_s *loadinfo,
FAR const char *filename)
{
struct stat buf;
int ret;
@ -102,7 +102,7 @@ static inline int libmod_filelen(FAR struct libmod_loadinfo_s *loadinfo,
if (ret < 0)
{
int errval = errno;
bdbg("Failed to stat file: %d\n", errval);
sdbg("Failed to stat file: %d\n", errval);
return -errval;
}
@ -110,7 +110,7 @@ static inline int libmod_filelen(FAR struct libmod_loadinfo_s *loadinfo,
if (!S_ISREG(buf.st_mode))
{
bdbg("Not a regular file. mode: %d\n", buf.st_mode);
sdbg("Not a regular file. mode: %d\n", buf.st_mode);
return -ENOENT;
}
@ -129,7 +129,7 @@ static inline int libmod_filelen(FAR struct libmod_loadinfo_s *loadinfo,
****************************************************************************/
/****************************************************************************
* Name: libmod_initialize
* Name: mod_initialize
*
* Description:
* This function is called to configure the library to process an ELF
@ -141,23 +141,23 @@ static inline int libmod_filelen(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
int libmod_initialize(FAR const char *filename,
FAR struct libmod_loadinfo_s *loadinfo)
int mod_initialize(FAR const char *filename,
FAR struct mod_loadinfo_s *loadinfo)
{
int ret;
bvdbg("filename: %s loadinfo: %p\n", filename, loadinfo);
svdbg("filename: %s loadinfo: %p\n", filename, loadinfo);
/* Clear the load info structure */
memset(loadinfo, 0, sizeof(struct libmod_loadinfo_s));
memset(loadinfo, 0, sizeof(struct mod_loadinfo_s));
/* Get the length of the file. */
ret = libmod_filelen(loadinfo, filename);
ret = mod_filelen(loadinfo, filename);
if (ret < 0)
{
bdbg("libmod_filelen failed: %d\n", ret);
sdbg("mod_filelen failed: %d\n", ret);
return ret;
}
@ -167,39 +167,38 @@ int libmod_initialize(FAR const char *filename,
if (loadinfo->filfd < 0)
{
int errval = errno;
bdbg("Failed to open ELF binary %s: %d\n", filename, errval);
sdbg("Failed to open ELF binary %s: %d\n", filename, errval);
return -errval;
}
/* Read the ELF ehdr from offset 0 */
ret = libmod_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
ret = mod_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr), 0);
if (ret < 0)
{
bdbg("Failed to read ELF header: %d\n", ret);
sdbg("Failed to read ELF header: %d\n", ret);
return ret;
}
libmod_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
mod_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr));
/* Verify the ELF header */
ret = libmod_verifyheader(&loadinfo->ehdr);
ret = mod_verifyheader(&loadinfo->ehdr);
if (ret < 0)
{
/* This may not be an error because we will be called to attempt loading
* EVERY binary. If libmod_verifyheader() does not recognize the ELF header,
* EVERY binary. If mod_verifyheader() does not recognize the ELF header,
* it will -ENOEXEC whcih simply informs the system that the file is not an
* ELF file. libmod_verifyheader() will return other errors if the ELF header
* ELF file. mod_verifyheader() will return other errors if the ELF header
* is not correctly formed.
*/
bdbg("Bad ELF header: %d\n", ret);
sdbg("Bad ELF header: %d\n", ret);
return ret;
}
return OK;
}

View file

@ -1,5 +1,5 @@
/****************************************************************************
* binfmt/module.c
* sched/module/module.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -49,9 +49,9 @@
#include <arpa/inet.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule/libmodule.h"
#include "module/module.h"
#ifdef CONFIG_MODULE
@ -86,7 +86,7 @@
****************************************************************************/
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_BINFMT)
static void mod_dumploadinfo(FAR struct libmod_loadinfo_s *loadinfo)
static void mod_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
{
int i;
@ -171,14 +171,14 @@ static void mod_dumpinitializer(mod_initializer_t initializer,
int insmod(FAR struct module_s *modp)
{
struct libmod_loadinfo_s loadinfo; /* Contains globals for libmodule */
struct mod_loadinfo_s loadinfo;
int ret;
bvdbg("Loading file: %s\n", modp->filename);
/* Initialize the ELF library to load the program binary. */
ret = libmod_initialize(modp->filename, &loadinfo);
ret = mod_initialize(modp->filename, &loadinfo);
mod_dumploadinfo(&loadinfo);
if (ret != 0)
{
@ -188,7 +188,7 @@ int insmod(FAR struct module_s *modp)
/* Load the program binary */
ret = libmod_load(&loadinfo);
ret = mod_load(&loadinfo);
mod_dumploadinfo(&loadinfo);
if (ret != 0)
{
@ -198,7 +198,7 @@ int insmod(FAR struct module_s *modp)
/* Bind the program to the exported symbol table */
ret = libmod_bind(&loadinfo, modp->exports, modp->nexports);
ret = mod_bind(&loadinfo, modp->exports, modp->nexports);
if (ret != 0)
{
bdbg("Failed to bind symbols program binary: %d\n", ret);
@ -226,13 +226,13 @@ int insmod(FAR struct module_s *modp)
}
}
libmod_uninitialize(&loadinfo);
mod_uninitialize(&loadinfo);
return OK;
errout_with_load:
libmod_unload(&loadinfo);
mod_unload(&loadinfo);
errout_with_init:
libmod_uninitialize(&loadinfo);
mod_uninitialize(&loadinfo);
errout:
return ret;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_iobuffer.c
* sched/module/mod_iobuffer.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,28 +43,16 @@
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "module.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_allocbuffer
* Name: mod_allocbuffer
*
* Description:
* Perform the initial allocation of the I/O buffer, if it has not already
@ -76,7 +64,7 @@
*
****************************************************************************/
int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo)
int mod_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
{
/* Has a buffer been allocated> */
@ -87,7 +75,7 @@ int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo)
loadinfo->iobuffer = (FAR uint8_t *)kmm_malloc(CONFIG_MODULE_BUFFERSIZE);
if (!loadinfo->iobuffer)
{
bdbg("Failed to allocate an I/O buffer\n");
sdbg("Failed to allocate an I/O buffer\n");
return -ENOMEM;
}
@ -98,7 +86,7 @@ int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo)
}
/****************************************************************************
* Name: libmod_reallocbuffer
* Name: mod_reallocbuffer
*
* Description:
* Increase the size of I/O buffer by the specified buffer increment.
@ -109,7 +97,7 @@ int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
int libmod_reallocbuffer(FAR struct libmod_loadinfo_s *loadinfo, size_t increment)
int mod_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment)
{
FAR void *buffer;
size_t newsize;
@ -123,7 +111,7 @@ int libmod_reallocbuffer(FAR struct libmod_loadinfo_s *loadinfo, size_t incremen
buffer = kmm_realloc((FAR void *)loadinfo->iobuffer, newsize);
if (!buffer)
{
bdbg("Failed to reallocate the I/O buffer\n");
sdbg("Failed to reallocate the I/O buffer\n");
return -ENOMEM;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_load.c
* sched/module/mod_load.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -51,9 +51,9 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
#include "module.h"
/****************************************************************************
* Pre-processor Definitions
@ -71,16 +71,12 @@
# define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_elfsize
* Name: mod_elfsize
*
* Description:
* Calculate total memory allocation for the ELF file.
@ -91,7 +87,7 @@
*
****************************************************************************/
static void libmod_elfsize(struct libmod_loadinfo_s *loadinfo)
static void mod_elfsize(struct mod_loadinfo_s *loadinfo)
{
size_t textsize;
size_t datasize;
@ -134,7 +130,7 @@ static void libmod_elfsize(struct libmod_loadinfo_s *loadinfo)
}
/****************************************************************************
* Name: libmod_loadfile
* Name: mod_loadfile
*
* Description:
* Read the section data into memory. Section addresses in the shdr[] are
@ -146,7 +142,7 @@ static void libmod_elfsize(struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
static inline int mod_loadfile(FAR struct mod_loadinfo_s *loadinfo)
{
FAR uint8_t *text;
FAR uint8_t *data;
@ -156,7 +152,7 @@ static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
/* Read each section into memory that is marked SHF_ALLOC + SHT_NOBITS */
bvdbg("Loaded sections:\n");
svdbg("Loaded sections:\n");
text = (FAR uint8_t *)loadinfo->textalloc;
data = (FAR uint8_t *)loadinfo->datastart;
@ -193,10 +189,10 @@ static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
{
/* Read the section data from sh_offset to the memory region */
ret = libmod_read(loadinfo, *pptr, shdr->sh_size, shdr->sh_offset);
ret = mod_read(loadinfo, *pptr, shdr->sh_size, shdr->sh_offset);
if (ret < 0)
{
bdbg("ERROR: Failed to read section %d: %d\n", i, ret);
sdbg("ERROR: Failed to read section %d: %d\n", i, ret);
return ret;
}
}
@ -212,7 +208,7 @@ static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
/* Update sh_addr to point to copy in memory */
bvdbg("%d. %08lx->%08lx\n", i,
svdbg("%d. %08lx->%08lx\n", i,
(unsigned long)shdr->sh_addr, (unsigned long)*pptr);
shdr->sh_addr = (uintptr_t)*pptr;
@ -230,7 +226,7 @@ static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
****************************************************************************/
/****************************************************************************
* Name: libmod_load
* Name: mod_load
*
* Description:
* Loads the binary into memory, allocating memory, performing relocations
@ -242,25 +238,25 @@ static inline int libmod_loadfile(FAR struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
int libmod_load(FAR struct libmod_loadinfo_s *loadinfo)
int mod_load(FAR struct mod_loadinfo_s *loadinfo)
{
int ret;
bvdbg("loadinfo: %p\n", loadinfo);
svdbg("loadinfo: %p\n", loadinfo);
DEBUGASSERT(loadinfo && loadinfo->filfd >= 0);
/* Load section headers into memory */
ret = libmod_loadshdrs(loadinfo);
ret = mod_loadshdrs(loadinfo);
if (ret < 0)
{
bdbg("ERROR: libmod_loadshdrs failed: %d\n", ret);
sdbg("ERROR: mod_loadshdrs failed: %d\n", ret);
goto errout_with_buffers;
}
/* Determine total size to allocate */
libmod_elfsize(loadinfo);
mod_elfsize(loadinfo);
/* Allocate (and zero) memory for the ELF file. */
@ -269,7 +265,7 @@ int libmod_load(FAR struct libmod_loadinfo_s *loadinfo)
loadinfo->textalloc = (uintptr_t)kmm_zalloc(loadinfo->textsize + loadinfo->datasize);
if (!loadinfo->textalloc)
{
bdbg("ERROR: Failed to allocate memory for the module\n");
sdbg("ERROR: Failed to allocate memory for the module\n");
ret = -ENOMEM;
goto errout_with_buffers;
}
@ -278,10 +274,10 @@ int libmod_load(FAR struct libmod_loadinfo_s *loadinfo)
/* Load ELF section data into memory */
ret = libmod_loadfile(loadinfo);
ret = mod_loadfile(loadinfo);
if (ret < 0)
{
bdbg("ERROR: libmod_loadfile failed: %d\n", ret);
sdbg("ERROR: mod_loadfile failed: %d\n", ret);
goto errout_with_buffers;
}
@ -290,7 +286,6 @@ int libmod_load(FAR struct libmod_loadinfo_s *loadinfo)
/* Error exits */
errout_with_buffers:
libmod_unload(loadinfo);
mod_unload(loadinfo);
return ret;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_read.c
* sched/module/mod_read.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -47,9 +47,9 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
#include "module.h"
/****************************************************************************
* Pre-processor Definitions
@ -66,11 +66,11 @@
****************************************************************************/
/****************************************************************************
* Name: libmod_dumpreaddata
* Name: mod_dumpreaddata
****************************************************************************/
#if defined(ELF_DUMP_READDATA)
static inline void libmod_dumpreaddata(FAR char *buffer, int buflen)
static inline void mod_dumpreaddata(FAR char *buffer, int buflen)
{
FAR uint32_t *buf32 = (FAR uint32_t *)buffer;
int i;
@ -88,7 +88,7 @@ static inline void libmod_dumpreaddata(FAR char *buffer, int buflen)
}
}
#else
# define libmod_dumpreaddata(b,n)
# define mod_dumpreaddata(b,n)
#endif
/****************************************************************************
@ -96,7 +96,7 @@ static inline void libmod_dumpreaddata(FAR char *buffer, int buflen)
****************************************************************************/
/****************************************************************************
* Name: libmod_read
* Name: mod_read
*
* Description:
* Read 'readsize' bytes from the object file at 'offset'. The data is
@ -108,13 +108,13 @@ static inline void libmod_dumpreaddata(FAR char *buffer, int buflen)
*
****************************************************************************/
int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
size_t readsize, off_t offset)
int mod_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
size_t readsize, off_t offset)
{
ssize_t nbytes; /* Number of bytes read */
off_t rpos; /* Position returned by lseek */
bvdbg("Read %ld bytes from offset %ld\n", (long)readsize, (long)offset);
svdbg("Read %ld bytes from offset %ld\n", (long)readsize, (long)offset);
/* Loop until all of the requested data has been read. */
@ -126,7 +126,7 @@ int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
if (rpos != offset)
{
int errval = errno;
bdbg("Failed to seek to position %lu: %d\n",
sdbg("Failed to seek to position %lu: %d\n",
(unsigned long)offset, errval);
return -errval;
}
@ -142,14 +142,14 @@ int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
if (errval != EINTR)
{
bdbg("Read from offset %lu failed: %d\n",
sdbg("Read from offset %lu failed: %d\n",
(unsigned long)offset, errval);
return -errval;
}
}
else if (nbytes == 0)
{
bdbg("Unexpected end of file\n");
sdbg("Unexpected end of file\n");
return -ENODATA;
}
else
@ -160,6 +160,6 @@ int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
}
}
libmod_dumpreaddata(buffer, readsize);
mod_dumpreaddata(buffer, readsize);
return OK;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_sections.c
* sched/module/mod_sections.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -46,24 +46,16 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Constant Data
****************************************************************************/
#include "module.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_sectname
* Name: mod_sectname
*
* Description:
* Get the symbol name in loadinfo->iobuffer[].
@ -74,8 +66,8 @@
*
****************************************************************************/
static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *shdr)
static inline int mod_sectname(FAR struct mod_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *shdr)
{
FAR Elf32_Shdr *shstr;
FAR uint8_t *buffer;
@ -93,7 +85,7 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
shstrndx = loadinfo->ehdr.e_shstrndx;
if (shstrndx == SHN_UNDEF)
{
bdbg("No section header string table\n");
sdbg("No section header string table\n");
return -EINVAL;
}
@ -126,7 +118,7 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
{
if (loadinfo->filelen <= offset)
{
bdbg("At end of file\n");
sdbg("At end of file\n");
return -EINVAL;
}
@ -136,10 +128,10 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
/* Read that number of bytes into the array */
buffer = &loadinfo->iobuffer[bytesread];
ret = libmod_read(loadinfo, buffer, readlen, offset);
ret = mod_read(loadinfo, buffer, readlen, offset);
if (ret < 0)
{
bdbg("Failed to read section name\n");
sdbg("Failed to read section name\n");
return ret;
}
@ -156,10 +148,10 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
/* No.. then we have to read more */
ret = libmod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
ret = mod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
if (ret < 0)
{
bdbg("libmod_reallocbuffer failed: %d\n", ret);
sdbg("mod_reallocbuffer failed: %d\n", ret);
return ret;
}
}
@ -174,7 +166,7 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
****************************************************************************/
/****************************************************************************
* Name: libmod_loadshdrs
* Name: mod_loadshdrs
*
* Description:
* Loads section headers into memory.
@ -185,7 +177,7 @@ static inline int libmod_sectname(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo)
int mod_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
{
size_t shdrsize;
int ret;
@ -196,7 +188,7 @@ int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo)
if (loadinfo->ehdr.e_shnum < 1)
{
bdbg("No sections(?)\n");
sdbg("No sections(?)\n");
return -EINVAL;
}
@ -205,7 +197,7 @@ int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo)
shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum;
if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
{
bdbg("Insufficent space in file for section header table\n");
sdbg("Insufficent space in file for section header table\n");
return -ESPIPE;
}
@ -214,25 +206,25 @@ int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo)
loadinfo->shdr = (FAR FAR Elf32_Shdr *)kmm_malloc(shdrsize);
if (!loadinfo->shdr)
{
bdbg("Failed to allocate the section header table. Size: %ld\n",
sdbg("Failed to allocate the section header table. Size: %ld\n",
(long)shdrsize);
return -ENOMEM;
}
/* Read the section header table into memory */
ret = libmod_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
ret = mod_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
loadinfo->ehdr.e_shoff);
if (ret < 0)
{
bdbg("Failed to read section header table: %d\n", ret);
sdbg("Failed to read section header table: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: libmod_findsection
* Name: mod_findsection
*
* Description:
* A section by its name.
@ -247,8 +239,8 @@ int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
int libmod_findsection(FAR struct libmod_loadinfo_s *loadinfo,
FAR const char *sectname)
int mod_findsection(FAR struct mod_loadinfo_s *loadinfo,
FAR const char *sectname)
{
FAR const Elf32_Shdr *shdr;
int ret;
@ -261,16 +253,16 @@ int libmod_findsection(FAR struct libmod_loadinfo_s *loadinfo,
/* Get the name of this section */
shdr = &loadinfo->shdr[i];
ret = libmod_sectname(loadinfo, shdr);
ret = mod_sectname(loadinfo, shdr);
if (ret < 0)
{
bdbg("libmod_sectname failed: %d\n", ret);
sdbg("mod_sectname failed: %d\n", ret);
return ret;
}
/* Check if the name of this section is 'sectname' */
bvdbg("%d. Comparing \"%s\" and .\"%s\"\n",
svdbg("%d. Comparing \"%s\" and .\"%s\"\n",
i, loadinfo->iobuffer, sectname);
if (strcmp((FAR const char *)loadinfo->iobuffer, sectname) == 0)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_symbols.c
* sched/module/mod_symbols.c
*
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -45,10 +45,10 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include <nuttx/binfmt/symtab.h>
#include "libmodule.h"
#include "module.h"
/****************************************************************************
* Pre-processor Definitions
@ -58,16 +58,12 @@
# define CONFIG_MODULE_BUFFERINCR 32
#endif
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_symname
* Name: mod_symname
*
* Description:
* Get the symbol name in loadinfo->iobuffer[].
@ -82,8 +78,8 @@
*
****************************************************************************/
static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
FAR const Elf32_Sym *sym)
static int mod_symname(FAR struct mod_loadinfo_s *loadinfo,
FAR const Elf32_Sym *sym)
{
FAR uint8_t *buffer;
off_t offset;
@ -97,7 +93,7 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
if (sym->st_name == 0)
{
bdbg("Symbol has no name\n");
sdbg("Symbol has no name\n");
return -ESRCH;
}
@ -116,7 +112,7 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
{
if (loadinfo->filelen <= offset)
{
bdbg("At end of file\n");
sdbg("At end of file\n");
return -EINVAL;
}
@ -126,10 +122,10 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
/* Read that number of bytes into the array */
buffer = &loadinfo->iobuffer[bytesread];
ret = libmod_read(loadinfo, buffer, readlen, offset);
ret = mod_read(loadinfo, buffer, readlen, offset);
if (ret < 0)
{
bdbg("libmod_read failed: %d\n", ret);
sdbg("mod_read failed: %d\n", ret);
return ret;
}
@ -146,10 +142,10 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
/* No.. then we have to read more */
ret = libmod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
ret = mod_reallocbuffer(loadinfo, CONFIG_MODULE_BUFFERINCR);
if (ret < 0)
{
bdbg("libmod_reallocbuffer failed: %d\n", ret);
sdbg("mod_reallocbuffer failed: %d\n", ret);
return ret;
}
}
@ -164,7 +160,7 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
****************************************************************************/
/****************************************************************************
* Name: libmod_findsymtab
* Name: mod_findsymtab
*
* Description:
* Find the symbol table section.
@ -175,7 +171,7 @@ static int libmod_symname(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo)
int mod_findsymtab(FAR struct mod_loadinfo_s *loadinfo)
{
int i;
@ -195,7 +191,7 @@ int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo)
if (loadinfo->symtabidx == 0)
{
bdbg("No symbols in ELF file\n");
sdbg("No symbols in ELF file\n");
return -EINVAL;
}
@ -203,7 +199,7 @@ int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo)
}
/****************************************************************************
* Name: libmod_readsym
* Name: mod_readsym
*
* Description:
* Read the ELFT symbol structure at the specfied index into memory.
@ -219,8 +215,8 @@ int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym)
int mod_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym)
{
FAR Elf32_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
off_t offset;
@ -229,7 +225,7 @@ int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
if (index < 0 || index > (symtab->sh_size / sizeof(Elf32_Sym)))
{
bdbg("Bad relocation symbol index: %d\n", index);
sdbg("Bad relocation symbol index: %d\n", index);
return -EINVAL;
}
@ -239,11 +235,11 @@ int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
/* And, finally, read the symbol table entry into memory */
return libmod_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
return mod_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
}
/****************************************************************************
* Name: libmod_symvalue
* Name: mod_symvalue
*
* Description:
* Get the value of a symbol. The updated value of the symbol is returned
@ -265,8 +261,8 @@ int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
*
****************************************************************************/
int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
FAR const struct symtab_s *exports, int nexports)
int mod_symvalue(FAR struct mod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
FAR const struct symtab_s *exports, int nexports)
{
FAR const struct symtab_s *symbol;
uintptr_t secbase;
@ -278,7 +274,7 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
{
/* NuttX ELF modules should be compiled with -fno-common. */
bdbg("SHN_COMMON: Re-compile with -fno-common\n");
sdbg("SHN_COMMON: Re-compile with -fno-common\n");
return -ENOSYS;
}
@ -286,7 +282,7 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
{
/* st_value already holds the correct value */
bvdbg("SHN_ABS: st_value=%08lx\n", (long)sym->st_value);
svdbg("SHN_ABS: st_value=%08lx\n", (long)sym->st_value);
return OK;
}
@ -294,7 +290,7 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
{
/* Get the name of the undefined symbol */
ret = libmod_symname(loadinfo, sym);
ret = mod_symname(loadinfo, sym);
if (ret < 0)
{
/* There are a few relocations for a few architectures that do
@ -303,7 +299,7 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
* indicate the nameless symbol.
*/
bdbg("SHN_UNDEF: Failed to get symbol name: %d\n", ret);
sdbg("SHN_UNDEF: Failed to get symbol name: %d\n", ret);
return ret;
}
@ -316,13 +312,13 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
#endif
if (!symbol)
{
bdbg("SHN_UNDEF: Exported symbol \"%s\" not found\n", loadinfo->iobuffer);
sdbg("SHN_UNDEF: Exported symbol \"%s\" not found\n", loadinfo->iobuffer);
return -ENOENT;
}
/* Yes... add the exported symbol value to the ELF symbol table entry */
bvdbg("SHN_ABS: name=%s %08x+%08x=%08x\n",
svdbg("SHN_ABS: name=%s %08x+%08x=%08x\n",
loadinfo->iobuffer, sym->st_value, symbol->sym_value,
sym->st_value + symbol->sym_value);
@ -334,7 +330,7 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
{
secbase = loadinfo->shdr[sym->st_shndx].sh_addr;
bvdbg("Other: %08x+%08x=%08x\n",
svdbg("Other: %08x+%08x=%08x\n",
sym->st_value, secbase, sym->st_value + secbase);
sym->st_value += secbase;

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_uninit.c
* sched/module/mod_uninit.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,32 +44,20 @@
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "module.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_uninitialize
* Name: mod_uninitialize
*
* Description:
* Releases any resources committed by libmod_initialize(). This essentially
* undoes the actions of libmod_initialize.
* Releases any resources committed by mod_initialize(). This essentially
* undoes the actions of mod_initialize.
*
* Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on
@ -77,11 +65,11 @@
*
****************************************************************************/
int libmod_uninitialize(struct libmod_loadinfo_s *loadinfo)
int mod_uninitialize(struct mod_loadinfo_s *loadinfo)
{
/* Free all working buffers */
libmod_freebuffers(loadinfo);
mod_freebuffers(loadinfo);
/* Close the ELF file */
@ -94,7 +82,7 @@ int libmod_uninitialize(struct libmod_loadinfo_s *loadinfo)
}
/****************************************************************************
* Name: libmod_freebuffers
* Name: mod_freebuffers
*
* Description:
* Release all working buffers.
@ -105,7 +93,7 @@ int libmod_uninitialize(struct libmod_loadinfo_s *loadinfo)
*
****************************************************************************/
int libmod_freebuffers(struct libmod_loadinfo_s *loadinfo)
int mod_freebuffers(struct mod_loadinfo_s *loadinfo)
{
/* Release all working allocations */

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_unload.c
* sched/module/mod_unload.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,32 +43,20 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
#include "libmodule.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Constant Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
#include "module.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_unload
* Name: mod_unload
*
* Description:
* This function unloads the object from memory. This essentially undoes
* the actions of libmod_load. It is called only under certain error
* the actions of mod_load. It is called only under certain error
* conditions after the module has been loaded but not yet started.
*
* Returned Value:
@ -77,11 +65,11 @@
*
****************************************************************************/
int libmod_unload(struct libmod_loadinfo_s *loadinfo)
int mod_unload(struct mod_loadinfo_s *loadinfo)
{
/* Free all working buffers */
libmod_freebuffers(loadinfo);
mod_freebuffers(loadinfo);
/* Release memory holding the relocated ELF image */
@ -99,4 +87,3 @@ int libmod_unload(struct libmod_loadinfo_s *loadinfo)
return OK;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* binfmt/libmodule/libmodule_verify.c
* sched/module/mod_verify.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,11 +43,7 @@
#include <debug.h>
#include <errno.h>
#include <nuttx/binfmt/module.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#include <nuttx/module.h>
/****************************************************************************
* Private Constant Data
@ -58,16 +54,12 @@ static const char g_modmagic[EI_MAGIC_SIZE] =
0x7f, 'E', 'L', 'F'
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: libmod_verifyheader
* Name: mod_verifyheader
*
* Description:
* Given the header from a possible ELF executable, verify that it
@ -83,11 +75,11 @@ static const char g_modmagic[EI_MAGIC_SIZE] =
*
****************************************************************************/
int libmod_verifyheader(FAR const Elf32_Ehdr *ehdr)
int mod_verifyheader(FAR const Elf32_Ehdr *ehdr)
{
if (!ehdr)
{
bdbg("NULL ELF header!");
sdbg("NULL ELF header!");
return -ENOEXEC;
}
@ -95,7 +87,7 @@ int libmod_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (memcmp(ehdr->e_ident, g_modmagic, EI_MAGIC_SIZE) != 0)
{
bvdbg("Not ELF magic {%02x, %02x, %02x, %02x}\n",
svdbg("Not ELF magic {%02x, %02x, %02x, %02x}\n",
ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], ehdr->e_ident[3]);
return -ENOEXEC;
}
@ -104,7 +96,7 @@ int libmod_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (ehdr->e_type != ET_REL)
{
bdbg("Not a relocatable file: e_type=%d\n", ehdr->e_type);
sdbg("Not a relocatable file: e_type=%d\n", ehdr->e_type);
return -EINVAL;
}
@ -112,7 +104,7 @@ int libmod_verifyheader(FAR const Elf32_Ehdr *ehdr)
if (up_checkarch(ehdr))
{
bdbg("Not a supported architecture\n");
sdbg("Not a supported architecture\n");
return -ENOEXEC;
}
@ -120,4 +112,3 @@ int libmod_verifyheader(FAR const Elf32_Ehdr *ehdr)
return OK;
}

View file

@ -1,5 +1,5 @@
/****************************************************************************
* binfmt/libmodule/libmodule.h
* sched/module/module.h
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __BINFMT_LIBELF_LIBELF_H
#define __BINFMT_LIBELF_LIBELF_H
#ifndef __SCHED_MODULE_MODULE_H
#define __SCHED_MODULE_MODULE_H
/****************************************************************************
* Included Files
@ -46,7 +46,7 @@
#include <elf32.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/module.h>
#include <nuttx/module.h>
/****************************************************************************
* Public Types
@ -56,7 +56,7 @@
* of the kernel module.
*/
struct libmod_loadinfo_s
struct mod_loadinfo_s
{
/* elfalloc is the base address of the memory that is allocated to hold the
* module image.
@ -85,11 +85,7 @@ struct libmod_loadinfo_s
****************************************************************************/
/****************************************************************************
* These are APIs exported by libmodule and used by insmod
****************************************************************************/
/****************************************************************************
* Name: libmod_initialize
* Name: mod_initialize
*
* Description:
* This function is called to configure the library to process an kernel
@ -101,15 +97,15 @@ struct libmod_loadinfo_s
*
****************************************************************************/
int libmod_initialize(FAR const char *filename,
FAR struct libmod_loadinfo_s *loadinfo);
int mod_initialize(FAR const char *filename,
FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_uninitialize
* Name: mod_uninitialize
*
* Description:
* Releases any resources committed by mod_init(). This essentially
* undoes the actions of libmod_initialize.
* undoes the actions of mod_initialize.
*
* Returned Value:
* 0 (OK) is returned on success and a negated errno is returned on
@ -117,10 +113,10 @@ int libmod_initialize(FAR const char *filename,
*
****************************************************************************/
int libmod_uninitialize(FAR struct libmod_loadinfo_s *loadinfo);
int mod_uninitialize(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_load
* Name: mod_load
*
* Description:
* Loads the binary into memory, allocating memory, performing relocations
@ -132,10 +128,10 @@ int libmod_uninitialize(FAR struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_load(FAR struct libmod_loadinfo_s *loadinfo);
int mod_load(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_bind
* Name: mod_bind
*
* Description:
* Bind the imported symbol names in the loaded module described by
@ -148,11 +144,11 @@ int libmod_load(FAR struct libmod_loadinfo_s *loadinfo);
****************************************************************************/
struct symtab_s;
int libmod_bind(FAR struct libmod_loadinfo_s *loadinfo,
FAR const struct symtab_s *exports, int nexports);
int mod_bind(FAR struct mod_loadinfo_s *loadinfo,
FAR const struct symtab_s *exports, int nexports);
/****************************************************************************
* Name: libmod_unload
* Name: mod_unload
*
* Description:
* This function unloads the object from memory. This essentially undoes
@ -165,10 +161,10 @@ int libmod_bind(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
int libmod_unload(struct libmod_loadinfo_s *loadinfo);
int mod_unload(struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_verifyheader
* Name: mod_verifyheader
*
* Description:
* Given the header from a possible ELF executable, verify that it is
@ -180,10 +176,10 @@ int libmod_unload(struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_verifyheader(FAR const Elf32_Ehdr *header);
int mod_verifyheader(FAR const Elf32_Ehdr *header);
/****************************************************************************
* Name: libmod_read
* Name: mod_read
*
* Description:
* Read 'readsize' bytes from the object file at 'offset'. The data is
@ -195,11 +191,11 @@ int libmod_verifyheader(FAR const Elf32_Ehdr *header);
*
****************************************************************************/
int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
size_t readsize, off_t offset);
int mod_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
size_t readsize, off_t offset);
/****************************************************************************
* Name: libmod_loadshdrs
* Name: mod_loadshdrs
*
* Description:
* Loads section headers into memory.
@ -210,10 +206,10 @@ int libmod_read(FAR struct libmod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
*
****************************************************************************/
int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo);
int mod_loadshdrs(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_findsection
* Name: mod_findsection
*
* Description:
* A section by its name.
@ -228,11 +224,11 @@ int libmod_loadshdrs(FAR struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_findsection(FAR struct libmod_loadinfo_s *loadinfo,
FAR const char *sectname);
int mod_findsection(FAR struct mod_loadinfo_s *loadinfo,
FAR const char *sectname);
/****************************************************************************
* Name: libmod_findsymtab
* Name: mod_findsymtab
*
* Description:
* Find the symbol table section.
@ -243,10 +239,10 @@ int libmod_findsection(FAR struct libmod_loadinfo_s *loadinfo,
*
****************************************************************************/
int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo);
int mod_findsymtab(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_readsym
* Name: mod_readsym
*
* Description:
* Read the ELFT symbol structure at the specfied index into memory.
@ -262,11 +258,11 @@ int libmod_findsymtab(FAR struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym);
int mod_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym);
/****************************************************************************
* Name: libmod_symvalue
* Name: mod_symvalue
*
* Description:
* Get the value of a symbol. The updated value of the symbol is returned
@ -290,11 +286,11 @@ int libmod_readsym(FAR struct libmod_loadinfo_s *loadinfo, int index,
*
****************************************************************************/
int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
FAR const struct symtab_s *exports, int nexports);
int mod_symvalue(FAR struct mod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
FAR const struct symtab_s *exports, int nexports);
/****************************************************************************
* Name: libmod_freebuffers
* Name: mod_freebuffers
*
* Description:
* Release all working buffers.
@ -305,10 +301,10 @@ int libmod_symvalue(FAR struct libmod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
*
****************************************************************************/
int libmod_freebuffers(FAR struct libmod_loadinfo_s *loadinfo);
int mod_freebuffers(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_allocbuffer
* Name: mod_allocbuffer
*
* Description:
* Perform the initial allocation of the I/O buffer, if it has not already
@ -320,10 +316,10 @@ int libmod_freebuffers(FAR struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo);
int mod_allocbuffer(FAR struct mod_loadinfo_s *loadinfo);
/****************************************************************************
* Name: libmod_reallocbuffer
* Name: mod_reallocbuffer
*
* Description:
* Increase the size of I/O buffer by the specified buffer increment.
@ -334,6 +330,6 @@ int libmod_allocbuffer(FAR struct libmod_loadinfo_s *loadinfo);
*
****************************************************************************/
int libmod_reallocbuffer(FAR struct libmod_loadinfo_s *loadinfo, size_t increment);
int mod_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo, size_t increment);
#endif /* __BINFMT_LIBELF_LIBELF_H */
#endif /* __SCHED_MODULE_MODULE_H */