mirror of
https://github.com/apache/nuttx.git
synced 2025-05-07 22:01:55 +08:00
libc/elf: rename modlib to libelf
Renaming "modlib" to "libelf" is more in line with the implementation content, which makes it easier for individual developers to understand the capabilities of this module. CONFIG_LIBC_MODLIB -> CONFIG_LIBC_ELF Signed-off-by: chao an <anchao.archer@bytedance.com>
This commit is contained in:
parent
1b9e6a8563
commit
52482219c8
@ -54,9 +54,9 @@ options:
|
||||
|
||||
6. Linker scripts. You might also want to use a linker scripts to combine
|
||||
sections better. An example linker script is at
|
||||
``nuttx/binfmt/libelf/gnu-elf.ld``. That example might have to be tuned for
|
||||
``nuttx/binfmt/elf/gnu-elf.ld``. That example might have to be tuned for
|
||||
your particular linker output to position additional sections correctly. The
|
||||
GNU LD ``LDELFFLAGS`` then might be::
|
||||
|
||||
LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld
|
||||
LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/elf/gnu-elf.ld
|
||||
|
||||
|
@ -55,8 +55,8 @@ configuration options:
|
||||
|
||||
6. Linker scripts. You might also want to use a linker scripts to combine
|
||||
sections better. An example linker script is at
|
||||
``nuttx/libc/modlib/gnu-elf.ld``. That example might have to be tuned for your
|
||||
``nuttx/libc/elf/gnu-elf.ld``. That example might have to be tuned for your
|
||||
particular linker output to position additional sections correctly. The GNU
|
||||
LD ``LDMODULEFLAGS`` then might be::
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/modlib/gnu-elf.ld
|
||||
LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/elf/gnu-elf.ld
|
||||
|
@ -66,8 +66,8 @@ Test-specific configuration options:
|
||||
|
||||
6. Linker scripts. You might also want to use a linker scripts to combine
|
||||
sections better. An example linker script is at
|
||||
``nuttx/binfmt/libelf/gnu-elf.ld``. That example might have to be tuned for
|
||||
``nuttx/binfmt/elf/gnu-elf.ld``. That example might have to be tuned for
|
||||
your particular linker output to position additional sections correctly. The
|
||||
GNU LD ``LDELFFLAGS`` then might be::
|
||||
|
||||
LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld
|
||||
LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/elf/gnu-elf.ld
|
||||
|
@ -53,8 +53,8 @@ system. At run time, the shared library is installed and exercised. Requires
|
||||
|
||||
6. Linker scripts. You might also want to use a linker scripts to combine
|
||||
sections better. An example linker script is at
|
||||
``nuttx/libc/modlib/gnu-elf.ld``. That example might have to be tuned for your
|
||||
``nuttx/libc/elf/gnu-elf.ld``. That example might have to be tuned for your
|
||||
particular linker output to position additional sections correctly. The GNU
|
||||
LD ``LDMODULEFLAGS`` then might be::
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/modlib/gnu-elf.ld
|
||||
LDMODULEFLAGS = -r -e module_initialize -T$(TOPDIR)/libc/elf/gnu-elf.ld
|
||||
|
@ -43,7 +43,7 @@ functions. So we have::
|
||||
inttypes - inttypes.h
|
||||
machine - Various architecture-specific implementations.
|
||||
math - math.h
|
||||
modlib - Part of module and shared library logic: nuttx/lib/modlib.h
|
||||
elf - Part of module and shared library logic: nuttx/lib/elf.h
|
||||
net - Various network-related header files: netinet/ether.h, arpa/inet.h
|
||||
pthread - pthread.h
|
||||
pwd - pwd.h
|
||||
|
@ -536,7 +536,7 @@ A macOS port is available at: <https://github.com/discoteq/flock>
|
||||
|
||||
* Xcode (the native compiler and the rest of the toolchain)
|
||||
|
||||
* ELF toolchain (if you want to build modules for CONFIG_LIBC_MODLIB)
|
||||
* ELF toolchain (if you want to build modules for CONFIG_LIBC_ELF)
|
||||
|
||||
brew install x86_64-elf-gcc
|
||||
|
||||
|
@ -1819,10 +1819,10 @@ Configuration sub-directories
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_LIBC_ARCH_ELF=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_LIBC_MODLIB=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=2
|
||||
CONFIG_MODLIB_BUFFERINCR=32
|
||||
CONFIG_MODLIB_BUFFERSIZE=128
|
||||
CONFIG_LIBC_ELF=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=2
|
||||
CONFIG_LIBC_ELF_BUFFERINCR=32
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=128
|
||||
|
||||
Add the following for testing shared libraries in the FLAT
|
||||
build:
|
||||
|
@ -389,11 +389,11 @@ the nsh configuration include these additions to the configuration file::
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_LIBC_ARCH_ELF=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_LIBC_MODLIB=y
|
||||
CONFIG_MODLIB_MAXDEPEND=2
|
||||
CONFIG_MODLIB_ALIGN_LOG2=2
|
||||
CONFIG_MODLIB_BUFFERSIZE=128
|
||||
CONFIG_MODLIB_BUFFERINCR=32
|
||||
CONFIG_LIBC_ELF=y
|
||||
CONFIG_LIBC_ELF_MAXDEPEND=2
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=2
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=128
|
||||
CONFIG_LIBC_ELF_BUFFERINCR=32
|
||||
|
||||
The could be followed may be added for testing shared libraries in the
|
||||
FLAT build using apps/examples/sotest (assuming that you also have SD
|
||||
@ -448,10 +448,10 @@ NOTES:
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_LIBC_ARCH_ELF=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_LIBC_MODLIB=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=2
|
||||
CONFIG_MODLIB_BUFFERINCR=32
|
||||
CONFIG_MODLIB_BUFFERSIZE=128
|
||||
CONFIG_LIBC_ELF=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=2
|
||||
CONFIG_LIBC_ELF_BUFFERINCR=32
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=128
|
||||
|
||||
Add the following for testing shared libraries in the FLAT
|
||||
build::
|
||||
|
@ -1438,11 +1438,11 @@ other NSH configurations include these additions to the configuration file::
|
||||
CONFIG_FS_ROMFS=y
|
||||
CONFIG_LIBC_ARCH_ELF=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_LIBC_MODLIB=y
|
||||
CONFIG_MODLIB_MAXDEPEND=2
|
||||
CONFIG_MODLIB_ALIGN_LOG2=2
|
||||
CONFIG_MODLIB_BUFFERSIZE=128
|
||||
CONFIG_MODLIB_BUFFERINCR=32
|
||||
CONFIG_LIBC_ELF=y
|
||||
CONFIG_LIBC_ELF_MAXDEPEND=2
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=2
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=128
|
||||
CONFIG_LIBC_ELF_BUFFERINCR=32
|
||||
|
||||
The could be followed may be added for testing shared libraries in the
|
||||
FLAT build using apps/examples/sotest (assuming that you also have SD
|
||||
|
@ -748,14 +748,14 @@ apps/interpreters/minibasic.
|
||||
module
|
||||
------
|
||||
|
||||
This is a configuration to test CONFIG_LIBC_MODLIB with 64-bit modules.
|
||||
This is a configuration to test CONFIG_LIBC_ELF with 64-bit modules.
|
||||
This has apps/examples/module enabled.
|
||||
This configuration is intended for 64-bit host OS.
|
||||
|
||||
module32
|
||||
--------
|
||||
|
||||
This is a configuration to test CONFIG_LIBC_MODLIB with CONFIG_SIM_M32
|
||||
This is a configuration to test CONFIG_LIBC_ELF with CONFIG_SIM_M32
|
||||
and 32-bit modules.
|
||||
This has apps/examples/module enabled.
|
||||
This configuration is intended for 64-bit host OS.
|
||||
@ -1353,14 +1353,14 @@ with an MTD RAM driver to simulate the FLASH part.
|
||||
sotest
|
||||
------
|
||||
|
||||
This is a configuration to test CONFIG_LIBC_MODLIB with 64-bit modules.
|
||||
This is a configuration to test CONFIG_LIBC_ELF with 64-bit modules.
|
||||
This has apps/examples/sotest enabled.
|
||||
This configuration is intended for 64-bit host OS.
|
||||
|
||||
sotest32
|
||||
--------
|
||||
|
||||
This is a configuration to test CONFIG_LIBC_MODLIB with CONFIG_SIM_M32
|
||||
This is a configuration to test CONFIG_LIBC_ELF with CONFIG_SIM_M32
|
||||
and 32-bit modules.
|
||||
This has apps/examples/sotest enabled.
|
||||
This configuration is intended for 64-bit host OS.
|
||||
|
2
Kconfig
2
Kconfig
@ -801,7 +801,7 @@ endif # DEBUG_AUDIO
|
||||
config DEBUG_BINFMT
|
||||
bool "Binary Loader Debug Features"
|
||||
default n
|
||||
depends on !BINFMT_DISABLE || LIBC_MODLIB
|
||||
depends on !BINFMT_DISABLE || LIBC_ELF
|
||||
---help---
|
||||
Enable binary loader debug features.
|
||||
|
||||
|
@ -531,7 +531,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -558,7 +558,7 @@ ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -e __start -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -e __start -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
||||
# Zig toolchain
|
||||
|
||||
|
@ -240,7 +240,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden # --target1-abs
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -254,4 +254,4 @@ ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)arm64$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -173,7 +173,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -181,4 +181,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -103,7 +103,7 @@ endif
|
||||
## Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -111,4 +111,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -92,7 +92,7 @@ CPP = $(CROSSDEV)/cevaxccc -mquiet -Wa,-quiet -E -P -x c
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -100,4 +100,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -97,7 +97,7 @@ CPP = $(CROSSDEV)/cevaxm6cc -mquiet -Wa,-quiet -E -P -x c
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -105,4 +105,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -318,7 +318,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -326,4 +326,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -134,7 +134,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -142,4 +142,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -82,7 +82,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -90,4 +90,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -120,7 +120,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -128,4 +128,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -426,7 +426,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -445,7 +445,7 @@ else
|
||||
LDELFFLAGS += --oformat elf64-littleriscv
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# Zig toolchain
|
||||
|
||||
|
@ -44,7 +44,7 @@ set_property(
|
||||
TARGET nuttx
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_MODULE_LINK_OPTIONS -r -e module_initialize -T
|
||||
${NUTTX_DIR}/libs/libc/modlib/gnu-elf.ld)
|
||||
${NUTTX_DIR}/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
if(CONFIG_LIBC_ARCH_ELF_64BIT)
|
||||
# For amd64: It seems macOS/x86_64 loads the program text around
|
||||
|
@ -129,7 +129,7 @@ OBJDUMP = $(CROSSDEV)objdump
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -137,4 +137,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -131,7 +131,7 @@ ARCHOPTIMIZATION += --pass-c=--no-warnings=$(TASKING_WARNINGS)
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -139,4 +139,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -83,7 +83,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -91,4 +91,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -241,7 +241,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -256,7 +256,7 @@ ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
LDELFFLAGS += $(TOPDIR)$(DELIM)arch$(DELIM)x86_64$(DELIM)src$(DELIM)crt0.o
|
||||
endif
|
||||
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
||||
# -fno-pic to avoid GOT relocations
|
||||
# -mcmodel=large to avoid out-of-range 32-bit relocations
|
||||
|
@ -210,7 +210,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -218,4 +218,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -214,7 +214,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -222,4 +222,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -111,7 +111,7 @@ EXEEXT = .hex
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -119,4 +119,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -215,7 +215,7 @@ endif
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -223,4 +223,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -113,7 +113,7 @@ EXEEXT = .hex
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -121,4 +121,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -138,7 +138,7 @@ EXEEXT = .hex
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -146,4 +146,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -113,7 +113,7 @@ EXEEXT = .hex
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -121,4 +121,4 @@ CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e __start
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -50,7 +50,7 @@ config ELF
|
||||
bool "Enable the ELF Binary Format"
|
||||
default n
|
||||
select BINFMT_LOADABLE
|
||||
select LIBC_MODLIB
|
||||
select LIBC_ELF
|
||||
---help---
|
||||
Enable support for the ELF binary format. Default: n
|
||||
|
||||
|
24
binfmt/elf.c
24
binfmt/elf.c
@ -44,11 +44,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT
|
||||
* have to be defined or CONFIG_MODLIB_DUMPBUFFER does nothing.
|
||||
* have to be defined or CONFIG_LIBC_ELF_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined(CONFIG_DEBUG_BINFMT)
|
||||
# undef CONFIG_MODLIB_DUMPBUFFER
|
||||
# undef CONFIG_LIBC_ELF_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ELF_STACKSIZE
|
||||
@ -102,8 +102,8 @@ static int elf_loadbinary(FAR struct binary_s *binp,
|
||||
|
||||
/* Initialize the ELF library to load the program binary. */
|
||||
|
||||
ret = modlib_initialize(filename, &loadinfo);
|
||||
modlib_dumploadinfo(&loadinfo);
|
||||
ret = libelf_initialize(filename, &loadinfo);
|
||||
libelf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
berr("Failed to initialize to load ELF program binary: %d\n", ret);
|
||||
@ -112,8 +112,8 @@ static int elf_loadbinary(FAR struct binary_s *binp,
|
||||
|
||||
/* Load the program binary */
|
||||
|
||||
ret = modlib_load_with_addrenv(&loadinfo);
|
||||
modlib_dumploadinfo(&loadinfo);
|
||||
ret = libelf_load_with_addrenv(&loadinfo);
|
||||
libelf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
berr("Failed to load ELF program binary: %d\n", ret);
|
||||
@ -124,7 +124,7 @@ static int elf_loadbinary(FAR struct binary_s *binp,
|
||||
|
||||
if (loadinfo.ehdr.e_type == ET_REL || loadinfo.gotindex >= 0)
|
||||
{
|
||||
ret = modlib_bind(&binp->mod, &loadinfo, exports, nexports);
|
||||
ret = libelf_bind(&binp->mod, &loadinfo, exports, nexports);
|
||||
if (ret != 0)
|
||||
{
|
||||
berr("Failed to bind symbols program binary: %d\n", ret);
|
||||
@ -209,7 +209,7 @@ static int elf_loadbinary(FAR struct binary_s *binp,
|
||||
binp->mode = loadinfo.filemode;
|
||||
#endif
|
||||
|
||||
modlib_dumpentrypt(&loadinfo);
|
||||
libelf_dumpentrypt(&loadinfo);
|
||||
#ifdef CONFIG_PIC
|
||||
if (loadinfo.gotindex >= 0)
|
||||
{
|
||||
@ -227,13 +227,13 @@ static int elf_loadbinary(FAR struct binary_s *binp,
|
||||
}
|
||||
#endif
|
||||
|
||||
modlib_uninitialize(&loadinfo);
|
||||
libelf_uninitialize(&loadinfo);
|
||||
return OK;
|
||||
|
||||
errout_with_load:
|
||||
modlib_unload(&loadinfo);
|
||||
libelf_unload(&loadinfo);
|
||||
errout_with_init:
|
||||
modlib_uninitialize(&loadinfo);
|
||||
libelf_uninitialize(&loadinfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ errout_with_init:
|
||||
static int elf_unloadbinary(FAR struct binary_s *binp)
|
||||
{
|
||||
binfo("Unloading %p\n", binp);
|
||||
modlib_uninit(&binp->mod);
|
||||
libelf_uninit(&binp->mod);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -53,4 +53,4 @@ LDNXFLATFLAGS = -e main -s 2048
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -50,4 +50,4 @@ LDNXFLATFLAGS = -e main -s 2048
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -57,11 +57,11 @@ CONFIG_LC823450_UART1=y
|
||||
CONFIG_LC823450_WDT=y
|
||||
CONFIG_LCD=y
|
||||
CONFIG_LCD_ST7565=y
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=512
|
||||
CONFIG_LIBC_KBDCODEC=y
|
||||
CONFIG_LIBC_MAX_EXITFUNS=32
|
||||
CONFIG_LIBC_MEMSET_OPTSPEED=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MODLIB_BUFFERSIZE=512
|
||||
CONFIG_MQ_MAXMSGSIZE=64
|
||||
CONFIG_MTD=y
|
||||
CONFIG_NAME_MAX=255
|
||||
|
@ -62,6 +62,8 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=4096
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_DLFCN=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=128
|
||||
CONFIG_LIBC_ENVPATH=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_LPC17_40_CAN2=y
|
||||
@ -91,8 +93,6 @@ CONFIG_M25P_SUBSECTOR_ERASE=y
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODLIB_BUFFERSIZE=128
|
||||
CONFIG_MTD=y
|
||||
CONFIG_MTD_M25P=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
|
@ -68,4 +68,4 @@ LDNXFLATFLAGS = -e main -s 2048
|
||||
# ELF module definitions
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -125,11 +125,11 @@ CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF=y
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_FLOATINGPOINT=y
|
||||
CONFIG_LIBC_LONG_LONG=y
|
||||
CONFIG_LIBC_MEMFD_ERROR=y
|
||||
CONFIG_LIBC_MODLIB=y
|
||||
CONFIG_LIBC_STRERROR_ERRNUM=y
|
||||
CONFIG_LIBM_TOOLCHAIN=y
|
||||
CONFIG_LINE_MAX=80
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <sys/mount.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
|
||||
@ -116,37 +116,37 @@ int board_boot_image(const char *path, uint32_t hdr_size)
|
||||
|
||||
/* Initialize the ELF library to load the program binary. */
|
||||
|
||||
syslog(LOG_INFO, "modlib_init...\n");
|
||||
syslog(LOG_INFO, "libelf_init...\n");
|
||||
|
||||
ret = modlib_initialize(path, &loadinfo);
|
||||
ret = libelf_initialize(path, &loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to modlib_init: %d\n", ret);
|
||||
syslog(LOG_ERR, "Failed to libelf_init: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Load the program binary */
|
||||
|
||||
syslog(LOG_INFO, "modlib_load...\n");
|
||||
syslog(LOG_INFO, "libelf_load...\n");
|
||||
|
||||
ret = modlib_load(&loadinfo);
|
||||
ret = libelf_load(&loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to modlib_load: %d\n", ret);
|
||||
syslog(LOG_ERR, "Failed to libelf_load: %d\n", ret);
|
||||
goto errout_with_init;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "modlib_bind...\n");
|
||||
syslog(LOG_INFO, "libelf_bind...\n");
|
||||
|
||||
memset(&mod, 0, sizeof(struct module_s));
|
||||
ret = modlib_bind(&mod, &loadinfo, NULL, 0);
|
||||
ret = libelf_bind(&mod, &loadinfo, NULL, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to modlib_bind: %d\n", ret);
|
||||
syslog(LOG_ERR, "Failed to libelf_bind: %d\n", ret);
|
||||
goto errout_with_load;
|
||||
}
|
||||
|
||||
bss = modlib_findsection(&loadinfo, ".bss");
|
||||
bss = libelf_findsection(&loadinfo, ".bss");
|
||||
got = loadinfo.shdr[loadinfo.gotindex].sh_addr;
|
||||
msp = loadinfo.shdr[bss].sh_addr + loadinfo.shdr[bss].sh_size +
|
||||
CONFIG_IDLETHREAD_STACKSIZE;
|
||||
@ -172,9 +172,9 @@ int board_boot_image(const char *path, uint32_t hdr_size)
|
||||
((void (*)(void))loadinfo.ehdr.e_entry + loadinfo.textalloc)();
|
||||
|
||||
errout_with_load:
|
||||
modlib_unload(&loadinfo);
|
||||
libelf_unload(&loadinfo);
|
||||
errout_with_init:
|
||||
modlib_uninitialize(&loadinfo);
|
||||
libelf_uninitialize(&loadinfo);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
@ -55,4 +55,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -59,4 +59,4 @@ LDNXFLATFLAGS = -e main -s 2048
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -41,7 +41,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODULE
|
||||
# include <nuttx/lib/modlib.h>
|
||||
# include <nuttx/lib/elf.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
@ -102,7 +102,7 @@ int stm32_bringup(void)
|
||||
#ifdef HAVE_MODSYMS
|
||||
/* Install the module symbol table */
|
||||
|
||||
modlib_setsymtab(MODSYMS_SYMTAB_ARRAY, MODSYMS_NSYMBOLS_VAR);
|
||||
libelf_setsymtab(MODSYMS_SYMTAB_ARRAY, MODSYMS_NSYMBOLS_VAR);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
|
@ -211,7 +211,7 @@ set_property(
|
||||
TARGET nuttx
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_MODULE_LINK_OPTIONS -r -e module_initialize -T
|
||||
${NUTTX_DIR}/libs/libc/modlib/gnu-elf.ld)
|
||||
${NUTTX_DIR}/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
|
@ -47,4 +47,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -47,4 +47,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -47,4 +47,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -37,11 +37,11 @@ CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_TMPFS=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_LIBC_DLFCN=y
|
||||
CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT=64
|
||||
CONFIG_LIBC_ELF_SYMBOL_CACHECOUNT=64
|
||||
CONFIG_LIBC_ENVPATH=y
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_SPICLOCK=12500000
|
||||
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT=64
|
||||
CONFIG_MODLIB_SYMBOL_CACHECOUNT=64
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
|
@ -45,4 +45,4 @@ LDNXFLATFLAGS = -e main -s 2048
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
@ -46,8 +46,8 @@ CONFIG_IDLETHREAD_STACKSIZE=8192
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_DLFCN=y
|
||||
CONFIG_LIBC_ELF_DUMPBUFFER=y
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_MODLIB_DUMPBUFFER=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/cache.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
#include <nuttx/reboot_notifier.h>
|
||||
@ -608,7 +608,7 @@ int boardctl(unsigned int cmd, uintptr_t arg)
|
||||
(FAR const struct boardioc_symtab_s *)arg;
|
||||
|
||||
DEBUGASSERT(symdesc != NULL);
|
||||
modlib_setsymtab(symdesc->symtab, symdesc->nsymbols);
|
||||
libelf_setsymtab(symdesc->symtab, symdesc->nsymbols);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -56,7 +56,7 @@ CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(ARCHWARNINGSXX)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
|
||||
ASMEXT = .asm
|
||||
|
@ -56,7 +56,7 @@ CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(ARCHWARNINGSXX)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
|
||||
ASMEXT = .asm
|
||||
|
@ -56,7 +56,7 @@ CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(ARCHWARNINGSXX)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
|
||||
ASMEXT = .asm
|
||||
|
@ -56,7 +56,7 @@ CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(ARCHWARNINGSXX)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
CMODULEFLAGS = $(CFLAGS) -fvisibility=hidden -mlong-calls # --target1-abs
|
||||
|
||||
ASMEXT = .asm
|
||||
|
@ -31,10 +31,10 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
|
@ -32,10 +32,10 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_DLFCN=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
|
@ -57,7 +57,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
CMODULEFLAGS = $(CFLAGS)
|
||||
|
||||
LDMODULEFLAGS = -melf32lriscv -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -65,4 +65,4 @@ CELFFLAGS = $(CFLAGS)
|
||||
CXXELFFLAGS = $(CXXFLAGS)
|
||||
|
||||
LDELFFLAGS = -melf32lriscv -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -30,10 +30,10 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="elf_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ENVPATH=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_PATH_INITIAL="/mnt/romfs"
|
||||
CONFIG_PIPES=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
|
@ -30,11 +30,11 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="module_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ENVPATH=y
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_PATH_INITIAL="/mnt/romfs"
|
||||
CONFIG_PIPES=y
|
||||
|
@ -267,7 +267,7 @@ endif
|
||||
CMODULEFLAGS += -fno-stack-protector
|
||||
|
||||
LDMODULEFLAGS = -r
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
SHMODULEFLAGS = -shared -Bsymbolic -G -Bdynamic
|
||||
|
||||
# NuttX modules are ELF binaries.
|
||||
@ -293,7 +293,7 @@ ifeq ($(CONFIG_LIBC_ARCH_ELF_64BIT),y)
|
||||
endif
|
||||
|
||||
LDELFFLAGS = -r -e main --gc-sections
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
ifeq ($(CONFIG_HOST_MACOS),y)
|
||||
LDFLAGS += -Wl,-dead_strip
|
||||
|
@ -49,12 +49,12 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=8192
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=64
|
||||
CONFIG_LIBC_MEMSET_64BIT=y
|
||||
CONFIG_LIBC_MEMSET_OPTSPEED=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODLIB_BUFFERSIZE=64
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLEBG=y
|
||||
|
@ -39,12 +39,12 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=16384
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=64
|
||||
CONFIG_LIBC_MEMSET_64BIT=y
|
||||
CONFIG_LIBC_MEMSET_OPTSPEED=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODLIB_BUFFERSIZE=64
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLEBG=y
|
||||
|
@ -40,12 +40,12 @@ CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=16384
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_ELF_ALIGN_LOG2=3
|
||||
CONFIG_LIBC_ELF_BUFFERSIZE=64
|
||||
CONFIG_LIBC_MEMSET_64BIT=y
|
||||
CONFIG_LIBC_MEMSET_OPTSPEED=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MODLIB_ALIGN_LOG2=3
|
||||
CONFIG_MODLIB_BUFFERSIZE=64
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLEBG=y
|
||||
|
@ -61,7 +61,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
CMODULEFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -69,4 +69,4 @@ CELFFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)elf$(DELIM)gnu-elf.ld)
|
||||
|
@ -54,14 +54,14 @@ CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_INTERPRETER_CPYTHON=y
|
||||
CONFIG_IOB_NBUFFERS=124
|
||||
CONFIG_IOB_THROTTLE=24
|
||||
CONFIG_LIBC_ELF_HAVE_SYMTAB=y
|
||||
CONFIG_LIBC_ELF_SYSTEM_SYMTAB=y
|
||||
CONFIG_LIBC_EXECFUNCS=y
|
||||
CONFIG_LIBC_LOCALE=y
|
||||
CONFIG_LIBC_LOCALE_GETTEXT=y
|
||||
CONFIG_LIB_ZLIB=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_MODLIB_HAVE_SYMTAB=y
|
||||
CONFIG_MODLIB_SYSTEM_SYMTAB=y
|
||||
CONFIG_MODULE=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
|
@ -61,7 +61,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
CMODULEFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -69,4 +69,4 @@ CELFFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -61,7 +61,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
CMODULEFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
@ -69,4 +69,4 @@ CELFFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
|
||||
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/elf/gnu-elf.ld)
|
||||
|
@ -61,7 +61,7 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
CMODULEFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
||||
LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld)
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
|
@ -60,9 +60,9 @@ set(DEQUOTELIST
|
||||
"CONFIG_INIT_SYMTAB" # Global symbol table
|
||||
"CONFIG_INIT_NEXPORTS" # Global symbol table size
|
||||
"CONFIG_INIT_ENTRYPOINT" # Name of entry point function
|
||||
"CONFIG_MODLIB_SYMTAB_ARRAY" # Symbol table array used by modlib functions
|
||||
"CONFIG_MODLIB_NSYMBOLS_VAR" # Variable holding number of symbols in the
|
||||
# table
|
||||
"CONFIG_LIBC_ELF_SYMTAB_ARRAY" # Symbol table array used by elf functions
|
||||
"CONFIG_LIBC_ELF_NSYMBOLS_VAR" # Variable holding number of symbols in the
|
||||
# table
|
||||
"CONFIG_PASS1_BUILDIR" # Pass1 build directory
|
||||
"CONFIG_PASS1_TARGET" # Pass1 build target
|
||||
"CONFIG_PASS1_OBJECT" # Pass1 build object
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -69,7 +69,7 @@ struct binary_s
|
||||
main_t entrypt; /* Entry point into a program module */
|
||||
FAR void *mapped; /* Memory-mapped, address space */
|
||||
|
||||
#ifdef CONFIG_LIBC_MODLIB
|
||||
#ifdef CONFIG_LIBC_ELF
|
||||
struct module_s mod; /* Module context */
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/lib/modlib.h
|
||||
* include/nuttx/lib/elf.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -20,8 +20,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_LIB_MODLIB_H
|
||||
#define __INCLUDE_NUTTX_LIB_MODLIB_H
|
||||
#ifndef __INCLUDE_NUTTX_LIB_LIBC_ELF_H
|
||||
#define __INCLUDE_NUTTX_LIB_LIBC_ELF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@ -40,34 +40,34 @@
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_MODLIB_MAXDEPEND
|
||||
# define CONFIG_MODLIB_MAXDEPEND 0
|
||||
#ifndef CONFIG_LIBC_ELF_MAXDEPEND
|
||||
# define CONFIG_LIBC_ELF_MAXDEPEND 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MODLIB_ALIGN_LOG2
|
||||
# define CONFIG_MODLIB_ALIGN_LOG2 2
|
||||
#ifndef CONFIG_LIBC_ELF_ALIGN_LOG2
|
||||
# define CONFIG_LIBC_ELF_ALIGN_LOG2 2
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MODLIB_BUFFERSIZE
|
||||
# define CONFIG_MODLIB_BUFFERSIZE 32
|
||||
#ifndef CONFIG_LIBC_ELF_BUFFERSIZE
|
||||
# define CONFIG_LIBC_ELF_BUFFERSIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MODLIB_BUFFERINCR
|
||||
# define CONFIG_MODLIB_BUFFERINCR 32
|
||||
#ifndef CONFIG_LIBC_ELF_BUFFERINCR
|
||||
# define CONFIG_LIBC_ELF_BUFFERINCR 32
|
||||
#endif
|
||||
|
||||
/* CONFIG_DEBUG_INFO, and CONFIG_LIBC_MODLIB have to be defined or
|
||||
* CONFIG_MODLIB_DUMPBUFFER does nothing.
|
||||
/* CONFIG_DEBUG_INFO, and CONFIG_LIBC_ELF have to be defined or
|
||||
* CONFIG_LIBC_ELF_DUMPBUFFER does nothing.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined(CONFIG_LIBC_MODLIB)
|
||||
# undef CONFIG_MODLIB_DUMPBUFFER
|
||||
#if !defined(CONFIG_DEBUG_INFO) || !defined(CONFIG_LIBC_ELF)
|
||||
# undef CONFIG_LIBC_ELF_DUMPBUFFER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MODLIB_DUMPBUFFER
|
||||
# define modlib_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
|
||||
#ifdef CONFIG_LIBC_ELF_DUMPBUFFER
|
||||
# define libelf_dumpbuffer(m,b,n) sinfodumpbuffer(m,b,n)
|
||||
#else
|
||||
# define modlib_dumpbuffer(m,b,n)
|
||||
# define libelf_dumpbuffer(m,b,n)
|
||||
#endif
|
||||
|
||||
/* Module names. These are only used by the kernel module and will be
|
||||
@ -80,8 +80,8 @@
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# define HAVE_MODLIB_NAMES
|
||||
# define MODLIB_NAMEMAX NAME_MAX
|
||||
# define HAVE_LIBC_ELF_NAMES
|
||||
# define LIBC_ELF_NAMEMAX NAME_MAX
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -143,7 +143,7 @@ struct mod_info_s
|
||||
typedef CODE int (*mod_initializer_t)(FAR struct mod_info_s *modinfo);
|
||||
|
||||
/* This is the type of the callback function used by
|
||||
* modlib_registry_foreach()
|
||||
* libelf_registry_foreach()
|
||||
*/
|
||||
|
||||
struct module_s;
|
||||
@ -154,8 +154,8 @@ typedef CODE int (*mod_callback_t)(FAR struct module_s *modp, FAR void *arg);
|
||||
struct module_s
|
||||
{
|
||||
FAR struct module_s *flink; /* Supports a singly linked list */
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
char modname[MODLIB_NAMEMAX]; /* Module name */
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
char modname[LIBC_ELF_NAMEMAX]; /* Module name */
|
||||
#endif
|
||||
struct mod_info_s modinfo; /* Module information */
|
||||
FAR void *textalloc; /* Allocated kernel text memory */
|
||||
@ -174,14 +174,14 @@ struct module_s
|
||||
size_t datasize; /* Size of the kernel .bss/.data memory allocation */
|
||||
#endif
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
uint8_t dependents; /* Number of modules that depend on this module */
|
||||
|
||||
/* This is an upacked array of pointers to other modules that this module
|
||||
* depends upon.
|
||||
*/
|
||||
|
||||
FAR struct module_s *dependencies[CONFIG_MODLIB_MAXDEPEND];
|
||||
FAR struct module_s *dependencies[CONFIG_LIBC_ELF_MAXDEPEND];
|
||||
#endif
|
||||
uintptr_t initarr; /* .init_array */
|
||||
uint16_t ninit; /* Number of entries in .init_array */
|
||||
@ -262,7 +262,7 @@ struct mod_loadinfo_s
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_initialize
|
||||
* Name: libelf_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called to configure the library to process an kernel
|
||||
@ -274,15 +274,15 @@ struct mod_loadinfo_s
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_initialize(FAR const char *filename,
|
||||
int libelf_initialize(FAR const char *filename,
|
||||
FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_uninitialize
|
||||
* Name: libelf_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Releases any resources committed by modlib_initialize(). This
|
||||
* essentially undoes the actions of modlib_initialize.
|
||||
* Releases any resources committed by libelf_initialize(). This
|
||||
* essentially undoes the actions of libelf_initialize.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
@ -290,10 +290,10 @@ int modlib_initialize(FAR const char *filename,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_uninitialize(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_getsymtab
|
||||
* Name: libelf_getsymtab
|
||||
*
|
||||
* Description:
|
||||
* Get the current symbol table selection as an atomic operation.
|
||||
@ -308,10 +308,10 @@ int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
||||
void libelf_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_setsymtab
|
||||
* Name: libelf_setsymtab
|
||||
*
|
||||
* Description:
|
||||
* Select a new symbol table selection as an atomic operation.
|
||||
@ -325,10 +325,10 @@ void modlib_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
||||
void libelf_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_load
|
||||
* Name: libelf_load
|
||||
*
|
||||
* Description:
|
||||
* Loads the binary into memory, allocating memory, performing relocations
|
||||
@ -340,10 +340,10 @@ void modlib_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_load(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_load(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_load_with_addrenv
|
||||
* Name: libelf_load_with_addrenv
|
||||
*
|
||||
* Description:
|
||||
* Loads the binary into memory, use the address environment to load the
|
||||
@ -356,18 +356,18 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo);
|
||||
#else
|
||||
# define modlib_load_with_addrenv(l) modlib_load(l)
|
||||
# define libelf_load_with_addrenv(l) libelf_load(l)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_bind
|
||||
* Name: libelf_bind
|
||||
*
|
||||
* Description:
|
||||
* Bind the imported symbol names in the loaded module described by
|
||||
* 'loadinfo' using the exported symbol values provided by
|
||||
* modlib_setsymtab().
|
||||
* libelf_setsymtab().
|
||||
*
|
||||
* Input Parameters:
|
||||
* modp - Module state information
|
||||
@ -381,16 +381,16 @@ int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_bind(FAR struct module_s *modp,
|
||||
int libelf_bind(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const struct symtab_s *exports, int nexports);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_unload
|
||||
* Name: libelf_unload
|
||||
*
|
||||
* Description:
|
||||
* This function unloads the object from memory. This essentially undoes
|
||||
* the actions of modlib_load. It is called only under certain error
|
||||
* the actions of libelf_load. It is called only under certain error
|
||||
* conditions after the module has been loaded but not yet started.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -403,10 +403,10 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_unload(struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_unload(struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_depend
|
||||
* Name: libelf_depend
|
||||
*
|
||||
* Description:
|
||||
* Set up module dependencies between the exporter and the importer of a
|
||||
@ -422,13 +422,13 @@ int modlib_unload(struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
int modlib_depend(FAR struct module_s *importer,
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
int libelf_depend(FAR struct module_s *importer,
|
||||
FAR struct module_s *exporter);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_undepend
|
||||
* Name: libelf_undepend
|
||||
*
|
||||
* Description:
|
||||
* Tear down module dependencies between the exporters and the importer of
|
||||
@ -444,12 +444,12 @@ int modlib_depend(FAR struct module_s *importer,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
int modlib_undepend(FAR struct module_s *importer);
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
int libelf_undepend(FAR struct module_s *importer);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_read
|
||||
* Name: libelf_read
|
||||
*
|
||||
* Description:
|
||||
* Read 'readsize' bytes from the object file at 'offset'. The data is
|
||||
@ -461,11 +461,11 @@ int modlib_undepend(FAR struct module_s *importer);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
|
||||
int libelf_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
|
||||
size_t readsize, off_t offset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_findsection
|
||||
* Name: libelf_findsection
|
||||
*
|
||||
* Description:
|
||||
* A section by its name.
|
||||
@ -480,11 +480,11 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_findsection(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const char *sectname);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_lock
|
||||
* Name: libelf_registry_lock
|
||||
*
|
||||
* Description:
|
||||
* Get exclusive access to the module registry.
|
||||
@ -497,10 +497,10 @@ int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_registry_lock(void);
|
||||
void libelf_registry_lock(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_unlock
|
||||
* Name: libelf_registry_unlock
|
||||
*
|
||||
* Description:
|
||||
* Relinquish the lock on the module registry
|
||||
@ -513,10 +513,10 @@ void modlib_registry_lock(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_registry_unlock(void);
|
||||
void libelf_registry_unlock(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_add
|
||||
* Name: libelf_registry_add
|
||||
*
|
||||
* Description:
|
||||
* Add a new entry to the module registry.
|
||||
@ -532,10 +532,10 @@ void modlib_registry_unlock(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_registry_add(FAR struct module_s *modp);
|
||||
void libelf_registry_add(FAR struct module_s *modp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_del
|
||||
* Name: libelf_registry_del
|
||||
*
|
||||
* Description:
|
||||
* Remove a module entry from the registry
|
||||
@ -552,10 +552,10 @@ void modlib_registry_add(FAR struct module_s *modp);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_registry_del(FAR struct module_s *modp);
|
||||
int libelf_registry_del(FAR struct module_s *modp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_find
|
||||
* Name: libelf_registry_find
|
||||
*
|
||||
* Description:
|
||||
* Find an entry in the module registry using the name of the module.
|
||||
@ -572,12 +572,12 @@ int modlib_registry_del(FAR struct module_s *modp);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
FAR struct module_s *modlib_registry_find(FAR const char *modname);
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
FAR struct module_s *libelf_registry_find(FAR const char *modname);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_verify
|
||||
* Name: libelf_registry_verify
|
||||
*
|
||||
* Description:
|
||||
* Verify that a module handle is valid by traversing the module list and
|
||||
@ -595,10 +595,10 @@ FAR struct module_s *modlib_registry_find(FAR const char *modname);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_registry_verify(FAR struct module_s *modp);
|
||||
int libelf_registry_verify(FAR struct module_s *modp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_registry_foreach
|
||||
* Name: libelf_registry_foreach
|
||||
*
|
||||
* Description:
|
||||
* Visit each module in the registry. This is an internal OS interface and
|
||||
@ -619,10 +619,10 @@ int modlib_registry_verify(FAR struct module_s *modp);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_registry_foreach(mod_callback_t callback, FAR void *arg);
|
||||
int libelf_registry_foreach(mod_callback_t callback, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_freesymtab
|
||||
* Name: libelf_freesymtab
|
||||
*
|
||||
* Description:
|
||||
* Free a symbol table for the current module.
|
||||
@ -632,10 +632,10 @@ int modlib_registry_foreach(mod_callback_t callback, FAR void *arg);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_freesymtab(FAR struct module_s *modp);
|
||||
void libelf_freesymtab(FAR struct module_s *modp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_dumploadinfo
|
||||
* Name: libelf_dumploadinfo
|
||||
*
|
||||
* Description:
|
||||
* Dump the load information to debug output.
|
||||
@ -643,39 +643,39 @@ void modlib_freesymtab(FAR struct module_s *modp);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_BINFMT_INFO
|
||||
void modlib_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo);
|
||||
void libelf_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo);
|
||||
#else
|
||||
# define modlib_dumploadinfo(i)
|
||||
# define libelf_dumploadinfo(i)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_dumpmodule
|
||||
* Name: libelf_dumpmodule
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_BINFMT_INFO
|
||||
void modlib_dumpmodule(FAR struct module_s *modp);
|
||||
void libelf_dumpmodule(FAR struct module_s *modp);
|
||||
#else
|
||||
# define modlib_dumpmodule(m)
|
||||
# define libelf_dumpmodule(m)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: elf_dumpentrypt
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MODLIB_DUMPBUFFER
|
||||
void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo);
|
||||
#ifdef CONFIG_LIBC_ELF_DUMPBUFFER
|
||||
void libelf_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo);
|
||||
#else
|
||||
# define modlib_dumpentrypt(l)
|
||||
# define libelf_dumpentrypt(l)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_insert
|
||||
* Name: libelf_insert
|
||||
*
|
||||
* Description:
|
||||
* Verify that the file is an ELF module binary and, if so, load the
|
||||
* module into kernel memory and initialize it for use.
|
||||
*
|
||||
* NOTE: modlib_setsymtab() had to have been called in board-specific OS
|
||||
* NOTE: libelf_setsymtab() had to have been called in board-specific OS
|
||||
* logic prior to calling this function from application logic (perhaps via
|
||||
* boardctl(BOARDIOC_OS_SYMTAB). Otherwise, insmod will be unable to
|
||||
* resolve symbols in the OS module.
|
||||
@ -688,37 +688,37 @@ void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL module handle that can be used on subsequent calls to other
|
||||
* module interfaces is returned on success. If modlib_insert() was
|
||||
* unable to load the module modlib_insert() will return a NULL handle
|
||||
* module interfaces is returned on success. If libelf_insert() was
|
||||
* unable to load the module libelf_insert() will return a NULL handle
|
||||
* and the errno variable will be set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *modlib_insert(FAR const char *filename, FAR const char *modname);
|
||||
FAR void *libelf_insert(FAR const char *filename, FAR const char *modname);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_getsymbol
|
||||
* Name: libelf_getsymbol
|
||||
*
|
||||
* Description:
|
||||
* modlib_getsymbol() returns the address of a symbol defined within the
|
||||
* object that was previously made accessible through a modlib_getsymbol()
|
||||
* call. handle is the value returned from a call to modlib_insert() (and
|
||||
* which has not since been released via a call to modlib_remove()),
|
||||
* libelf_getsymbol() returns the address of a symbol defined within the
|
||||
* object that was previously made accessible through a libelf_getsymbol()
|
||||
* call. handle is the value returned from a call to libelf_insert() (and
|
||||
* which has not since been released via a call to libelf_remove()),
|
||||
* name is the symbol's name as a character string.
|
||||
*
|
||||
* The returned symbol address will remain valid until modlib_remove() is
|
||||
* The returned symbol address will remain valid until libelf_remove() is
|
||||
* called.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The opaque, non-NULL value returned by a previous successful
|
||||
* call to modlib_insert().
|
||||
* call to libelf_insert().
|
||||
* name - A pointer to the symbol name string.
|
||||
*
|
||||
* Returned Value:
|
||||
* The address associated with the symbol is returned on success.
|
||||
* If handle does not refer to a valid module opened by modlib_insert(),
|
||||
* or if the named modlib_symbol cannot be found within any of the objects
|
||||
* associated with handle, modlib_getsymbol() will return NULL and the
|
||||
* If handle does not refer to a valid module opened by libelf_insert(),
|
||||
* or if the named libelf_symbol cannot be found within any of the objects
|
||||
* associated with handle, libelf_getsymbol() will return NULL and the
|
||||
* errno variable will be set appropriately.
|
||||
*
|
||||
* NOTE: This means that the address zero can never be a valid return
|
||||
@ -726,26 +726,26 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR const void *modlib_getsymbol(FAR void *handle, FAR const char *name);
|
||||
FAR const void *libelf_getsymbol(FAR void *handle, FAR const char *name);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_uninit
|
||||
* Name: libelf_uninit
|
||||
*
|
||||
* Description:
|
||||
* Uninitialize module resources.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_uninit(FAR struct module_s *modp);
|
||||
int libelf_uninit(FAR struct module_s *modp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_remove
|
||||
* Name: libelf_remove
|
||||
*
|
||||
* Description:
|
||||
* Remove a previously installed module from memory.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The module handler previously returned by modlib_insert().
|
||||
* handle - The module handler previously returned by libelf_insert().
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. On any failure, -1 (ERROR) is returned the
|
||||
@ -753,13 +753,13 @@ int modlib_uninit(FAR struct module_s *modp);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_remove(FAR void *handle);
|
||||
int libelf_remove(FAR void *handle);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_modhandle
|
||||
* Name: libelf_modhandle
|
||||
*
|
||||
* Description:
|
||||
* modlib_modhandle() returns the module handle for the installed
|
||||
* libelf_modhandle() returns the module handle for the installed
|
||||
* module with the provided name. A secondary use of this function is to
|
||||
* determine if a module has been loaded or not.
|
||||
*
|
||||
@ -767,17 +767,17 @@ int modlib_remove(FAR void *handle);
|
||||
* name - A pointer to the module name string.
|
||||
*
|
||||
* Returned Value:
|
||||
* The non-NULL module handle previously returned by modlib_insert() is
|
||||
* The non-NULL module handle previously returned by libelf_insert() is
|
||||
* returned on success. If no module with that name is installed,
|
||||
* modlib_modhandle() will return a NULL handle and the errno variable
|
||||
* libelf_modhandle() will return a NULL handle and the errno variable
|
||||
* will be set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
FAR void *modlib_gethandle(FAR const char *name);
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
FAR void *libelf_gethandle(FAR const char *name);
|
||||
#else
|
||||
# define modlib_gethandle(n) NULL
|
||||
# define libelf_gethandle(n) NULL
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_LIB_MODLIB_H */
|
||||
#endif /* __INCLUDE_NUTTX_LIB_LIBC_ELF_H */
|
@ -52,7 +52,7 @@ extern "C"
|
||||
* module into kernel memory and initialize it for use.
|
||||
*
|
||||
* NOTE:
|
||||
* modlib_setsymtab had to have been called in board-specific OS logic
|
||||
* libelf_setsymtab had to have been called in board-specific OS logic
|
||||
* prior to calling this function from application logic (perhaps via
|
||||
* boardctl(BOARDIOC_OS_SYMTAB). Otherwise, insmod will be unable to
|
||||
* resolve symbols in the OS module.
|
||||
|
4
libs/libc/.gitignore
vendored
4
libs/libc/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
/exec_symtab.c
|
||||
/modlib_symtab.c
|
||||
modlib/gnu-elf.ld
|
||||
/elf_symtab.c
|
||||
elf/gnu-elf.ld
|
||||
|
@ -13,7 +13,7 @@ source "libs/libc/unistd/Kconfig"
|
||||
source "libs/libc/string/Kconfig"
|
||||
source "libs/libc/pthread/Kconfig"
|
||||
source "libs/libc/dlfcn/Kconfig"
|
||||
source "libs/libc/modlib/Kconfig"
|
||||
source "libs/libc/elf/Kconfig"
|
||||
source "libs/libc/gdbstub/Kconfig"
|
||||
source "libs/libc/grp/Kconfig"
|
||||
source "libs/libc/pwd/Kconfig"
|
||||
|
@ -42,7 +42,7 @@ include locale/Make.defs
|
||||
include lzf/Make.defs
|
||||
include machine/Make.defs
|
||||
include misc/Make.defs
|
||||
include modlib/Make.defs
|
||||
include elf/Make.defs
|
||||
include net/Make.defs
|
||||
include netdb/Make.defs
|
||||
include obstack/Make.defs
|
||||
@ -122,14 +122,14 @@ CSRCS += exec_symtab.c
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MODLIB_SYSTEM_SYMTAB),y)
|
||||
ifeq ($(CONFIG_LIBC_ELF_SYSTEM_SYMTAB),y)
|
||||
|
||||
modlib_sys_symtab.c : $(CSVFILES) $(MKSYMTAB)
|
||||
elf_sys_symtab.c : $(CSVFILES) $(MKSYMTAB)
|
||||
$(Q) cat $(CSVFILES) | LC_ALL=C sort >$@.csv
|
||||
$(Q) $(MKSYMTAB) $@.csv $@ $(CONFIG_MODLIB_SYMTAB_ARRAY) $(CONFIG_MODLIB_NSYMBOLS_VAR)
|
||||
$(Q) $(MKSYMTAB) $@.csv $@ $(CONFIG_LIBC_ELF_SYMTAB_ARRAY) $(CONFIG_LIBC_ELF_NSYMBOLS_VAR)
|
||||
$(Q) rm -f $@.csv
|
||||
|
||||
CSRCS += modlib_sys_symtab.c
|
||||
CSRCS += elf_sys_symtab.c
|
||||
|
||||
endif
|
||||
|
||||
@ -183,8 +183,8 @@ context:: bin kbin
|
||||
ifeq ($(CONFIG_LIBC_ZONEINFO_ROMFS),y)
|
||||
$(Q) $(MAKE) -C zoneinfo context BIN=$(BIN)
|
||||
endif
|
||||
ifeq ($(CONFIG_LIBC_MODLIB),y)
|
||||
$(Q) $(MAKE) -C modlib context
|
||||
ifeq ($(CONFIG_LIBC_ELF),y)
|
||||
$(Q) $(MAKE) -C elf context
|
||||
endif
|
||||
|
||||
|
||||
@ -214,7 +214,7 @@ depend:: .depend
|
||||
|
||||
clean::
|
||||
$(Q) $(MAKE) -C zoneinfo clean BIN=$(BIN)
|
||||
$(Q) $(MAKE) -C modlib clean
|
||||
$(Q) $(MAKE) -C elf clean
|
||||
$(call DELFILE, $(BIN))
|
||||
$(call DELFILE, $(KBIN))
|
||||
$(call CLEAN)
|
||||
@ -223,7 +223,7 @@ clean::
|
||||
|
||||
distclean:: clean
|
||||
$(Q) $(MAKE) -C zoneinfo distclean BIN=$(BIN)
|
||||
$(Q) $(MAKE) -C modlib distclean
|
||||
$(Q) $(MAKE) -C elf distclean
|
||||
$(call DELFILE, exec_symtab.c)
|
||||
$(call DELFILE, .depend)
|
||||
$(call DELDIR, bin)
|
||||
|
@ -9,7 +9,7 @@ config LIBC_DLFCN
|
||||
bool "Shared library support"
|
||||
default n
|
||||
select MODULES
|
||||
select LIBC_MODLIB if !BUILD_FLAT
|
||||
select LIBC_ELF if !BUILD_FLAT
|
||||
select MODULE if BUILD_FLAT
|
||||
---help---
|
||||
Enabled support for user-space shared libraries.
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -93,7 +93,7 @@ int dlclose(FAR void *handle)
|
||||
* dlremove() is essentially a clone of rmmod().
|
||||
*/
|
||||
|
||||
return modlib_remove(handle);
|
||||
return libelf_remove(handle);
|
||||
|
||||
#else /* if defined(CONFIG_BUILD_KERNEL) */
|
||||
/* The KERNEL build is considerably more complex: In order to be shared,
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <nuttx/envpath.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/lib/lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
@ -48,7 +48,7 @@
|
||||
* Verify that the file is an ELF module binary and, if so, load the
|
||||
* shared library into user memory and initialize it for use.
|
||||
*
|
||||
* NOTE: modlib_setsymtab() had to have been called by application logic
|
||||
* NOTE: libelf_setsymtab() had to have been called by application logic
|
||||
* logic prior to calling this. Otherwise, dlinsert will be unable to
|
||||
* resolve symbols in the OS module.
|
||||
*
|
||||
@ -97,7 +97,7 @@ static inline FAR void *dlinsert(FAR const char *filename)
|
||||
* name.
|
||||
*/
|
||||
|
||||
handle = modlib_insert(filename, basename(name));
|
||||
handle = libelf_insert(filename, basename(name));
|
||||
lib_free(name);
|
||||
return handle;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
@ -87,7 +87,7 @@ FAR void *dlsym(FAR void *handle, FAR const char *name)
|
||||
* dlgetsem() is essentially a clone of modsym().
|
||||
*/
|
||||
|
||||
return (FAR void *)modlib_getsymbol(handle, name);
|
||||
return (FAR void *)libelf_getsymbol(handle, name);
|
||||
|
||||
#else /* if defined(CONFIG_BUILD_KERNEL) */
|
||||
/* The KERNEL build is considerably more complex: In order to be shared,
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -73,7 +73,7 @@ int dlsymtab(FAR const struct symtab_s *symtab, int nsymbols)
|
||||
* the module library.
|
||||
*/
|
||||
|
||||
modlib_setsymtab(symtab, nsymbols);
|
||||
libelf_setsymtab(symtab, nsymbols);
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# ##############################################################################
|
||||
# libs/libc/modlib/CMakeLists.txt
|
||||
# libs/libc/elf/CMakeLists.txt
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -20,32 +20,32 @@
|
||||
#
|
||||
# ##############################################################################
|
||||
|
||||
if(CONFIG_LIBC_MODLIB)
|
||||
if(CONFIG_LIBC_ELF)
|
||||
|
||||
list(
|
||||
APPEND
|
||||
SRCS
|
||||
modlib_addrenv.c
|
||||
modlib_bind.c
|
||||
modlib_depend.c
|
||||
modlib_init.c
|
||||
modlib_iobuffer.c
|
||||
modlib_load.c
|
||||
modlib_loadhdrs.c
|
||||
modlib_verify.c
|
||||
modlib_read.c
|
||||
modlib_registry.c
|
||||
modlib_sections.c
|
||||
modlib_symbols.c
|
||||
modlib_symtab.c
|
||||
modlib_uninit.c
|
||||
modlib_unload.c
|
||||
modlib_gethandle.c
|
||||
modlib_getsymbol.c
|
||||
modlib_insert.c
|
||||
modlib_remove.c)
|
||||
elf_addrenv.c
|
||||
elf_bind.c
|
||||
elf_depend.c
|
||||
elf_init.c
|
||||
elf_iobuffer.c
|
||||
elf_load.c
|
||||
elf_loadhdrs.c
|
||||
elf_verify.c
|
||||
elf_read.c
|
||||
elf_registry.c
|
||||
elf_sections.c
|
||||
elf_symbols.c
|
||||
elf_symtab.c
|
||||
elf_uninit.c
|
||||
elf_unload.c
|
||||
elf_gethandle.c
|
||||
elf_getsymbol.c
|
||||
elf_insert.c
|
||||
elf_remove.c)
|
||||
|
||||
list(APPEND SRCS modlib_globals.S)
|
||||
list(APPEND SRCS elf_globals.S)
|
||||
|
||||
target_sources(c PRIVATE ${SRCS})
|
||||
|
@ -3,16 +3,16 @@
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config LIBC_MODLIB
|
||||
config LIBC_ELF
|
||||
bool "Enable module library"
|
||||
default n
|
||||
select LIBC_ARCH_ELF
|
||||
select ARCH_USE_TEXT_HEAP if ARCH_HAVE_TEXT_HEAP
|
||||
|
||||
menu "Module library configuration"
|
||||
depends on LIBC_MODLIB
|
||||
depends on LIBC_ELF
|
||||
|
||||
config MODLIB_MAXDEPEND
|
||||
config LIBC_ELF_MAXDEPEND
|
||||
int "Max dependencies"
|
||||
default 2
|
||||
---help---
|
||||
@ -24,16 +24,16 @@ config MODLIB_MAXDEPEND
|
||||
current design because it uses some very simple, pre-allocated data
|
||||
structures.
|
||||
|
||||
All dependencies logic my be eliminated by set CONFIG_MODLIB_MAXDEPEND
|
||||
All dependencies logic my be eliminated by set CONFIG_LIBC_ELF_MAXDEPEND
|
||||
to zero.
|
||||
|
||||
config MODLIB_ALIGN_LOG2
|
||||
config LIBC_ELF_ALIGN_LOG2
|
||||
int "Log2 Section Alignment"
|
||||
default 2
|
||||
---help---
|
||||
Align all sections to this Log2 value: 0->1, 1->2, 2->4, etc.
|
||||
|
||||
config MODLIB_BUFFERSIZE
|
||||
config LIBC_ELF_BUFFERSIZE
|
||||
int "Module I/O Buffer Size"
|
||||
default 32
|
||||
---help---
|
||||
@ -42,7 +42,7 @@ config MODLIB_BUFFERSIZE
|
||||
This is really just this initial size of the buffer; it will be
|
||||
reallocated as necessary to hold large symbol names). Default: 32
|
||||
|
||||
config MODLIB_BUFFERINCR
|
||||
config LIBC_ELF_BUFFERINCR
|
||||
int "Module I/O Buffer Realloc Increment"
|
||||
default 32
|
||||
---help---
|
||||
@ -51,14 +51,14 @@ config MODLIB_BUFFERINCR
|
||||
This value specifies the size increment to use each time the
|
||||
buffer is reallocated. Default: 32
|
||||
|
||||
config MODLIB_DUMPBUFFER
|
||||
config LIBC_ELF_DUMPBUFFER
|
||||
bool "Dump module buffers"
|
||||
default n
|
||||
depends on DEBUG_INFO
|
||||
---help---
|
||||
Dump various module buffers for debug purposes
|
||||
|
||||
config MODLIB_HAVE_SYMTAB
|
||||
config LIBC_ELF_HAVE_SYMTAB
|
||||
bool "Have symbol table"
|
||||
default n
|
||||
---help---
|
||||
@ -66,47 +66,47 @@ config MODLIB_HAVE_SYMTAB
|
||||
option in order to use it. Symbol tables are required in most
|
||||
cases in order to link executable programs to the base code.
|
||||
|
||||
config MODLIB_RELOCATION_BUFFERCOUNT
|
||||
int "MODLIB Relocation Table Buffer Count"
|
||||
config LIBC_ELF_RELOCATION_BUFFERCOUNT
|
||||
int "LIBELF Relocation Table Buffer Count"
|
||||
default 256
|
||||
---help---
|
||||
This is an cache buffer that is used to store elf relocation table to
|
||||
reduce access fs. Default: 256
|
||||
|
||||
config MODLIB_SYMBOL_CACHECOUNT
|
||||
int "MODLIB SYMBOL Table Cache Count"
|
||||
config LIBC_ELF_SYMBOL_CACHECOUNT
|
||||
int "LIBELF SYMBOL Table Cache Count"
|
||||
default 256
|
||||
---help---
|
||||
This is an cache that is used to store elf symbol table to
|
||||
reduce access fs. Default: 256
|
||||
|
||||
if MODLIB_HAVE_SYMTAB
|
||||
if LIBC_ELF_HAVE_SYMTAB
|
||||
|
||||
config MODLIB_SYMTAB_ARRAY
|
||||
config LIBC_ELF_SYMTAB_ARRAY
|
||||
string "Symbol table name used by dlsym"
|
||||
default "g_mod_symtab" if !EXECFUNCS_HAVE_SYMTAB
|
||||
default EXECFUNCS_SYMTAB_ARRAY if EXECFUNCS_HAVE_SYMTAB
|
||||
|
||||
config MODLIB_NSYMBOLS_VAR
|
||||
config LIBC_ELF_NSYMBOLS_VAR
|
||||
string "Name of variable holding the number of symbols"
|
||||
default "g_mod_nsymbols" if !EXECFUNCS_HAVE_SYMTAB
|
||||
default EXECFUNCS_NSYMBOLS_VAR if EXECFUNCS_HAVE_SYMTAB
|
||||
|
||||
config MODLIB_SYSTEM_SYMTAB
|
||||
config LIBC_ELF_SYSTEM_SYMTAB
|
||||
bool "Generate the system symbol table"
|
||||
default n
|
||||
|
||||
endif # MODLIB_HAVE_SYMTAB
|
||||
endif # LIBC_ELF_HAVE_SYMTAB
|
||||
|
||||
config MODLIB_LOADTO_LMA
|
||||
bool "modlib load sections to LMA"
|
||||
config LIBC_ELF_LOADTO_LMA
|
||||
bool "elf load sections to LMA"
|
||||
default n
|
||||
---help---
|
||||
Load all section to LMA not VMA, so the startup code(e.g. start.S) need
|
||||
relocate .data section to the final address(VMA) and zero .bss section
|
||||
by self.
|
||||
|
||||
config MODLIB_EXIDX_SECTNAME
|
||||
config LIBC_ELF_EXIDX_SECTNAME
|
||||
string "ELF Section Name for Exception Index"
|
||||
default ".ARM.exidx"
|
||||
depends on CXX_EXCEPTION && ARCH_ARM
|
@ -1,5 +1,5 @@
|
||||
############################################################################
|
||||
# libs/libc/modlib/Make.defs
|
||||
# libs/libc/elf/Make.defs
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -20,22 +20,22 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_LIBC_MODLIB),y)
|
||||
ifeq ($(CONFIG_LIBC_ELF),y)
|
||||
|
||||
# Add the nuttx/lib/modlib.h files to the build
|
||||
# Add the nuttx/lib/elf.h files to the build
|
||||
|
||||
CSRCS += modlib_addrenv.c modlib_bind.c modlib_depend.c modlib_init.c
|
||||
CSRCS += modlib_iobuffer.c modlib_load.c modlib_loadhdrs.c modlib_verify.c
|
||||
CSRCS += modlib_read.c modlib_registry.c modlib_sections.c
|
||||
CSRCS += modlib_symbols.c modlib_symtab.c modlib_uninit.c modlib_unload.c
|
||||
CSRCS += modlib_gethandle.c modlib_getsymbol.c modlib_insert.c
|
||||
CSRCS += modlib_remove.c
|
||||
CSRCS += elf_addrenv.c elf_bind.c elf_depend.c elf_init.c
|
||||
CSRCS += elf_iobuffer.c elf_load.c elf_loadhdrs.c elf_verify.c
|
||||
CSRCS += elf_read.c elf_registry.c elf_sections.c
|
||||
CSRCS += elf_symbols.c elf_symtab.c elf_uninit.c elf_unload.c
|
||||
CSRCS += elf_gethandle.c elf_getsymbol.c elf_insert.c
|
||||
CSRCS += elf_remove.c
|
||||
|
||||
# Add the modlib directory to the build
|
||||
# Add the elf directory to the build
|
||||
|
||||
ASRCS += modlib_globals.S
|
||||
ASRCS += elf_globals.S
|
||||
|
||||
DEPPATH += --dep-path modlib
|
||||
VPATH += :modlib
|
||||
DEPPATH += --dep-path elf
|
||||
VPATH += :elf
|
||||
|
||||
endif
|
@ -1,5 +1,5 @@
|
||||
############################################################################
|
||||
# libs/libc/modlib/Makefile
|
||||
# libs/libc/elf/Makefile
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib.h
|
||||
* libs/libc/elf/elf.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -20,22 +20,22 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __LIBS_LIBC_MODLIB_MODLIB_H
|
||||
#define __LIBS_LIBC_MODLIB_MODLIB_H
|
||||
#ifndef __LIBS_LIBC_LIBC_ELF_LIBC_ELF_H
|
||||
#define __LIBS_LIBC_LIBC_ELF_LIBC_ELF_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/addrenv.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_verifyheader
|
||||
* Name: libelf_verifyheader
|
||||
*
|
||||
* Description:
|
||||
* Given the header from a possible ELF executable, verify that it is
|
||||
@ -47,10 +47,10 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_verifyheader(FAR const Elf_Ehdr *header);
|
||||
int libelf_verifyheader(FAR const Elf_Ehdr *header);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_findsymtab
|
||||
* Name: libelf_findsymtab
|
||||
*
|
||||
* Description:
|
||||
* Find the symbol table section.
|
||||
@ -61,10 +61,10 @@ int modlib_verifyheader(FAR const Elf_Ehdr *header);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_findsymtab(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_readsym
|
||||
* Name: libelf_readsym
|
||||
*
|
||||
* Description:
|
||||
* Read the ELF symbol structure at the specified index into memory.
|
||||
@ -80,11 +80,11 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
|
||||
int libelf_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
|
||||
FAR Elf_Sym *sym, FAR Elf_Shdr *shdr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_symvalue
|
||||
* Name: libelf_symvalue
|
||||
*
|
||||
* Description:
|
||||
* Get the value of a symbol. The updated value of the symbol is returned
|
||||
@ -110,13 +110,13 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_symvalue(FAR struct module_s *modp,
|
||||
int libelf_symvalue(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo, FAR Elf_Sym *sym,
|
||||
Elf_Off sh_offset,
|
||||
FAR const struct symtab_s *exports, int nexports);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_insertsymtab
|
||||
* Name: libelf_insertsymtab
|
||||
*
|
||||
* Description:
|
||||
* Insert a symbol table for the current module.
|
||||
@ -135,13 +135,13 @@ int modlib_symvalue(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_insertsymtab(FAR struct module_s *modp,
|
||||
int libelf_insertsymtab(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR Elf_Shdr *shdr,
|
||||
FAR Elf_Sym *sym);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_findglobal
|
||||
* Name: libelf_findglobal
|
||||
*
|
||||
* Description:
|
||||
* Find a symbol in the global symbol table
|
||||
@ -160,13 +160,13 @@ int modlib_insertsymtab(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void *modlib_findglobal(FAR struct module_s *modp,
|
||||
void *libelf_findglobal(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR Elf_Shdr *shdr,
|
||||
FAR Elf_Sym *sym);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_loadhdrs
|
||||
* Name: libelf_loadhdrs
|
||||
*
|
||||
* Description:
|
||||
* Loads program and section headers into memory.
|
||||
@ -177,10 +177,10 @@ void *modlib_findglobal(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_loadhdrs(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_sectname
|
||||
* Name: libelf_sectname
|
||||
*
|
||||
* Description:
|
||||
* Get the symbol name in loadinfo->iobuffer[].
|
||||
@ -191,11 +191,11 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_sectname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const Elf_Shdr *shdr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_allocbuffer
|
||||
* Name: libelf_allocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Perform the initial allocation of the I/O buffer, if it has not already
|
||||
@ -207,10 +207,10 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_allocbuffer(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_reallocbuffer
|
||||
* Name: libelf_reallocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Increase the size of I/O buffer by the specified buffer increment.
|
||||
@ -221,11 +221,11 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
|
||||
size_t increment);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_freebuffers
|
||||
* Name: libelf_freebuffers
|
||||
*
|
||||
* Description:
|
||||
* Release all working buffers.
|
||||
@ -236,12 +236,12 @@ int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_freebuffers(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_freebuffers(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_alloc
|
||||
* Name: libelf_addrenv_alloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate memory for the ELF image (textalloc and datastart). If
|
||||
@ -264,11 +264,11 @@ int modlib_freebuffers(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_addrenv_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
size_t textsize, size_t datasize);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_select
|
||||
* Name: libelf_addrenv_select
|
||||
*
|
||||
* Description:
|
||||
* Temporarily select the task's address environment.
|
||||
@ -281,13 +281,13 @@ int modlib_addrenv_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_select(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_addrenv_select(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_restore
|
||||
* Name: libelf_addrenv_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore the address environment before modlib_addrenv_select() was
|
||||
* Restore the address environment before libelf_addrenv_select() was
|
||||
* called.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -298,14 +298,14 @@ int modlib_addrenv_select(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo);
|
||||
int libelf_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_free
|
||||
* Name: libelf_addrenv_free
|
||||
*
|
||||
* Description:
|
||||
* Release the address environment previously created by
|
||||
* modlib_addrenv_alloc(). This function is called only under certain
|
||||
* libelf_addrenv_alloc(). This function is called only under certain
|
||||
* error conditions after the module has been loaded but not yet started.
|
||||
* After the module has been started, the address environment will
|
||||
* automatically be freed when the module exits.
|
||||
@ -318,7 +318,7 @@ int modlib_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_addrenv_free(FAR struct mod_loadinfo_s *loadinfo);
|
||||
void libelf_addrenv_free(FAR struct mod_loadinfo_s *loadinfo);
|
||||
|
||||
#endif /* CONFIG_ARCH_ADDRENV */
|
||||
#endif /* __LIBS_LIBC_MODLIB_MODLIB_H */
|
||||
#endif /* __LIBS_LIBC_LIBC_ELF_LIBC_ELF_H */
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_addrenv.c
|
||||
* libs/libc/elf/elf_addrenv.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -33,7 +33,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "modlib.h"
|
||||
#include "elf.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_alloc
|
||||
* Name: libelf_addrenv_alloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate memory for the ELF image (textalloc and datastart). If
|
||||
@ -80,7 +80,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_addrenv_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
size_t textsize, size_t datasize)
|
||||
{
|
||||
#if defined(CONFIG_ARCH_STACK_DYNAMIC)
|
||||
@ -143,7 +143,7 @@ errout_with_addrenv:
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_select
|
||||
* Name: libelf_addrenv_select
|
||||
*
|
||||
* Description:
|
||||
* Temporarily select the task's address environment.
|
||||
@ -156,7 +156,7 @@ errout_with_addrenv:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_select(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_addrenv_select(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -183,10 +183,10 @@ int modlib_addrenv_select(FAR struct mod_loadinfo_s *loadinfo)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_restore
|
||||
* Name: libelf_addrenv_restore
|
||||
*
|
||||
* Description:
|
||||
* Restore the address environment before modlib_addrenv_select() was
|
||||
* Restore the address environment before libelf_addrenv_select() was
|
||||
* called.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -197,7 +197,7 @@ int modlib_addrenv_select(FAR struct mod_loadinfo_s *loadinfo)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -224,11 +224,11 @@ int modlib_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_addrenv_free
|
||||
* Name: libelf_addrenv_free
|
||||
*
|
||||
* Description:
|
||||
* Release the address environment previously created by
|
||||
* modlib_addrenv_alloc(). This function is called only under certain
|
||||
* libelf_addrenv_alloc(). This function is called only under certain
|
||||
* error conditions after the module has been loaded but not yet started.
|
||||
* After the module has been started, the address environment will
|
||||
* automatically be freed when the module exits.
|
||||
@ -241,7 +241,7 @@ int modlib_addrenv_restore(FAR struct mod_loadinfo_s *loadinfo)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_addrenv_free(FAR struct mod_loadinfo_s *loadinfo)
|
||||
void libelf_addrenv_free(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Free the address environment */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_bind.c
|
||||
* libs/libc/elf/elf_bind.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -34,10 +34,10 @@
|
||||
|
||||
#include <nuttx/cache.h>
|
||||
#include <nuttx/elf.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#include "libc.h"
|
||||
#include "modlib/modlib.h"
|
||||
#include "elf/elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -87,14 +87,14 @@ struct
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_readrels
|
||||
* Name: libelf_readrels
|
||||
*
|
||||
* Description:
|
||||
* Read the (ELF_Rel structure * buffer count) into memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int modlib_readrels(FAR struct mod_loadinfo_s *loadinfo,
|
||||
static inline int libelf_readrels(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const Elf_Shdr *relsec,
|
||||
int index, FAR Elf_Rel *rels,
|
||||
int count)
|
||||
@ -121,19 +121,19 @@ static inline int modlib_readrels(FAR struct mod_loadinfo_s *loadinfo,
|
||||
|
||||
/* And, finally, read the symbol table entry into memory */
|
||||
|
||||
return modlib_read(loadinfo, (FAR uint8_t *)rels, size,
|
||||
return libelf_read(loadinfo, (FAR uint8_t *)rels, size,
|
||||
relsec->sh_offset + offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_readrelas
|
||||
* Name: libelf_readrelas
|
||||
*
|
||||
* Description:
|
||||
* Read the (ELF_Rela structure * buffer count) into memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int modlib_readrelas(FAR struct mod_loadinfo_s *loadinfo,
|
||||
static inline int libelf_readrelas(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const Elf_Shdr *relsec,
|
||||
int index, FAR Elf_Rela *relas,
|
||||
int count)
|
||||
@ -160,12 +160,12 @@ static inline int modlib_readrelas(FAR struct mod_loadinfo_s *loadinfo,
|
||||
|
||||
/* And, finally, read the symbol table entry into memory */
|
||||
|
||||
return modlib_read(loadinfo, (FAR uint8_t *)relas, size,
|
||||
return libelf_read(loadinfo, (FAR uint8_t *)relas, size,
|
||||
relsec->sh_offset + offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_relocate and modlib_relocateadd
|
||||
* Name: libelf_relocate and libelf_relocateadd
|
||||
*
|
||||
* Description:
|
||||
* Perform all relocations associated with a section.
|
||||
@ -176,7 +176,7 @@ static inline int modlib_readrelas(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int modlib_relocate(FAR struct module_s *modp,
|
||||
static int libelf_relocate(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo, int relidx,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
{
|
||||
@ -198,7 +198,8 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
ARCH_ELFDATA_DEF;
|
||||
|
||||
rels = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rel));
|
||||
rels = lib_malloc(CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT *
|
||||
sizeof(Elf_Rel));
|
||||
if (!rels)
|
||||
{
|
||||
berr("Failed to allocate memory for elf relocation rels\n");
|
||||
@ -216,12 +217,12 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
{
|
||||
/* Read the relocation entry into memory */
|
||||
|
||||
rel = &rels[i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT];
|
||||
rel = &rels[i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT];
|
||||
|
||||
if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT))
|
||||
if (!(i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT))
|
||||
{
|
||||
ret = modlib_readrels(loadinfo, relsec, i, rels,
|
||||
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT);
|
||||
ret = libelf_readrels(loadinfo, relsec, i, rels,
|
||||
CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
@ -258,7 +259,7 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
if (sym == NULL)
|
||||
{
|
||||
if (j < CONFIG_MODLIB_SYMBOL_CACHECOUNT)
|
||||
if (j < CONFIG_LIBC_ELF_SYMBOL_CACHECOUNT)
|
||||
{
|
||||
cache = lib_malloc(sizeof(Elf_SymCache));
|
||||
if (!cache)
|
||||
@ -279,7 +280,7 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
/* Read the symbol table entry into memory */
|
||||
|
||||
ret = modlib_readsym(loadinfo, symidx, sym,
|
||||
ret = libelf_readsym(loadinfo, symidx, sym,
|
||||
&loadinfo->shdr[loadinfo->symtabidx]);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -292,7 +293,7 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
|
||||
/* Get the value of the symbol (in sym.st_value) */
|
||||
|
||||
ret = modlib_symvalue(modp, loadinfo, sym,
|
||||
ret = libelf_symvalue(modp, loadinfo, sym,
|
||||
loadinfo->shdr[loadinfo->strtabidx].sh_offset,
|
||||
exports, nexports);
|
||||
if (ret < 0)
|
||||
@ -425,7 +426,7 @@ static int modlib_relocate(FAR struct module_s *modp,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
static int libelf_relocateadd(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
int relidx,
|
||||
FAR const struct symtab_s *exports,
|
||||
@ -449,7 +450,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
ARCH_ELFDATA_DEF;
|
||||
|
||||
relas = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT *
|
||||
relas = lib_malloc(CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT *
|
||||
sizeof(Elf_Rela));
|
||||
if (!relas)
|
||||
{
|
||||
@ -468,12 +469,12 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
{
|
||||
/* Read the relocation entry into memory */
|
||||
|
||||
rela = &relas[i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT];
|
||||
rela = &relas[i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT];
|
||||
|
||||
if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT))
|
||||
if (!(i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT))
|
||||
{
|
||||
ret = modlib_readrelas(loadinfo, relsec, i, relas,
|
||||
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT);
|
||||
ret = libelf_readrelas(loadinfo, relsec, i, relas,
|
||||
CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Section %d reloc %d: "
|
||||
@ -510,7 +511,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
if (sym == NULL)
|
||||
{
|
||||
if (j < CONFIG_MODLIB_SYMBOL_CACHECOUNT)
|
||||
if (j < CONFIG_LIBC_ELF_SYMBOL_CACHECOUNT)
|
||||
{
|
||||
cache = lib_malloc(sizeof(Elf_SymCache));
|
||||
if (!cache)
|
||||
@ -531,7 +532,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
/* Read the symbol table entry into memory */
|
||||
|
||||
ret = modlib_readsym(loadinfo, symidx, sym,
|
||||
ret = libelf_readsym(loadinfo, symidx, sym,
|
||||
&loadinfo->shdr[loadinfo->symtabidx]);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -544,7 +545,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
|
||||
/* Get the value of the symbol (in sym.st_value) */
|
||||
|
||||
ret = modlib_symvalue(modp, loadinfo, sym,
|
||||
ret = libelf_symvalue(modp, loadinfo, sym,
|
||||
loadinfo->shdr[loadinfo->strtabidx].sh_offset,
|
||||
exports, nexports);
|
||||
if (ret < 0)
|
||||
@ -622,7 +623,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_relocatedyn
|
||||
* Name: libelf_relocatedyn
|
||||
*
|
||||
* Description:
|
||||
* Perform all relocations associated with a dynamic section.
|
||||
@ -633,7 +634,7 @@ static int modlib_relocateadd(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
static int libelf_relocatedyn(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
int relidx)
|
||||
{
|
||||
@ -662,7 +663,7 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)dyn, shdr->sh_size,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)dyn, shdr->sh_size,
|
||||
shdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -673,7 +674,8 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
|
||||
/* Assume DT_RELA to get maximum size required */
|
||||
|
||||
rels = lib_zalloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rela));
|
||||
rels = lib_zalloc(CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT *
|
||||
sizeof(Elf_Rela));
|
||||
if (!rels)
|
||||
{
|
||||
berr("Failed to allocate memory for elf relocation rels\n");
|
||||
@ -734,7 +736,7 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)sym, symhdr->sh_size,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)sym, symhdr->sh_size,
|
||||
symhdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -771,26 +773,26 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
|
||||
if (reldata.relrela[idx_rel] == 0)
|
||||
{
|
||||
rel = &rels[i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT];
|
||||
rel = &rels[i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT];
|
||||
rela = (Elf_Rela *)rel; /* Just to keep the compiler happy */
|
||||
}
|
||||
else
|
||||
{
|
||||
rela = &relas[i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT];
|
||||
rela = &relas[i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT];
|
||||
rel = (Elf_Rel *)rela;
|
||||
}
|
||||
|
||||
if (!(i % CONFIG_MODLIB_RELOCATION_BUFFERCOUNT))
|
||||
if (!(i % CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT))
|
||||
{
|
||||
size_t relsize = (sizeof(Elf_Rela) *
|
||||
CONFIG_MODLIB_RELOCATION_BUFFERCOUNT);
|
||||
CONFIG_LIBC_ELF_RELOCATION_BUFFERCOUNT);
|
||||
|
||||
if (reldata.relsz[idx_rel] < relsize)
|
||||
{
|
||||
relsize = reldata.relsz[idx_rel];
|
||||
}
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)rels,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)rels,
|
||||
relsize,
|
||||
reldata.reloff[idx_rel] +
|
||||
i * sizeof(Elf_Rel));
|
||||
@ -814,7 +816,7 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
{
|
||||
FAR void *ep;
|
||||
|
||||
ep = modlib_findglobal(modp, loadinfo, symhdr,
|
||||
ep = libelf_findglobal(modp, loadinfo, symhdr,
|
||||
&sym[idx_sym]);
|
||||
if ((ep == NULL) && (ELF_ST_BIND(sym[idx_sym].st_info)
|
||||
!= STB_WEAK))
|
||||
@ -890,12 +892,12 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_bind
|
||||
* Name: libelf_bind
|
||||
*
|
||||
* Description:
|
||||
* Bind the imported symbol names in the loaded module described by
|
||||
* 'loadinfo' using the exported symbol values provided by
|
||||
* modlib_setsymtab().
|
||||
* libelf_setsymtab().
|
||||
*
|
||||
* Input Parameters:
|
||||
* modp - Module state information
|
||||
@ -909,7 +911,7 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_bind(FAR struct module_s *modp,
|
||||
int libelf_bind(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR const struct symtab_s *exports, int nexports)
|
||||
{
|
||||
@ -918,16 +920,16 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* If CONFIG_ARCH_ADDRENV=y, then the loaded ELF lies in a virtual address
|
||||
* space that may not be in place now. modlib_addrenv_select() will
|
||||
* space that may not be in place now. libelf_addrenv_select() will
|
||||
* temporarily instantiate that address space.
|
||||
*/
|
||||
|
||||
if (loadinfo->addrenv != NULL)
|
||||
{
|
||||
ret = modlib_addrenv_select(loadinfo);
|
||||
ret = libelf_addrenv_select(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_addrenv_select() failed: %d\n", ret);
|
||||
berr("ERROR: libelf_addrenv_select() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -935,7 +937,7 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
|
||||
/* Find the symbol and string tables */
|
||||
|
||||
ret = modlib_findsymtab(loadinfo);
|
||||
ret = libelf_findsymtab(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_addrenv;
|
||||
@ -959,7 +961,7 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
switch (loadinfo->shdr[i].sh_type)
|
||||
{
|
||||
case SHT_DYNAMIC:
|
||||
ret = modlib_relocatedyn(modp, loadinfo, i);
|
||||
ret = libelf_relocatedyn(modp, loadinfo, i);
|
||||
break;
|
||||
case SHT_DYNSYM:
|
||||
loadinfo->dsymtabidx = i;
|
||||
@ -1016,7 +1018,7 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = modlib_relocate(modp, loadinfo, i, exports, nexports);
|
||||
ret = libelf_relocate(modp, loadinfo, i, exports, nexports);
|
||||
break;
|
||||
case SHT_RELA:
|
||||
if ((loadinfo->shdr[infosec].sh_flags & SHF_ALLOC) == 0)
|
||||
@ -1024,7 +1026,7 @@ int modlib_bind(FAR struct module_s *modp,
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = modlib_relocateadd(modp, loadinfo, i, exports,
|
||||
ret = libelf_relocateadd(modp, loadinfo, i, exports,
|
||||
nexports);
|
||||
break;
|
||||
case SHT_INIT_ARRAY:
|
||||
@ -1081,10 +1083,10 @@ errout_with_addrenv:
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
if (loadinfo->addrenv != NULL)
|
||||
{
|
||||
int status = modlib_addrenv_restore(loadinfo);
|
||||
int status = libelf_addrenv_restore(loadinfo);
|
||||
if (status < 0)
|
||||
{
|
||||
berr("ERROR: modlib_addrenv_restore() failed: %d\n", status);
|
||||
berr("ERROR: libelf_addrenv_restore() failed: %d\n", status);
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = status;
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_depend.c
|
||||
* libs/libc/elf/elf_depend.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -31,16 +31,16 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_depend
|
||||
* Name: libelf_depend
|
||||
*
|
||||
* Description:
|
||||
* Set up module dependencies between the exporter and the importer of a
|
||||
@ -56,7 +56,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_depend(FAR struct module_s *importer,
|
||||
int libelf_depend(FAR struct module_s *importer,
|
||||
FAR struct module_s *exporter)
|
||||
{
|
||||
int freendx = -1;
|
||||
@ -70,11 +70,11 @@ int modlib_depend(FAR struct module_s *importer,
|
||||
* list of dependencies.
|
||||
*
|
||||
* The list dependency list is a a dumb, upacked array of pointers. This
|
||||
* should not be too inefficient if the number of CONFIG_MODLIB_MAXDEPEND
|
||||
* should not be too inefficient if the number of CONFIG_LIBC_ELF_MAXDEPEND
|
||||
* is small. Otherwise, a more dynamic data structure would be in order.
|
||||
*/
|
||||
|
||||
for (i = 0; i < CONFIG_MODLIB_MAXDEPEND; i++)
|
||||
for (i = 0; i < CONFIG_LIBC_ELF_MAXDEPEND; i++)
|
||||
{
|
||||
FAR const struct module_s *modp;
|
||||
|
||||
@ -133,7 +133,7 @@ int modlib_depend(FAR struct module_s *importer,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_undepend
|
||||
* Name: libelf_undepend
|
||||
*
|
||||
* Description:
|
||||
* Tear down module dependencies between the exporters and the importer of
|
||||
@ -149,7 +149,7 @@ int modlib_depend(FAR struct module_s *importer,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_undepend(FAR struct module_s *importer)
|
||||
int libelf_undepend(FAR struct module_s *importer)
|
||||
{
|
||||
FAR struct module_s *exporter;
|
||||
int i;
|
||||
@ -158,11 +158,11 @@ int modlib_undepend(FAR struct module_s *importer)
|
||||
|
||||
/* Decrement the dependency count on each of exporters of symbols used by
|
||||
* this importer module. This is an upacked array of pointers. This
|
||||
* should not be too inefficient if the number of CONFIG_MODLIB_MAXDEPEND
|
||||
* should not be too inefficient if the number of CONFIG_LIBC_ELF_MAXDEPEND
|
||||
* is small. Otherwise, a more dynamic data structure would be in order.
|
||||
*/
|
||||
|
||||
for (i = 0; i < CONFIG_MODLIB_MAXDEPEND; i++)
|
||||
for (i = 0; i < CONFIG_LIBC_ELF_MAXDEPEND; i++)
|
||||
{
|
||||
exporter = importer->dependencies[i];
|
||||
if (exporter != NULL)
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_gethandle.c
|
||||
* libs/libc/elf/elf_gethandle.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -27,17 +27,17 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_modhandle
|
||||
* Name: libelf_modhandle
|
||||
*
|
||||
* Description:
|
||||
* modlib_modhandle() returns the module handle for the installed
|
||||
* libelf_modhandle() returns the module handle for the installed
|
||||
* module with the provided name. A secondary use of this function is to
|
||||
* determine if a module has been loaded or not.
|
||||
*
|
||||
@ -45,16 +45,16 @@
|
||||
* name - A pointer to the module name string.
|
||||
*
|
||||
* Returned Value:
|
||||
* The non-NULL module handle previously returned by modlib_insert() is
|
||||
* The non-NULL module handle previously returned by libelf_insert() is
|
||||
* returned on success. If no module with that name is installed,
|
||||
* modlib_modhandle() will return a NULL handle and the errno variable
|
||||
* libelf_modhandle() will return a NULL handle and the errno variable
|
||||
* will be set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
|
||||
FAR void *modlib_gethandle(FAR const char *name)
|
||||
FAR void *libelf_gethandle(FAR const char *name)
|
||||
{
|
||||
FAR struct module_s *modp;
|
||||
|
||||
@ -62,19 +62,19 @@ FAR void *modlib_gethandle(FAR const char *name)
|
||||
|
||||
/* Get exclusive access to the module registry */
|
||||
|
||||
modlib_registry_lock();
|
||||
libelf_registry_lock();
|
||||
|
||||
/* Find the module entry for this name in the registry */
|
||||
|
||||
modp = modlib_registry_find(name);
|
||||
modp = libelf_registry_find(name);
|
||||
if (modp == NULL)
|
||||
{
|
||||
berr("ERROR: Failed to find module %s\n", name);
|
||||
set_errno(ENOENT);
|
||||
}
|
||||
|
||||
modlib_registry_unlock();
|
||||
libelf_registry_unlock();
|
||||
return modp;
|
||||
}
|
||||
|
||||
#endif /* HAVE_MODLIB_NAMES */
|
||||
#endif /* HAVE_LIBC_ELF_NAMES */
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_getsymbol.c
|
||||
* libs/libc/elf/elf_getsymbol.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -27,7 +27,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
@ -35,28 +35,28 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_getsymbol
|
||||
* Name: libelf_getsymbol
|
||||
*
|
||||
* Description:
|
||||
* modlib_getsymbol() returns the address of a symbol defined within the
|
||||
* object that was previously made accessible through a modlib_getsymbol()
|
||||
* call. handle is the value returned from a call to modlib_insert() (and
|
||||
* which has not since been released via a call to modlib_remove()),
|
||||
* libelf_getsymbol() returns the address of a symbol defined within the
|
||||
* object that was previously made accessible through a libelf_getsymbol()
|
||||
* call. handle is the value returned from a call to libelf_insert() (and
|
||||
* which has not since been released via a call to libelf_remove()),
|
||||
* name is the symbol's name as a character string.
|
||||
*
|
||||
* The returned symbol address will remain valid until modlib_remove() is
|
||||
* The returned symbol address will remain valid until libelf_remove() is
|
||||
* called.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The opaque, non-NULL value returned by a previous successful
|
||||
* call to modlib_insert().
|
||||
* call to libelf_insert().
|
||||
* name - A pointer to the symbol name string.
|
||||
*
|
||||
* Returned Value:
|
||||
* The address associated with the symbol is returned on success.
|
||||
* If handle does not refer to a valid module opened by modlib_insert(),
|
||||
* or if the named modlib_symbol cannot be found within any of the objects
|
||||
* associated with handle, modlib_getsymbol() will return NULL and the
|
||||
* If handle does not refer to a valid module opened by libelf_insert(),
|
||||
* or if the named libelf_symbol cannot be found within any of the objects
|
||||
* associated with handle, libelf_getsymbol() will return NULL and the
|
||||
* errno variable will be set appropriately.
|
||||
*
|
||||
* NOTE: This means that the address zero can never be a valid return
|
||||
@ -64,7 +64,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR const void *modlib_getsymbol(FAR void *handle, FAR const char *name)
|
||||
FAR const void *libelf_getsymbol(FAR void *handle, FAR const char *name)
|
||||
{
|
||||
FAR struct module_s *modp = handle;
|
||||
FAR const struct symtab_s *symbol;
|
||||
@ -73,8 +73,8 @@ FAR const void *modlib_getsymbol(FAR void *handle, FAR const char *name)
|
||||
|
||||
/* Verify that the module is in the registry */
|
||||
|
||||
modlib_registry_lock();
|
||||
ret = modlib_registry_verify(modp);
|
||||
libelf_registry_lock();
|
||||
ret = libelf_registry_verify(modp);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Failed to verify module: %d\n", ret);
|
||||
@ -96,7 +96,7 @@ FAR const void *modlib_getsymbol(FAR void *handle, FAR const char *name)
|
||||
symbol = symtab_findbyname(modp->modinfo.exports, name,
|
||||
modp->modinfo.nexports);
|
||||
|
||||
modlib_registry_unlock();
|
||||
libelf_registry_unlock();
|
||||
if (symbol == NULL)
|
||||
{
|
||||
berr("ERROR: Failed to find symbol in symbol \"%s\" in table\n", name);
|
||||
@ -110,7 +110,7 @@ FAR const void *modlib_getsymbol(FAR void *handle, FAR const char *name)
|
||||
return symbol->sym_value;
|
||||
|
||||
errout_with_lock:
|
||||
modlib_registry_unlock();
|
||||
libelf_registry_unlock();
|
||||
set_errno(err);
|
||||
return NULL;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_globals.S
|
||||
* libs/libc/elf/elf_globals.S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_init.c
|
||||
* libs/libc/elf/elf_init.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -35,16 +35,16 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#include "modlib/modlib.h"
|
||||
#include "elf/elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_fileinfo
|
||||
* Name: libelf_fileinfo
|
||||
*
|
||||
* Description:
|
||||
* Get the info of the ELF file
|
||||
@ -55,7 +55,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int modlib_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
static inline int libelf_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
struct stat buf;
|
||||
int ret;
|
||||
@ -84,7 +84,7 @@ static inline int modlib_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_initialize
|
||||
* Name: libelf_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called to configure the library to process an ELF
|
||||
@ -96,7 +96,7 @@ static inline int modlib_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_initialize(FAR const char *filename,
|
||||
int libelf_initialize(FAR const char *filename,
|
||||
FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
@ -119,16 +119,16 @@ int modlib_initialize(FAR const char *filename,
|
||||
|
||||
/* Get some stats info of the file. */
|
||||
|
||||
ret = modlib_fileinfo(loadinfo);
|
||||
ret = libelf_fileinfo(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_fileinfo failed: %d\n", ret);
|
||||
berr("ERROR: libelf_fileinfo failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Read the ELF ehdr from offset 0 */
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
|
||||
sizeof(Elf_Ehdr), 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -136,18 +136,18 @@ int modlib_initialize(FAR const char *filename,
|
||||
return ret;
|
||||
}
|
||||
|
||||
modlib_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
|
||||
libelf_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
|
||||
sizeof(Elf_Ehdr));
|
||||
|
||||
/* Verify the ELF header */
|
||||
|
||||
ret = modlib_verifyheader(&loadinfo->ehdr);
|
||||
ret = libelf_verifyheader(&loadinfo->ehdr);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* This may not be an error because we will be called to attempt
|
||||
* loading EVERY binary. If modlib_verifyheader() does not recognize
|
||||
* loading EVERY binary. If libelf_verifyheader() does not recognize
|
||||
* the ELF header, it will -ENOEXEC which simply informs the system
|
||||
* that the file is not an ELF file. modlib_verifyheader() will return
|
||||
* that the file is not an ELF file. libelf_verifyheader() will return
|
||||
* other errors if the ELF header is not correctly formed.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_insert.c
|
||||
* libs/libc/elf/elf_insert.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -29,16 +29,16 @@
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/lib/lib.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#include "modlib.h"
|
||||
#include "elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_dumploadinfo
|
||||
* Name: libelf_dumploadinfo
|
||||
*
|
||||
* Description:
|
||||
* Dump the load information to debug output.
|
||||
@ -46,7 +46,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_BINFMT_INFO
|
||||
void modlib_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
void libelf_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -109,13 +109,13 @@ void modlib_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_dumpmodule
|
||||
* Name: libelf_dumpmodule
|
||||
****************************************************************************/
|
||||
|
||||
void modlib_dumpmodule(FAR struct module_s *modp)
|
||||
void libelf_dumpmodule(FAR struct module_s *modp)
|
||||
{
|
||||
binfo("Module:\n");
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
binfo(" modname: %s\n", modp->modname);
|
||||
#endif
|
||||
binfo(" textalloc: %08lx\n", (long)modp->textalloc);
|
||||
@ -134,16 +134,16 @@ void modlib_dumpmodule(FAR struct module_s *modp)
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
binfo(" dependents: %d\n", modp->dependents);
|
||||
for (int i = 0; i < modp->dependents; i++)
|
||||
{
|
||||
# ifdef HAVE_MODLIB_NAMES
|
||||
# ifdef HAVE_LIBC_ELF_NAMES
|
||||
binfo("%d %s\n", i, modp->dependencies[i]->modname);
|
||||
# else
|
||||
binfo("%d\n", i);
|
||||
# endif
|
||||
modlib_dumpmodule(modp->dependencies[i]);
|
||||
libelf_dumpmodule(modp->dependencies[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -156,24 +156,24 @@ void modlib_dumpmodule(FAR struct module_s *modp)
|
||||
* Name: elf_dumpentrypt
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MODLIB_DUMPBUFFER
|
||||
void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo)
|
||||
#ifdef CONFIG_LIBC_ELF_DUMPBUFFER
|
||||
void libelf_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR const uint8_t *entry;
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
int ret;
|
||||
|
||||
/* If CONFIG_ARCH_ADDRENV=y, then the loaded ELF lies in a virtual address
|
||||
* space that may not be in place now. modlib_addrenv_select() will
|
||||
* space that may not be in place now. libelf_addrenv_select() will
|
||||
* temporarily instantiate that address space.
|
||||
*/
|
||||
|
||||
if (loadinfo->addrenv != NULL)
|
||||
{
|
||||
ret = modlib_addrenv_select(loadinfo);
|
||||
ret = libelf_addrenv_select(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_addrenv_select() failed: %d\n", ret);
|
||||
berr("ERROR: libelf_addrenv_select() failed: %d\n", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -193,7 +193,7 @@ void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo)
|
||||
entry = (FAR const uint8_t *)loadinfo->textalloc;
|
||||
}
|
||||
|
||||
modlib_dumpbuffer("Entry code", entry,
|
||||
libelf_dumpbuffer("Entry code", entry,
|
||||
MIN(loadinfo->textsize - loadinfo->ehdr.e_entry, 512));
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
@ -201,10 +201,10 @@ void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
if (loadinfo->addrenv != NULL)
|
||||
{
|
||||
ret = modlib_addrenv_restore(loadinfo);
|
||||
ret = libelf_addrenv_restore(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_addrenv_restore() failed: %d\n", ret);
|
||||
berr("ERROR: libelf_addrenv_restore() failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -212,14 +212,14 @@ void modlib_dumpentrypt(FAR struct mod_loadinfo_s *loadinfo)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_loadsymtab
|
||||
* Name: libelf_loadsymtab
|
||||
*
|
||||
* Description:
|
||||
* Load the symbol table into memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int modlib_loadsymtab(FAR struct module_s *modp,
|
||||
static int libelf_loadsymtab(FAR struct module_s *modp,
|
||||
FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR Elf_Shdr *symhdr = &loadinfo->shdr[loadinfo->symtabidx];
|
||||
@ -232,7 +232,7 @@ static int modlib_loadsymtab(FAR struct module_s *modp,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)sym, symhdr->sh_size,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)sym, symhdr->sh_size,
|
||||
symhdr->sh_offset);
|
||||
|
||||
if (ret < 0)
|
||||
@ -253,7 +253,7 @@ static int modlib_loadsymtab(FAR struct module_s *modp,
|
||||
}
|
||||
}
|
||||
|
||||
ret = modlib_insertsymtab(modp, loadinfo, symhdr, sym);
|
||||
ret = libelf_insertsymtab(modp, loadinfo, symhdr, sym);
|
||||
lib_free(sym);
|
||||
if (ret != 0)
|
||||
{
|
||||
@ -265,13 +265,13 @@ static int modlib_loadsymtab(FAR struct module_s *modp,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_insert
|
||||
* Name: libelf_insert
|
||||
*
|
||||
* Description:
|
||||
* Verify that the file is an ELF module binary and, if so, load the
|
||||
* module into kernel memory and initialize it for use.
|
||||
*
|
||||
* NOTE: modlib_setsymtab() had to have been called in board-specific OS
|
||||
* NOTE: libelf_setsymtab() had to have been called in board-specific OS
|
||||
* logic prior to calling this function from application logic (perhaps via
|
||||
* boardctl(BOARDIOC_OS_SYMTAB). Otherwise, insmod will be unable to
|
||||
* resolve symbols in the OS module.
|
||||
@ -284,13 +284,13 @@ static int modlib_loadsymtab(FAR struct module_s *modp,
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL module handle that can be used on subsequent calls to other
|
||||
* module interfaces is returned on success. If modlib_insert() was
|
||||
* unable to load the module modlib_insert() will return a NULL handle
|
||||
* module interfaces is returned on success. If libelf_insert() was
|
||||
* unable to load the module libelf_insert() will return a NULL handle
|
||||
* and the errno variable will be set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
FAR void *libelf_insert(FAR const char *filename, FAR const char *modname)
|
||||
{
|
||||
FAR const struct symtab_s *exports;
|
||||
struct mod_loadinfo_s loadinfo;
|
||||
@ -305,14 +305,14 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
|
||||
/* Get exclusive access to the module registry */
|
||||
|
||||
modlib_registry_lock();
|
||||
libelf_registry_lock();
|
||||
|
||||
/* Check if this module is already installed */
|
||||
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
if (modlib_registry_find(modname) != NULL)
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
if (libelf_registry_find(modname) != NULL)
|
||||
{
|
||||
modlib_registry_unlock();
|
||||
libelf_registry_unlock();
|
||||
set_errno(EEXIST);
|
||||
return NULL;
|
||||
}
|
||||
@ -320,8 +320,8 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
|
||||
/* Initialize the ELF library to load the program binary. */
|
||||
|
||||
ret = modlib_initialize(filename, &loadinfo);
|
||||
modlib_dumploadinfo(&loadinfo);
|
||||
ret = libelf_initialize(filename, &loadinfo);
|
||||
libelf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
berr("ERROR: Failed to initialize to load module: %d\n", ret);
|
||||
@ -338,7 +338,7 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
goto errout_with_loadinfo;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MODLIB_NAMES
|
||||
#ifdef HAVE_LIBC_ELF_NAMES
|
||||
/* Save the module name in the registry entry */
|
||||
|
||||
strlcpy(modp->modname, modname, sizeof(modp->modname));
|
||||
@ -346,8 +346,8 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
|
||||
/* Load the program binary */
|
||||
|
||||
ret = modlib_load(&loadinfo);
|
||||
modlib_dumploadinfo(&loadinfo);
|
||||
ret = libelf_load(&loadinfo);
|
||||
libelf_dumploadinfo(&loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
binfo("Failed to load ELF program binary: %d\n", ret);
|
||||
@ -356,18 +356,18 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
|
||||
/* Get the symbol table */
|
||||
|
||||
modlib_getsymtab(&exports, &nexports);
|
||||
libelf_getsymtab(&exports, &nexports);
|
||||
|
||||
/* Bind the program to the kernel symbol table */
|
||||
|
||||
ret = modlib_bind(modp, &loadinfo, exports, nexports);
|
||||
ret = libelf_bind(modp, &loadinfo, exports, nexports);
|
||||
if (ret != 0)
|
||||
{
|
||||
binfo("Failed to bind symbols program binary: %d\n", ret);
|
||||
goto errout_with_load;
|
||||
}
|
||||
|
||||
ret = modlib_loadsymtab(modp, &loadinfo);
|
||||
ret = libelf_loadsymtab(modp, &loadinfo);
|
||||
if (ret != 0)
|
||||
{
|
||||
binfo("Failed to load symbol table: %d\n", ret);
|
||||
@ -420,22 +420,22 @@ FAR void *modlib_insert(FAR const char *filename, FAR const char *modname)
|
||||
|
||||
/* Add the new module entry to the registry */
|
||||
|
||||
modlib_registry_add(modp);
|
||||
libelf_registry_add(modp);
|
||||
|
||||
modlib_uninitialize(&loadinfo);
|
||||
modlib_registry_unlock();
|
||||
libelf_uninitialize(&loadinfo);
|
||||
libelf_registry_unlock();
|
||||
return modp;
|
||||
|
||||
errout_with_load:
|
||||
modlib_unload(&loadinfo);
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
modlib_undepend(modp);
|
||||
libelf_unload(&loadinfo);
|
||||
#if CONFIG_LIBC_ELF_MAXDEPEND > 0
|
||||
libelf_undepend(modp);
|
||||
#endif
|
||||
errout_with_registry_entry:
|
||||
lib_free(modp);
|
||||
errout_with_loadinfo:
|
||||
modlib_uninitialize(&loadinfo);
|
||||
modlib_registry_unlock();
|
||||
libelf_uninitialize(&loadinfo);
|
||||
libelf_registry_unlock();
|
||||
set_errno(-ret);
|
||||
return NULL;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_iobuffer.c
|
||||
* libs/libc/elf/elf_iobuffer.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -29,17 +29,17 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#include "libc.h"
|
||||
#include "modlib/modlib.h"
|
||||
#include "elf/elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_allocbuffer
|
||||
* Name: libelf_allocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Perform the initial allocation of the I/O buffer, if it has not already
|
||||
@ -51,7 +51,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Has a buffer been allocated> */
|
||||
|
||||
@ -60,21 +60,21 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
/* No.. allocate one now */
|
||||
|
||||
loadinfo->iobuffer = (FAR uint8_t *)
|
||||
lib_malloc(CONFIG_MODLIB_BUFFERSIZE);
|
||||
lib_malloc(CONFIG_LIBC_ELF_BUFFERSIZE);
|
||||
if (!loadinfo->iobuffer)
|
||||
{
|
||||
berr("ERROR: Failed to allocate an I/O buffer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
loadinfo->buflen = CONFIG_MODLIB_BUFFERSIZE;
|
||||
loadinfo->buflen = CONFIG_LIBC_ELF_BUFFERSIZE;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_reallocbuffer
|
||||
* Name: libelf_reallocbuffer
|
||||
*
|
||||
* Description:
|
||||
* Increase the size of I/O buffer by the specified buffer increment.
|
||||
@ -85,7 +85,7 @@ int modlib_allocbuffer(FAR struct mod_loadinfo_s *loadinfo)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int libelf_reallocbuffer(FAR struct mod_loadinfo_s *loadinfo,
|
||||
size_t increment)
|
||||
{
|
||||
FAR void *buffer;
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_load.c
|
||||
* libs/libc/elf/elf_load.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -39,17 +39,17 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#include "libc.h"
|
||||
#include "modlib/modlib.h"
|
||||
#include "elf/elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ELF_ALIGN_MASK ((1 << CONFIG_MODLIB_ALIGN_LOG2) - 1)
|
||||
#define ELF_ALIGN_MASK ((1 << CONFIG_LIBC_ELF_ALIGN_LOG2) - 1)
|
||||
#define ELF_ALIGNUP(a) (((unsigned long)(a) + ELF_ALIGN_MASK) & ~ELF_ALIGN_MASK)
|
||||
#define ELF_ALIGNDOWN(a) ((unsigned long)(a) & ~ELF_ALIGN_MASK)
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_USE_SEPARATED_SECTION
|
||||
static int modlib_section_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
static int libelf_section_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR Elf_Shdr *shdr, uint8_t idx)
|
||||
{
|
||||
if (loadinfo->ehdr.e_type == ET_DYN)
|
||||
@ -89,7 +89,7 @@ static int modlib_section_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
}
|
||||
}
|
||||
|
||||
modlib_sectname(loadinfo, shdr);
|
||||
libelf_sectname(loadinfo, shdr);
|
||||
if ((shdr->sh_flags & SHF_WRITE) != 0)
|
||||
{
|
||||
# ifdef CONFIG_ARCH_USE_DATA_HEAP
|
||||
@ -141,14 +141,14 @@ static int modlib_section_alloc(FAR struct mod_loadinfo_s *loadinfo,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_elfsize
|
||||
* Name: libelf_elfsize
|
||||
*
|
||||
* Description:
|
||||
* Calculate total memory allocation for the ELF file.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
static void libelf_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
{
|
||||
size_t textsize = 0;
|
||||
size_t datasize = 0;
|
||||
@ -206,7 +206,7 @@ static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_USE_SEPARATED_SECTION
|
||||
if (alloc && modlib_section_alloc(loadinfo, shdr, i) >= 0)
|
||||
if (alloc && libelf_section_alloc(loadinfo, shdr, i) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -222,7 +222,7 @@ static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_ARCH_USE_SEPARATED_SECTION
|
||||
if (alloc && modlib_section_alloc(loadinfo, shdr, i) >= 0)
|
||||
if (alloc && libelf_section_alloc(loadinfo, shdr, i) >= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -245,9 +245,9 @@ static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
loadinfo->datasize = datasize;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MODLIB_LOADTO_LMA
|
||||
#ifdef CONFIG_LIBC_ELF_LOADTO_LMA
|
||||
/****************************************************************************
|
||||
* Name: modlib_vma2lma
|
||||
* Name: libelf_vma2lma
|
||||
*
|
||||
* Description:
|
||||
* Convert section`s VMA to LMA according to PhysAddr(p_paddr) of
|
||||
@ -259,7 +259,7 @@ static void modlib_elfsize(FAR struct mod_loadinfo_s *loadinfo, bool alloc)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int modlib_vma2lma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
static int libelf_vma2lma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
FAR Elf_Shdr *shdr, FAR Elf_Addr *lma)
|
||||
{
|
||||
int i;
|
||||
@ -283,7 +283,7 @@ static int modlib_vma2lma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_set_emptysect_vma
|
||||
* Name: libelf_set_emptysect_vma
|
||||
*
|
||||
* Description:
|
||||
* Set VMA for empty and unallocated sections, some relocations might
|
||||
@ -294,7 +294,7 @@ static int modlib_vma2lma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void modlib_set_emptysect_vma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
static void libelf_set_emptysect_vma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
int section)
|
||||
{
|
||||
FAR Elf_Shdr *shdr = &loadinfo->shdr[section];
|
||||
@ -316,7 +316,7 @@ static void modlib_set_emptysect_vma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_loadfile
|
||||
* Name: libelf_loadfile
|
||||
*
|
||||
* Description:
|
||||
* Read the section data into memory. Section addresses in the shdr[] are
|
||||
@ -328,7 +328,7 @@ static void modlib_set_emptysect_vma(FAR struct mod_loadinfo_s *loadinfo,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
static inline int libelf_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
FAR uint8_t *text = (FAR uint8_t *)loadinfo->textalloc;
|
||||
FAR uint8_t *data = (FAR uint8_t *)loadinfo->datastart;
|
||||
@ -350,14 +350,14 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
if (phdr->p_flags & PF_X)
|
||||
{
|
||||
ret = modlib_read(loadinfo, buffer_data_address(text),
|
||||
ret = libelf_read(loadinfo, buffer_data_address(text),
|
||||
phdr->p_filesz,
|
||||
phdr->p_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t bsssize = phdr->p_memsz - phdr->p_filesz;
|
||||
ret = modlib_read(loadinfo, data, phdr->p_filesz,
|
||||
ret = libelf_read(loadinfo, data, phdr->p_filesz,
|
||||
phdr->p_offset);
|
||||
memset(data + phdr->p_filesz, 0, bsssize);
|
||||
}
|
||||
@ -385,7 +385,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
/* Set the VMA regardless */
|
||||
|
||||
modlib_set_emptysect_vma(loadinfo, i);
|
||||
libelf_set_emptysect_vma(loadinfo, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -438,8 +438,8 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
if (shdr->sh_type != SHT_NOBITS)
|
||||
{
|
||||
#ifdef CONFIG_MODLIB_LOADTO_LMA
|
||||
ret = modlib_vma2lma(loadinfo, shdr, (FAR Elf_Addr *)pptr);
|
||||
#ifdef CONFIG_LIBC_ELF_LOADTO_LMA
|
||||
ret = libelf_vma2lma(loadinfo, shdr, (FAR Elf_Addr *)pptr);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: Failed to convert addr %d: %d\n", i, ret);
|
||||
@ -449,7 +449,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Read the section data from sh_offset to the memory region */
|
||||
|
||||
ret = modlib_read(loadinfo, buffer_data_address(*pptr),
|
||||
ret = libelf_read(loadinfo, buffer_data_address(*pptr),
|
||||
shdr->sh_size, shdr->sh_offset);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -462,7 +462,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
|
||||
* section must be cleared.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_MODLIB_LOADTO_LMA
|
||||
#ifndef CONFIG_LIBC_ELF_LOADTO_LMA
|
||||
else if (*pptr != NULL)
|
||||
{
|
||||
memset(*pptr, 0, shdr->sh_size);
|
||||
@ -530,7 +530,7 @@ skipload:
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_load
|
||||
* Name: libelf_load
|
||||
*
|
||||
* Description:
|
||||
* Loads the binary into memory, allocating memory, performing relocations
|
||||
@ -542,7 +542,7 @@ skipload:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -551,14 +551,14 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Load section and program headers into memory */
|
||||
|
||||
ret = modlib_loadhdrs(loadinfo);
|
||||
ret = libelf_loadhdrs(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_loadhdrs failed: %d\n", ret);
|
||||
berr("ERROR: libelf_loadhdrs failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
loadinfo->gotindex = modlib_findsection(loadinfo, ".got");
|
||||
loadinfo->gotindex = libelf_findsection(loadinfo, ".got");
|
||||
if (loadinfo->gotindex >= 0)
|
||||
{
|
||||
binfo("GOT section found! index %d\n", loadinfo->gotindex);
|
||||
@ -571,7 +571,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Determine total size to allocate */
|
||||
|
||||
modlib_elfsize(loadinfo, true);
|
||||
libelf_elfsize(loadinfo, true);
|
||||
|
||||
/* Allocate (and zero) memory for the ELF file. */
|
||||
|
||||
@ -582,7 +582,7 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
* GOT. Therefore we cannot do two different allocations.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_MODLIB_LOADTO_LMA
|
||||
#ifndef CONFIG_LIBC_ELF_LOADTO_LMA
|
||||
|
||||
if (loadinfo->ehdr.e_type == ET_REL || loadinfo->ehdr.e_type == ET_EXEC)
|
||||
{
|
||||
@ -650,22 +650,22 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
loadinfo->segpad;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MODLIB_LOADTO_LMA */
|
||||
#endif /* CONFIG_LIBC_ELF_LOADTO_LMA */
|
||||
|
||||
/* Load ELF section data into memory */
|
||||
|
||||
ret = modlib_loadfile(loadinfo);
|
||||
ret = libelf_loadfile(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_loadfile failed: %d\n", ret);
|
||||
berr("ERROR: libelf_loadfile failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MODLIB_EXIDX_SECTNAME
|
||||
ret = modlib_findsection(loadinfo, CONFIG_MODLIB_EXIDX_SECTNAME);
|
||||
#ifdef CONFIG_LIBC_ELF_EXIDX_SECTNAME
|
||||
ret = libelf_findsection(loadinfo, CONFIG_LIBC_ELF_EXIDX_SECTNAME);
|
||||
if (ret < 0)
|
||||
{
|
||||
binfo("modlib_findsection: Exception Index section not found: %d\n",
|
||||
binfo("libelf_findsection: Exception Index section not found: %d\n",
|
||||
ret);
|
||||
}
|
||||
else
|
||||
@ -680,12 +680,12 @@ int modlib_load(FAR struct mod_loadinfo_s *loadinfo)
|
||||
/* Error exits */
|
||||
|
||||
errout_with_buffers:
|
||||
modlib_unload(loadinfo);
|
||||
libelf_unload(loadinfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_load_with_addrenv
|
||||
* Name: libelf_load_with_addrenv
|
||||
*
|
||||
* Description:
|
||||
* Loads the binary into memory, use the address environment to load the
|
||||
@ -698,7 +698,7 @@ errout_with_buffers:
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -707,14 +707,14 @@ int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Load section and program headers into memory */
|
||||
|
||||
ret = modlib_loadhdrs(loadinfo);
|
||||
ret = libelf_loadhdrs(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_loadhdrs failed: %d\n", ret);
|
||||
berr("ERROR: libelf_loadhdrs failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
loadinfo->gotindex = modlib_findsection(loadinfo, ".got");
|
||||
loadinfo->gotindex = libelf_findsection(loadinfo, ".got");
|
||||
if (loadinfo->gotindex >= 0)
|
||||
{
|
||||
binfo("GOT section found! index %d\n", loadinfo->gotindex);
|
||||
@ -727,9 +727,9 @@ int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Determine total size to allocate */
|
||||
|
||||
modlib_elfsize(loadinfo, false);
|
||||
libelf_elfsize(loadinfo, false);
|
||||
|
||||
ret = modlib_addrenv_alloc(loadinfo, loadinfo->textsize,
|
||||
ret = libelf_addrenv_alloc(loadinfo, loadinfo->textsize,
|
||||
loadinfo->datasize);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -742,36 +742,36 @@ int modlib_load_with_addrenv(FAR struct mod_loadinfo_s *loadinfo)
|
||||
* temporarily instantiate that address space.
|
||||
*/
|
||||
|
||||
ret = modlib_addrenv_select(loadinfo);
|
||||
ret = libelf_addrenv_select(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: elf_addrenv_select() failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
ret = modlib_loadfile(loadinfo);
|
||||
ret = libelf_loadfile(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_loadfile failed: %d\n", ret);
|
||||
berr("ERROR: libelf_loadfile failed: %d\n", ret);
|
||||
goto errout_with_addrenv;
|
||||
}
|
||||
|
||||
/* Restore the original address environment */
|
||||
|
||||
ret = modlib_addrenv_restore(loadinfo);
|
||||
ret = libelf_addrenv_restore(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_addrenv_restore() failed: %d\n", ret);
|
||||
berr("ERROR: libelf_addrenv_restore() failed: %d\n", ret);
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
errout_with_addrenv:
|
||||
modlib_addrenv_restore(loadinfo);
|
||||
libelf_addrenv_restore(loadinfo);
|
||||
|
||||
errout_with_buffers:
|
||||
modlib_unload(loadinfo);
|
||||
libelf_unload(loadinfo);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/modlib/modlib_loadhdrs.c
|
||||
* libs/libc/elf/elf_loadhdrs.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -30,10 +30,10 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/lib/modlib.h>
|
||||
#include <nuttx/lib/elf.h>
|
||||
|
||||
#include "libc.h"
|
||||
#include "modlib/modlib.h"
|
||||
#include "elf/elf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -44,7 +44,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_loadhdrs
|
||||
* Name: libelf_loadhdrs
|
||||
*
|
||||
* Description:
|
||||
* Loads program and section headers into memory.
|
||||
@ -55,7 +55,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
|
||||
int libelf_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
size_t shdrsize;
|
||||
size_t phdrsize;
|
||||
@ -94,7 +94,7 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Read the section header table into memory */
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)loadinfo->shdr, shdrsize,
|
||||
loadinfo->ehdr.e_shoff);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -125,7 +125,7 @@ int modlib_loadhdrs(FAR struct mod_loadinfo_s *loadinfo)
|
||||
|
||||
/* Read the program header table into memory */
|
||||
|
||||
ret = modlib_read(loadinfo, (FAR uint8_t *)loadinfo->phdr, phdrsize,
|
||||
ret = libelf_read(loadinfo, (FAR uint8_t *)loadinfo->phdr, phdrsize,
|
||||
loadinfo->ehdr.e_phoff);
|
||||
if (ret < 0)
|
||||
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user