diff --git a/Documentation/applications/examples/elf/index.rst b/Documentation/applications/examples/elf/index.rst index 71f9db78b8..6ea3bfeedd 100644 --- a/Documentation/applications/examples/elf/index.rst +++ b/Documentation/applications/examples/elf/index.rst @@ -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 diff --git a/Documentation/applications/examples/module/index.rst b/Documentation/applications/examples/module/index.rst index 1f1af24889..e75a3e8658 100644 --- a/Documentation/applications/examples/module/index.rst +++ b/Documentation/applications/examples/module/index.rst @@ -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 diff --git a/Documentation/applications/examples/posix_spawn/index.rst b/Documentation/applications/examples/posix_spawn/index.rst index 4d8d7b4e71..f9872edcdb 100644 --- a/Documentation/applications/examples/posix_spawn/index.rst +++ b/Documentation/applications/examples/posix_spawn/index.rst @@ -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 diff --git a/Documentation/applications/examples/sotest/index.rst b/Documentation/applications/examples/sotest/index.rst index 0ab2c0140c..81f9d8e147 100644 --- a/Documentation/applications/examples/sotest/index.rst +++ b/Documentation/applications/examples/sotest/index.rst @@ -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 diff --git a/Documentation/components/libs/libc/index.rst b/Documentation/components/libs/libc/index.rst index d9594c0a79..304df23341 100644 --- a/Documentation/components/libs/libc/index.rst +++ b/Documentation/components/libs/libc/index.rst @@ -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 diff --git a/Documentation/legacy_README.md b/Documentation/legacy_README.md index b104635add..dcbf9bf58c 100644 --- a/Documentation/legacy_README.md +++ b/Documentation/legacy_README.md @@ -536,7 +536,7 @@ A macOS port is available at: * 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 diff --git a/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt b/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt index 29881da3a5..e4c5752ac4 100644 --- a/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt +++ b/Documentation/platforms/arm/samv7/boards/samv71-xult/README.txt @@ -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: diff --git a/Documentation/platforms/arm/stm32f4/boards/olimex-stm32-p407/index.rst b/Documentation/platforms/arm/stm32f4/boards/olimex-stm32-p407/index.rst index a4771651bb..458ef6ac9b 100644 --- a/Documentation/platforms/arm/stm32f4/boards/olimex-stm32-p407/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/olimex-stm32-p407/index.rst @@ -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:: diff --git a/Documentation/platforms/arm/stm32f4/boards/stm32f4discovery/index.rst b/Documentation/platforms/arm/stm32f4/boards/stm32f4discovery/index.rst index 032100a3cd..696354aa4d 100644 --- a/Documentation/platforms/arm/stm32f4/boards/stm32f4discovery/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/stm32f4discovery/index.rst @@ -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 diff --git a/Documentation/platforms/sim/sim/boards/sim/index.rst b/Documentation/platforms/sim/sim/boards/sim/index.rst index 7954973d76..deae8a8a83 100644 --- a/Documentation/platforms/sim/sim/boards/sim/index.rst +++ b/Documentation/platforms/sim/sim/boards/sim/index.rst @@ -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. diff --git a/Kconfig b/Kconfig index 636d982bc4..e4db18b617 100644 --- a/Kconfig +++ b/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. diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 71db67818f..0e57c8c613 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -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 diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs index cd81fe2455..3de82652a5 100644 --- a/arch/arm64/src/Toolchain.defs +++ b/arch/arm64/src/Toolchain.defs @@ -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) diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index ab60713eab..511de17b57 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -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) diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index b1745905bd..74463cba30 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -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) diff --git a/arch/ceva/src/xc5/Toolchain.defs b/arch/ceva/src/xc5/Toolchain.defs index f1f556e030..7852e9aec7 100644 --- a/arch/ceva/src/xc5/Toolchain.defs +++ b/arch/ceva/src/xc5/Toolchain.defs @@ -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) diff --git a/arch/ceva/src/xm6/Toolchain.defs b/arch/ceva/src/xm6/Toolchain.defs index 5604220227..2768a158b3 100644 --- a/arch/ceva/src/xm6/Toolchain.defs +++ b/arch/ceva/src/xm6/Toolchain.defs @@ -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) diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index e2c88098e5..2ad34c5e78 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -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) diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index 821126ff79..a78e3888fc 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -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) diff --git a/arch/misoc/src/minerva/Toolchain.defs b/arch/misoc/src/minerva/Toolchain.defs index 50b15eea6b..50543de24f 100644 --- a/arch/misoc/src/minerva/Toolchain.defs +++ b/arch/misoc/src/minerva/Toolchain.defs @@ -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) diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index a33d8e1c71..c7e3f3c758 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -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) diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 09b9400b7d..71db3504af 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -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 diff --git a/arch/sim/CMakeLists.txt b/arch/sim/CMakeLists.txt index 8f01ac439c..a1b7c772f2 100644 --- a/arch/sim/CMakeLists.txt +++ b/arch/sim/CMakeLists.txt @@ -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 diff --git a/arch/sparc/src/sparc_v8/Toolchain.defs b/arch/sparc/src/sparc_v8/Toolchain.defs index d5041d7d11..0e01e82f96 100644 --- a/arch/sparc/src/sparc_v8/Toolchain.defs +++ b/arch/sparc/src/sparc_v8/Toolchain.defs @@ -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) diff --git a/arch/tricore/src/common/ToolchainTasking.defs b/arch/tricore/src/common/ToolchainTasking.defs index 6ae81f937c..353930b4a4 100644 --- a/arch/tricore/src/common/ToolchainTasking.defs +++ b/arch/tricore/src/common/ToolchainTasking.defs @@ -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) diff --git a/arch/x86/src/common/Toolchain.defs b/arch/x86/src/common/Toolchain.defs index 641a9c7b1a..76cdfca695 100644 --- a/arch/x86/src/common/Toolchain.defs +++ b/arch/x86/src/common/Toolchain.defs @@ -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) diff --git a/arch/x86_64/src/common/Toolchain.defs b/arch/x86_64/src/common/Toolchain.defs index 9206d4ed90..91a1e5b6ea 100644 --- a/arch/x86_64/src/common/Toolchain.defs +++ b/arch/x86_64/src/common/Toolchain.defs @@ -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 diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index e9dd39c0c9..7caa075e00 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -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) diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index 963c784985..4aa7a68df0 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -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) diff --git a/arch/z16/src/z16f/Toolchain.defs b/arch/z16/src/z16f/Toolchain.defs index 14ec0f8a1d..353cf10b62 100644 --- a/arch/z16/src/z16f/Toolchain.defs +++ b/arch/z16/src/z16f/Toolchain.defs @@ -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) diff --git a/arch/z80/src/ez80/Toolchain.defs b/arch/z80/src/ez80/Toolchain.defs index ff8b88d099..1f64f8ebc7 100644 --- a/arch/z80/src/ez80/Toolchain.defs +++ b/arch/z80/src/ez80/Toolchain.defs @@ -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) diff --git a/arch/z80/src/z180/Toolchain.defs b/arch/z80/src/z180/Toolchain.defs index d6b21ac7b3..44295a9e6d 100644 --- a/arch/z80/src/z180/Toolchain.defs +++ b/arch/z80/src/z180/Toolchain.defs @@ -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) diff --git a/arch/z80/src/z8/Toolchain.defs b/arch/z80/src/z8/Toolchain.defs index e2b825f598..bea30decf4 100644 --- a/arch/z80/src/z8/Toolchain.defs +++ b/arch/z80/src/z8/Toolchain.defs @@ -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) diff --git a/arch/z80/src/z80/Toolchain.defs b/arch/z80/src/z80/Toolchain.defs index 645eaf2b3f..5d5f4f26ee 100644 --- a/arch/z80/src/z80/Toolchain.defs +++ b/arch/z80/src/z80/Toolchain.defs @@ -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) diff --git a/binfmt/Kconfig b/binfmt/Kconfig index 5a32240d70..fc8255b021 100644 --- a/binfmt/Kconfig +++ b/binfmt/Kconfig @@ -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 diff --git a/binfmt/elf.c b/binfmt/elf.c index 836f702c40..5d881d30ab 100644 --- a/binfmt/elf.c +++ b/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; } diff --git a/boards/arm/imx9/imx95-evk/scripts/Make.defs b/boards/arm/imx9/imx95-evk/scripts/Make.defs index a88c3e0b6b..f2f6355f74 100644 --- a/boards/arm/imx9/imx95-evk/scripts/Make.defs +++ b/boards/arm/imx9/imx95-evk/scripts/Make.defs @@ -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) diff --git a/boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs b/boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs index 54d83d5871..c85cf5c8d8 100644 --- a/boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs +++ b/boards/arm/imxrt/imxrt1170-evk/scripts/Make.defs @@ -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) diff --git a/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig b/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig index 82b237309b..41b76ce96c 100644 --- a/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig +++ b/boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig @@ -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 diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/configs/nsh/defconfig b/boards/arm/lpc17xx_40xx/lx_cpu/configs/nsh/defconfig index 795d691b34..455c2d5beb 100644 --- a/boards/arm/lpc17xx_40xx/lx_cpu/configs/nsh/defconfig +++ b/boards/arm/lpc17xx_40xx/lx_cpu/configs/nsh/defconfig @@ -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 diff --git a/boards/arm/mps/mps2-an500/scripts/Make.defs b/boards/arm/mps/mps2-an500/scripts/Make.defs index c80870e8d7..0e389a3726 100644 --- a/boards/arm/mps/mps2-an500/scripts/Make.defs +++ b/boards/arm/mps/mps2-an500/scripts/Make.defs @@ -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) diff --git a/boards/arm/mps/mps3-an547/configs/bl/defconfig b/boards/arm/mps/mps3-an547/configs/bl/defconfig index d1acb8b130..f0c79f843d 100644 --- a/boards/arm/mps/mps3-an547/configs/bl/defconfig +++ b/boards/arm/mps/mps3-an547/configs/bl/defconfig @@ -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 diff --git a/boards/arm/mps/mps3-an547/src/mps3_bringup.c b/boards/arm/mps/mps3-an547/src/mps3_bringup.c index 731c65f486..c76695952a 100644 --- a/boards/arm/mps/mps3-an547/src/mps3_bringup.c +++ b/boards/arm/mps/mps3-an547/src/mps3_bringup.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include @@ -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 diff --git a/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs b/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs index 8b96fa625a..0a0af24d5f 100644 --- a/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs +++ b/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs @@ -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) diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs index 5949dba2ce..7eac71be7a 100644 --- a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs +++ b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs @@ -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) diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c index c7d0d69beb..1f4bb10606 100644 --- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c +++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c @@ -41,7 +41,7 @@ #endif #ifdef CONFIG_MODULE -# include +# include #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 diff --git a/boards/arm/stm32/stm32f4discovery/src/CMakeLists.txt b/boards/arm/stm32/stm32f4discovery/src/CMakeLists.txt index c522e1d928..da35accdab 100644 --- a/boards/arm/stm32/stm32f4discovery/src/CMakeLists.txt +++ b/boards/arm/stm32/stm32f4discovery/src/CMakeLists.txt @@ -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 diff --git a/boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs b/boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs index 13cd1f40de..a73b00d786 100644 --- a/boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs +++ b/boards/arm/stm32h7/linum-stm32h753bi/scripts/Make.defs @@ -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) diff --git a/boards/arm/stm32h7/openh743i/scripts/Make.defs b/boards/arm/stm32h7/openh743i/scripts/Make.defs index 8a79ef3a07..c5bb5006d5 100644 --- a/boards/arm/stm32h7/openh743i/scripts/Make.defs +++ b/boards/arm/stm32h7/openh743i/scripts/Make.defs @@ -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) diff --git a/boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs b/boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs index dfc845d168..2c41ae4fbc 100644 --- a/boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs +++ b/boards/arm/stm32h7/weact-stm32h743/scripts/Make.defs @@ -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) diff --git a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig index 0f6dbfbc7e..f247e8d27f 100644 --- a/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig +++ b/boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig @@ -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 diff --git a/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs b/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs index c9a341d7c9..b49076d735 100644 --- a/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs +++ b/boards/arm/xmc4/xmc4800-relax/scripts/Make.defs @@ -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) diff --git a/boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig b/boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig index bfaa75bf45..11a91f3fd8 100644 --- a/boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig +++ b/boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig @@ -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 diff --git a/boards/boardctl.c b/boards/boardctl.c index c116883a9c..279347c088 100644 --- a/boards/boardctl.c +++ b/boards/boardctl.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -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 diff --git a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs index 2e8c829410..a47f753614 100644 --- a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs @@ -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 diff --git a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs index 2fa4ec830b..4cceb5443e 100644 --- a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs @@ -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 diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs index 1e332e6f33..842ab6bd83 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs @@ -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 diff --git a/boards/renesas/rx65n/rx65n/scripts/Make.defs b/boards/renesas/rx65n/rx65n/scripts/Make.defs index 2bc971e7cc..a2ecc99eed 100644 --- a/boards/renesas/rx65n/rx65n/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n/scripts/Make.defs @@ -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 diff --git a/boards/risc-v/c906/smartl-c906/configs/module/defconfig b/boards/risc-v/c906/smartl-c906/configs/module/defconfig index 37ac423322..1870b988ad 100644 --- a/boards/risc-v/c906/smartl-c906/configs/module/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/module/defconfig @@ -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 diff --git a/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig b/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig index d9150e9cd6..22086c6432 100644 --- a/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig @@ -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 diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs b/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs index d926ea0e15..f27259234a 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs @@ -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) diff --git a/boards/risc-v/k210/maix-bit/configs/elf/defconfig b/boards/risc-v/k210/maix-bit/configs/elf/defconfig index b34b93355f..126ebf5ac3 100644 --- a/boards/risc-v/k210/maix-bit/configs/elf/defconfig +++ b/boards/risc-v/k210/maix-bit/configs/elf/defconfig @@ -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 diff --git a/boards/risc-v/k210/maix-bit/configs/module/defconfig b/boards/risc-v/k210/maix-bit/configs/module/defconfig index 3ea3418526..49969e17ce 100644 --- a/boards/risc-v/k210/maix-bit/configs/module/defconfig +++ b/boards/risc-v/k210/maix-bit/configs/module/defconfig @@ -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 diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 5911e22b29..427d256f2a 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -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 diff --git a/boards/sparc/bm3803/xx3803/configs/nsh/defconfig b/boards/sparc/bm3803/xx3803/configs/nsh/defconfig index e1625e06a5..ba92fa983b 100644 --- a/boards/sparc/bm3803/xx3803/configs/nsh/defconfig +++ b/boards/sparc/bm3803/xx3803/configs/nsh/defconfig @@ -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 diff --git a/boards/sparc/s698pm/s698pm-dkit/configs/nsh/defconfig b/boards/sparc/s698pm/s698pm-dkit/configs/nsh/defconfig index 9c6f083861..68c11fc994 100644 --- a/boards/sparc/s698pm/s698pm-dkit/configs/nsh/defconfig +++ b/boards/sparc/s698pm/s698pm-dkit/configs/nsh/defconfig @@ -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 diff --git a/boards/sparc/s698pm/s698pm-dkit/configs/smp/defconfig b/boards/sparc/s698pm/s698pm-dkit/configs/smp/defconfig index 7e751364f4..529f162f22 100644 --- a/boards/sparc/s698pm/s698pm-dkit/configs/smp/defconfig +++ b/boards/sparc/s698pm/s698pm-dkit/configs/smp/defconfig @@ -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 diff --git a/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs b/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs index 2eaa4fff7e..708b3e9712 100644 --- a/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs @@ -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) diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/python/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/python/defconfig index 99f9a4f78d..e1b80c7578 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/python/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/python/defconfig @@ -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 diff --git a/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs index 27916248d3..1cdde66808 100644 --- a/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs @@ -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) diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs index 48862da084..696a25653c 100644 --- a/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs @@ -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) diff --git a/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs index 710307d716..62ab9a5805 100644 --- a/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs @@ -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 diff --git a/cmake/nuttx_mkconfig.cmake b/cmake/nuttx_mkconfig.cmake index e5ff721a44..4ba00cccd0 100644 --- a/cmake/nuttx_mkconfig.cmake +++ b/cmake/nuttx_mkconfig.cmake @@ -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 diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index d3787bf11b..5a8cfee79b 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -33,7 +33,7 @@ #include #include -#include +#include /**************************************************************************** * 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 diff --git a/include/nuttx/lib/modlib.h b/include/nuttx/lib/elf.h similarity index 82% rename from include/nuttx/lib/modlib.h rename to include/nuttx/lib/elf.h index b8cc0d1263..12f7018803 100644 --- a/include/nuttx/lib/modlib.h +++ b/include/nuttx/lib/elf.h @@ -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 */ diff --git a/include/nuttx/module.h b/include/nuttx/module.h index 666f6260a3..306281e949 100644 --- a/include/nuttx/module.h +++ b/include/nuttx/module.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. diff --git a/libs/libc/.gitignore b/libs/libc/.gitignore index 216ebb0947..e52c6d6974 100644 --- a/libs/libc/.gitignore +++ b/libs/libc/.gitignore @@ -1,3 +1,3 @@ /exec_symtab.c -/modlib_symtab.c -modlib/gnu-elf.ld +/elf_symtab.c +elf/gnu-elf.ld diff --git a/libs/libc/Kconfig b/libs/libc/Kconfig index b5d5e02717..2df4cbbfd0 100644 --- a/libs/libc/Kconfig +++ b/libs/libc/Kconfig @@ -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" diff --git a/libs/libc/Makefile b/libs/libc/Makefile index 2cc26625b8..33bcba86d0 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -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) diff --git a/libs/libc/dlfcn/Kconfig b/libs/libc/dlfcn/Kconfig index d5b4c63de6..ac3f9eb133 100644 --- a/libs/libc/dlfcn/Kconfig +++ b/libs/libc/dlfcn/Kconfig @@ -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. diff --git a/libs/libc/dlfcn/lib_dlclose.c b/libs/libc/dlfcn/lib_dlclose.c index 766ee73a3d..2dfa5da484 100644 --- a/libs/libc/dlfcn/lib_dlclose.c +++ b/libs/libc/dlfcn/lib_dlclose.c @@ -28,7 +28,7 @@ #include -#include +#include /**************************************************************************** * 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, diff --git a/libs/libc/dlfcn/lib_dlopen.c b/libs/libc/dlfcn/lib_dlopen.c index 0a4ed4aaa4..408a0f3d52 100644 --- a/libs/libc/dlfcn/lib_dlopen.c +++ b/libs/libc/dlfcn/lib_dlopen.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include /**************************************************************************** @@ -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; } diff --git a/libs/libc/dlfcn/lib_dlsym.c b/libs/libc/dlfcn/lib_dlsym.c index ec27135577..a37d054aa4 100644 --- a/libs/libc/dlfcn/lib_dlsym.c +++ b/libs/libc/dlfcn/lib_dlsym.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include /**************************************************************************** @@ -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, diff --git a/libs/libc/dlfcn/lib_dlsymtab.c b/libs/libc/dlfcn/lib_dlsymtab.c index 3a2a7ba115..b2f6705a0c 100644 --- a/libs/libc/dlfcn/lib_dlsymtab.c +++ b/libs/libc/dlfcn/lib_dlsymtab.c @@ -29,7 +29,7 @@ #include #include -#include +#include /**************************************************************************** * 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 } diff --git a/libs/libc/modlib/CMakeLists.txt b/libs/libc/elf/CMakeLists.txt similarity index 68% rename from libs/libc/modlib/CMakeLists.txt rename to libs/libc/elf/CMakeLists.txt index 7eee2033c9..af65da605d 100644 --- a/libs/libc/modlib/CMakeLists.txt +++ b/libs/libc/elf/CMakeLists.txt @@ -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}) diff --git a/libs/libc/modlib/Kconfig b/libs/libc/elf/Kconfig similarity index 82% rename from libs/libc/modlib/Kconfig rename to libs/libc/elf/Kconfig index 78ed9bda8a..2fd36399d9 100644 --- a/libs/libc/modlib/Kconfig +++ b/libs/libc/elf/Kconfig @@ -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 diff --git a/libs/libc/modlib/Make.defs b/libs/libc/elf/Make.defs similarity index 62% rename from libs/libc/modlib/Make.defs rename to libs/libc/elf/Make.defs index 4d727470d8..1ce6e6e194 100644 --- a/libs/libc/modlib/Make.defs +++ b/libs/libc/elf/Make.defs @@ -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 diff --git a/libs/libc/modlib/Makefile b/libs/libc/elf/Makefile similarity index 97% rename from libs/libc/modlib/Makefile rename to libs/libc/elf/Makefile index 2d98a157e3..a1bad65733 100644 --- a/libs/libc/modlib/Makefile +++ b/libs/libc/elf/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# libs/libc/modlib/Makefile +# libs/libc/elf/Makefile # # SPDX-License-Identifier: Apache-2.0 # diff --git a/libs/libc/modlib/modlib.h b/libs/libc/elf/elf.h similarity index 85% rename from libs/libc/modlib/modlib.h rename to libs/libc/elf/elf.h index 43bb58eda8..986a3fa580 100644 --- a/libs/libc/modlib/modlib.h +++ b/libs/libc/elf/elf.h @@ -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 -#include +#include /**************************************************************************** * 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 */ diff --git a/libs/libc/modlib/modlib_addrenv.c b/libs/libc/elf/elf_addrenv.c similarity index 92% rename from libs/libc/modlib/modlib_addrenv.c rename to libs/libc/elf/elf_addrenv.c index 6d140ff341..712436036e 100644 --- a/libs/libc/modlib/modlib_addrenv.c +++ b/libs/libc/elf/elf_addrenv.c @@ -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 #include -#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 */ diff --git a/libs/libc/modlib/modlib_bind.c b/libs/libc/elf/elf_bind.c similarity index 91% rename from libs/libc/modlib/modlib_bind.c rename to libs/libc/elf/elf_bind.c index 3e03054b2f..faaf087e63 100644 --- a/libs/libc/modlib/modlib_bind.c +++ b/libs/libc/elf/elf_bind.c @@ -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 #include -#include +#include #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; diff --git a/libs/libc/modlib/modlib_depend.c b/libs/libc/elf/elf_depend.c similarity index 91% rename from libs/libc/modlib/modlib_depend.c rename to libs/libc/elf/elf_depend.c index 258597ae63..128334107e 100644 --- a/libs/libc/modlib/modlib_depend.c +++ b/libs/libc/elf/elf_depend.c @@ -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 #include -#include +#include -#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) diff --git a/libs/libc/modlib/modlib_gethandle.c b/libs/libc/elf/elf_gethandle.c similarity index 82% rename from libs/libc/modlib/modlib_gethandle.c rename to libs/libc/elf/elf_gethandle.c index ddd7303df3..699b5ffab3 100644 --- a/libs/libc/modlib/modlib_gethandle.c +++ b/libs/libc/elf/elf_gethandle.c @@ -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 #include -#include +#include /**************************************************************************** * 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 */ diff --git a/libs/libc/modlib/modlib_getsymbol.c b/libs/libc/elf/elf_getsymbol.c similarity index 79% rename from libs/libc/modlib/modlib_getsymbol.c rename to libs/libc/elf/elf_getsymbol.c index c73a454a10..453296d3e4 100644 --- a/libs/libc/modlib/modlib_getsymbol.c +++ b/libs/libc/elf/elf_getsymbol.c @@ -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 #include -#include +#include #include /**************************************************************************** @@ -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; } diff --git a/libs/libc/modlib/modlib_globals.S b/libs/libc/elf/elf_globals.S similarity index 98% rename from libs/libc/modlib/modlib_globals.S rename to libs/libc/elf/elf_globals.S index a458fdabe5..da707b1498 100644 --- a/libs/libc/modlib/modlib_globals.S +++ b/libs/libc/elf/elf_globals.S @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_globals.S + * libs/libc/elf/elf_globals.S * * SPDX-License-Identifier: Apache-2.0 * diff --git a/libs/libc/modlib/modlib_init.c b/libs/libc/elf/elf_init.c similarity index 86% rename from libs/libc/modlib/modlib_init.c rename to libs/libc/elf/elf_init.c index d7162d38fb..53808e7608 100644 --- a/libs/libc/modlib/modlib_init.c +++ b/libs/libc/elf/elf_init.c @@ -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 #include -#include +#include -#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. */ diff --git a/libs/libc/modlib/modlib_insert.c b/libs/libc/elf/elf_insert.c similarity index 85% rename from libs/libc/modlib/modlib_insert.c rename to libs/libc/elf/elf_insert.c index 19a6ab320c..d786a1ef68 100644 --- a/libs/libc/modlib/modlib_insert.c +++ b/libs/libc/elf/elf_insert.c @@ -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 #include -#include +#include -#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; } diff --git a/libs/libc/modlib/modlib_iobuffer.c b/libs/libc/elf/elf_iobuffer.c similarity index 88% rename from libs/libc/modlib/modlib_iobuffer.c rename to libs/libc/elf/elf_iobuffer.c index f9b75f7f22..0b5d24d386 100644 --- a/libs/libc/modlib/modlib_iobuffer.c +++ b/libs/libc/elf/elf_iobuffer.c @@ -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 #include -#include +#include #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; diff --git a/libs/libc/modlib/modlib_load.c b/libs/libc/elf/elf_load.c similarity index 89% rename from libs/libc/modlib/modlib_load.c rename to libs/libc/elf/elf_load.c index 0048f793a9..30ffabe813 100644 --- a/libs/libc/modlib/modlib_load.c +++ b/libs/libc/elf/elf_load.c @@ -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 #include -#include +#include #include #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 diff --git a/libs/libc/modlib/modlib_loadhdrs.c b/libs/libc/elf/elf_loadhdrs.c similarity index 93% rename from libs/libc/modlib/modlib_loadhdrs.c rename to libs/libc/elf/elf_loadhdrs.c index 5f8a65e537..a433efddb0 100644 --- a/libs/libc/modlib/modlib_loadhdrs.c +++ b/libs/libc/elf/elf_loadhdrs.c @@ -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 #include -#include +#include #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) { diff --git a/libs/libc/modlib/modlib_read.c b/libs/libc/elf/elf_read.c similarity index 92% rename from libs/libc/modlib/modlib_read.c rename to libs/libc/elf/elf_read.c index 8f0fb09b89..2df8a3c442 100644 --- a/libs/libc/modlib/modlib_read.c +++ b/libs/libc/elf/elf_read.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_read.c + * libs/libc/elf/elf_read.c * * SPDX-License-Identifier: Apache-2.0 * @@ -35,7 +35,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions @@ -48,13 +48,13 @@ ****************************************************************************/ /**************************************************************************** - * Name: modlib_dumpreaddata + * Name: libelf_dumpreaddata ****************************************************************************/ #ifdef ELF_DUMP_READDATA -# define modlib_dumpreaddata(b,n) binfodumpbuffer("modlib_read",b,n) +# define libelf_dumpreaddata(b,n) binfodumpbuffer("libelf_read",b,n) #else -# define modlib_dumpreaddata(b,n) +# define libelf_dumpreaddata(b,n) #endif /**************************************************************************** @@ -62,7 +62,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: modlib_read + * Name: libelf_read * * Description: * Read 'readsize' bytes from the object file at 'offset'. The data is @@ -74,7 +74,7 @@ * ****************************************************************************/ -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) { size_t nsize = readsize; @@ -127,6 +127,6 @@ int modlib_read(FAR struct mod_loadinfo_s *loadinfo, FAR uint8_t *buffer, } } - modlib_dumpreaddata(buffer, nsize); + libelf_dumpreaddata(buffer, nsize); return OK; } diff --git a/libs/libc/modlib/modlib_registry.c b/libs/libc/elf/elf_registry.c similarity index 89% rename from libs/libc/modlib/modlib_registry.c rename to libs/libc/elf/elf_registry.c index 3e8dacd0ae..55781b070d 100644 --- a/libs/libc/modlib/modlib_registry.c +++ b/libs/libc/elf/elf_registry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_registry.c + * libs/libc/elf/elf_registry.c * * SPDX-License-Identifier: Apache-2.0 * @@ -32,7 +32,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions @@ -54,7 +54,7 @@ static FAR struct module_s *g_mod_registry; ****************************************************************************/ /**************************************************************************** - * Name: modlib_registry_lock + * Name: libelf_registry_lock * * Description: * Get exclusive access to the module registry. @@ -67,13 +67,13 @@ static FAR struct module_s *g_mod_registry; * ****************************************************************************/ -void modlib_registry_lock(void) +void libelf_registry_lock(void) { nxrmutex_lock(&g_modlock); } /**************************************************************************** - * Name: modlib_registry_unlock + * Name: libelf_registry_unlock * * Description: * Relinquish the lock on the module registry @@ -86,13 +86,13 @@ void modlib_registry_lock(void) * ****************************************************************************/ -void modlib_registry_unlock(void) +void libelf_registry_unlock(void) { nxrmutex_unlock(&g_modlock); } /**************************************************************************** - * Name: modlib_registry_add + * Name: libelf_registry_add * * Description: * Add a new entry to the module registry. @@ -108,7 +108,7 @@ void modlib_registry_unlock(void) * ****************************************************************************/ -void modlib_registry_add(FAR struct module_s *modp) +void libelf_registry_add(FAR struct module_s *modp) { DEBUGASSERT(modp); modp->flink = g_mod_registry; @@ -116,7 +116,7 @@ void modlib_registry_add(FAR struct module_s *modp) } /**************************************************************************** - * Name: modlib_registry_del + * Name: libelf_registry_del * * Description: * Remove a module entry from the registry @@ -133,7 +133,7 @@ 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) { FAR struct module_s *prev; FAR struct module_s *curr; @@ -162,7 +162,7 @@ int modlib_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. @@ -179,13 +179,14 @@ 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) { FAR struct module_s *modp; for (modp = g_mod_registry; - modp != NULL && strncmp(modp->modname, modname, MODLIB_NAMEMAX) != 0; + modp != NULL && + strncmp(modp->modname, modname, LIBC_ELF_NAMEMAX) != 0; modp = modp->flink); return modp; @@ -193,7 +194,7 @@ FAR struct module_s *modlib_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 @@ -211,7 +212,7 @@ 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) { FAR struct module_s *node; @@ -227,7 +228,7 @@ int modlib_registry_verify(FAR struct module_s *modp) } /**************************************************************************** - * Name: modlib_registry_foreach + * Name: libelf_registry_foreach * * Description: * Visit each module in the registry @@ -244,14 +245,14 @@ 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) { FAR struct module_s *modp; int ret = OK; /* Get exclusive access to the module registry */ - modlib_registry_lock(); + libelf_registry_lock(); /* Visit each installed module */ @@ -266,6 +267,6 @@ int modlib_registry_foreach(mod_callback_t callback, FAR void *arg) } } - modlib_registry_unlock(); + libelf_registry_unlock(); return ret; } diff --git a/libs/libc/modlib/modlib_remove.c b/libs/libc/elf/elf_remove.c similarity index 91% rename from libs/libc/modlib/modlib_remove.c rename to libs/libc/elf/elf_remove.c index 10db0de419..ab101fe242 100644 --- a/libs/libc/modlib/modlib_remove.c +++ b/libs/libc/elf/elf_remove.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_remove.c + * libs/libc/elf/elf_remove.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,27 +29,27 @@ #include #include -#include +#include /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * 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) { FAR void (**array)(void); int ret = OK; int i; -#if CONFIG_MODLIB_MAXDEPEND > 0 +#if CONFIG_LIBC_ELF_MAXDEPEND > 0 /* Refuse to remove any module that other modules may depend upon. */ if (modp->dependents > 0) @@ -81,7 +81,7 @@ int modlib_uninit(FAR struct module_s *modp) return ret; } - modlib_freesymtab(modp); + libelf_freesymtab(modp); /* Nullify so that the uninitializer cannot be called again */ @@ -161,23 +161,23 @@ int modlib_uninit(FAR struct module_s *modp) #endif } -#if CONFIG_MODLIB_MAXDEPEND > 0 +#if CONFIG_LIBC_ELF_MAXDEPEND > 0 /* Eliminate any dependencies that this module has on other modules */ - modlib_undepend(modp); + libelf_undepend(modp); #endif return ret; } /**************************************************************************** - * 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 @@ -185,7 +185,7 @@ int modlib_uninit(FAR struct module_s *modp) * ****************************************************************************/ -int modlib_remove(FAR void *handle) +int libelf_remove(FAR void *handle) { FAR struct module_s *modp = (FAR struct module_s *)handle; int ret; @@ -194,18 +194,18 @@ int modlib_remove(FAR void *handle) /* Get exclusive access to the module registry */ - modlib_registry_lock(); + libelf_registry_lock(); /* Verify that the module is in the registry */ - ret = modlib_registry_verify(modp); + ret = libelf_registry_verify(modp); if (ret < 0) { berr("ERROR: Failed to verify module: %d\n", ret); goto errout_with_lock; } - ret = modlib_uninit(modp); + ret = libelf_uninit(modp); if (ret < 0) { berr("ERROR: Failed to uninitialize module %d\n", ret); @@ -214,7 +214,7 @@ int modlib_remove(FAR void *handle) /* Remove the module from the registry */ - ret = modlib_registry_del(modp); + ret = libelf_registry_del(modp); if (ret < 0) { berr("ERROR: Failed to remove the module from the registry: %d\n", @@ -222,14 +222,14 @@ int modlib_remove(FAR void *handle) goto errout_with_lock; } - modlib_registry_unlock(); + libelf_registry_unlock(); /* And free the registry entry */ return ret; errout_with_lock: - modlib_registry_unlock(); + libelf_registry_unlock(); set_errno(-ret); return ERROR; } diff --git a/libs/libc/modlib/modlib_sections.c b/libs/libc/elf/elf_sections.c similarity index 89% rename from libs/libc/modlib/modlib_sections.c rename to libs/libc/elf/elf_sections.c index 7e8ac1553c..be31caa785 100644 --- a/libs/libc/modlib/modlib_sections.c +++ b/libs/libc/elf/elf_sections.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_sections.c + * libs/libc/elf/elf_sections.c * * SPDX-License-Identifier: Apache-2.0 * @@ -32,14 +32,14 @@ #include #include "libc.h" -#include "modlib/modlib.h" +#include "elf/elf.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: modlib_sectname + * Name: libelf_sectname * * Description: * Get the symbol name in loadinfo->iobuffer[]. @@ -50,7 +50,7 @@ * ****************************************************************************/ -int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, +int libelf_sectname(FAR struct mod_loadinfo_s *loadinfo, FAR const Elf_Shdr *shdr) { FAR Elf_Shdr *shstr; @@ -71,14 +71,14 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, return -EINVAL; } - /* Allocate an I/O buffer. This buffer is used by modlib_sectname() to + /* Allocate an I/O buffer. This buffer is used by libelf_sectname() to * accumulate the variable length symbol name. */ - ret = modlib_allocbuffer(loadinfo); + ret = libelf_allocbuffer(loadinfo); if (ret < 0) { - berr("ERROR: modlib_allocbuffer failed: %d\n", ret); + berr("ERROR: libelf_allocbuffer failed: %d\n", ret); return -ENOMEM; } @@ -119,7 +119,7 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, /* Read that number of bytes into the array */ - ret = modlib_read(loadinfo, buffer, readlen, offset + bytesread); + ret = libelf_read(loadinfo, buffer, readlen, offset + bytesread); if (ret < 0) { berr("ERROR: Failed to read section name: %d\n", ret); @@ -139,7 +139,7 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, /* No.. then we have to read more */ - ret = modlib_reallocbuffer(loadinfo, CONFIG_MODLIB_BUFFERINCR); + ret = libelf_reallocbuffer(loadinfo, CONFIG_LIBC_ELF_BUFFERINCR); if (ret < 0) { berr("ERROR: mod_reallocbuffer failed: %d\n", ret); @@ -153,7 +153,7 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, } /**************************************************************************** - * Name: modlib_findsection + * Name: libelf_findsection * * Description: * A section by its name. @@ -168,7 +168,7 @@ int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo, * ****************************************************************************/ -int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo, +int libelf_findsection(FAR struct mod_loadinfo_s *loadinfo, FAR const char *sectname) { int i; @@ -183,10 +183,10 @@ int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo, /* Get the name of this section */ - int ret = modlib_sectname(loadinfo, shdr); + int ret = libelf_sectname(loadinfo, shdr); if (ret < 0) { - berr("ERROR: modlib_sectname failed: %d\n", ret); + berr("ERROR: libelf_sectname failed: %d\n", ret); return ret; } diff --git a/libs/libc/modlib/modlib_symbols.c b/libs/libc/elf/elf_symbols.c similarity index 90% rename from libs/libc/modlib/modlib_symbols.c rename to libs/libc/elf/elf_symbols.c index 98e1c35663..f29e5e2b21 100644 --- a/libs/libc/modlib/modlib_symbols.c +++ b/libs/libc/elf/elf_symbols.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_symbols.c + * libs/libc/elf/elf_symbols.c * * SPDX-License-Identifier: Apache-2.0 * @@ -34,10 +34,10 @@ #include #include -#include +#include #include "libc.h" -#include "modlib/modlib.h" +#include "elf/elf.h" /**************************************************************************** * Pre-processor Definitions @@ -77,7 +77,7 @@ extern int nglobals; ****************************************************************************/ /**************************************************************************** - * Name: modlib_symname + * Name: libelf_symname * * Description: * Get the symbol name in loadinfo->iobuffer[]. @@ -92,7 +92,7 @@ extern int nglobals; * ****************************************************************************/ -static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, +static int libelf_symname(FAR struct mod_loadinfo_s *loadinfo, FAR const Elf_Sym *sym, Elf_Off sh_offset) { FAR uint8_t *buffer; @@ -115,10 +115,10 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, * accumulate the variable length symbol name. */ - ret = modlib_allocbuffer(loadinfo); + ret = libelf_allocbuffer(loadinfo); if (ret < 0) { - berr("ERROR: modlib_allocbuffer failed: %d\n", ret); + berr("ERROR: libelf_allocbuffer failed: %d\n", ret); return -ENOMEM; } @@ -147,10 +147,10 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, /* Read that number of bytes into the array */ buffer = &loadinfo->iobuffer[bytesread]; - ret = modlib_read(loadinfo, buffer, readlen, offset); + ret = libelf_read(loadinfo, buffer, readlen, offset); if (ret < 0) { - berr("ERROR: modlib_read failed: %d\n", ret); + berr("ERROR: libelf_read failed: %d\n", ret); return ret; } @@ -167,14 +167,14 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, /* No.. then we have to read more */ - ret = modlib_reallocbuffer(loadinfo, CONFIG_MODLIB_BUFFERINCR); + ret = libelf_reallocbuffer(loadinfo, CONFIG_LIBC_ELF_BUFFERINCR); if (ret < 0) { berr("ERROR: mod_reallocbuffer failed: %d\n", ret); return ret; } - offset += CONFIG_MODLIB_BUFFERINCR; + offset += CONFIG_LIBC_ELF_BUFFERINCR; } /* We will not get here */ @@ -183,10 +183,10 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, } /**************************************************************************** - * Name: modlib_symcallback + * Name: libelf_symcallback * * Description: - * modlib_registry_foreach() callback function. Test if the provided + * libelf_registry_foreach() callback function. Test if the provided * module, modp, exports the symbol of interest. If so, return that symbol * value and setup the module dependency relationship. * @@ -196,7 +196,7 @@ static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo, * ****************************************************************************/ -static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg) +static int libelf_symcallback(FAR struct module_s *modp, FAR void *arg) { FAR struct mod_exportinfo_s *exportinfo = (FAR struct mod_exportinfo_s *) arg; @@ -213,11 +213,11 @@ static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg) * stop the traversal. */ -#if CONFIG_MODLIB_MAXDEPEND > 0 - int ret = modlib_depend(exportinfo->modp, modp); +#if CONFIG_LIBC_ELF_MAXDEPEND > 0 + int ret = libelf_depend(exportinfo->modp, modp); if (ret < 0) { - berr("ERROR: modlib_depend failed: %d\n", ret); + berr("ERROR: libelf_depend failed: %d\n", ret); return ret; } #endif @@ -233,7 +233,7 @@ static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: modlib_findsymtab + * Name: libelf_findsymtab * * Description: * Find the symbol table section. @@ -244,7 +244,7 @@ static int modlib_symcallback(FAR struct module_s *modp, FAR void *arg) * ****************************************************************************/ -int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo) +int libelf_findsymtab(FAR struct mod_loadinfo_s *loadinfo) { int i; @@ -272,7 +272,7 @@ int modlib_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. @@ -288,7 +288,7 @@ 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 *symtab) { off_t offset; @@ -307,11 +307,11 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index, /* And, finally, read the symbol table entry into memory */ - return modlib_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf_Sym), offset); + return libelf_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf_Sym), offset); } /**************************************************************************** - * Name: modlib_symvalue + * Name: libelf_symvalue * * Description: * Get the value of a symbol. The updated value of the symbol is returned @@ -337,7 +337,7 @@ 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) @@ -369,7 +369,7 @@ int modlib_symvalue(FAR struct module_s *modp, { /* Get the name of the undefined symbol */ - ret = modlib_symname(loadinfo, sym, sh_offset); + ret = libelf_symname(loadinfo, sym, sh_offset); if (ret < 0) { /* There are a few relocations for a few architectures that do @@ -392,11 +392,11 @@ int modlib_symvalue(FAR struct module_s *modp, exportinfo.modp = modp; exportinfo.symbol = NULL; - ret = modlib_registry_foreach(modlib_symcallback, + ret = libelf_registry_foreach(libelf_symcallback, (FAR void *)&exportinfo); if (ret < 0) { - berr("ERROR: modlib_symcallback failed: %d\n", ret); + berr("ERROR: libelf_symcallback failed: %d\n", ret); return ret; } @@ -457,7 +457,7 @@ int modlib_symvalue(FAR struct module_s *modp, } /**************************************************************************** - * Name: modlib_insertsymtab + * Name: libelf_insertsymtab * * Description: * Insert a symbol into the modules exportinfo array. @@ -477,7 +477,7 @@ int modlib_symvalue(FAR struct module_s *modp, * ****************************************************************************/ -int modlib_insertsymtab(FAR struct module_s *modp, +int libelf_insertsymtab(FAR struct module_s *modp, struct mod_loadinfo_s *loadinfo, FAR Elf_Shdr *shdr, FAR Elf_Sym *sym) { @@ -492,7 +492,7 @@ int modlib_insertsymtab(FAR struct module_s *modp, if (modp->modinfo.exports != NULL) { bwarn("Module export information already present - replacing"); - modlib_freesymtab((FAR void *)modp); + libelf_freesymtab((FAR void *)modp); } /* Count the "live" symbols */ @@ -526,7 +526,7 @@ int modlib_insertsymtab(FAR struct module_s *modp, ELF_ST_TYPE(sym[i].st_info) != STT_NOTYPE && ELF_ST_VISIBILITY(sym[i].st_other) == STV_DEFAULT) { - ret = modlib_symname(loadinfo, &sym[i], strtab->sh_offset); + ret = libelf_symname(loadinfo, &sym[i], strtab->sh_offset); if (ret < 0) { lib_free((FAR void *)modp->modinfo.exports); @@ -576,7 +576,7 @@ static int findep(FAR const void *c1, FAR const void *c2) } /**************************************************************************** - * Name: modlib_findglobal + * Name: libelf_findglobal * * Description: * Find a symbol in our library entry point table @@ -586,7 +586,7 @@ static int findep(FAR const void *c1, FAR const void *c2) * ****************************************************************************/ -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) { @@ -595,7 +595,7 @@ void *modlib_findglobal(FAR struct module_s *modp, struct eptable_s key; FAR struct eptable_s *res; - ret = modlib_symname(loadinfo, sym, strtab->sh_offset); + ret = libelf_symname(loadinfo, sym, strtab->sh_offset); if (ret < 0) { return NULL; @@ -615,7 +615,7 @@ void *modlib_findglobal(FAR struct module_s *modp, } /**************************************************************************** - * Name: modlib_freesymtab + * Name: libelf_freesymtab * * Description: * Free a symbol table @@ -625,7 +625,7 @@ void *modlib_findglobal(FAR struct module_s *modp, * ****************************************************************************/ -void modlib_freesymtab(FAR struct module_s *modp) +void libelf_freesymtab(FAR struct module_s *modp) { FAR const struct symtab_s *symbol; int i; diff --git a/libs/libc/modlib/modlib_symtab.c b/libs/libc/elf/elf_symtab.c similarity index 74% rename from libs/libc/modlib/modlib_symtab.c rename to libs/libc/elf/elf_symtab.c index e84d817f55..ba9dbfb902 100644 --- a/libs/libc/modlib/modlib_symtab.c +++ b/libs/libc/elf/elf_symtab.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_symtab.c + * libs/libc/elf/elf_symtab.c * * SPDX-License-Identifier: Apache-2.0 * @@ -29,23 +29,23 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_MODLIB_HAVE_SYMTAB +#ifdef CONFIG_LIBC_ELF_HAVE_SYMTAB /* Symbol table used by dlsym */ -# ifndef CONFIG_MODLIB_SYMTAB_ARRAY -# error "CONFIG_MODLIB_SYMTAB_ARRAY must be defined" +# ifndef CONFIG_LIBC_ELF_SYMTAB_ARRAY +# error "CONFIG_LIBC_ELF_SYMTAB_ARRAY must be defined" # endif /* Number of Symbols in the Table */ -# ifndef CONFIG_MODLIB_NSYMBOLS_VAR -# error "CONFIG_MODLIB_NSYMBOLS_VAR must be defined" +# ifndef CONFIG_LIBC_ELF_NSYMBOLS_VAR +# error "CONFIG_LIBC_ELF_NSYMBOLS_VAR must be defined" # endif #endif @@ -53,24 +53,24 @@ * Public Data ****************************************************************************/ -#ifdef CONFIG_MODLIB_HAVE_SYMTAB -extern const struct symtab_s CONFIG_MODLIB_SYMTAB_ARRAY[]; -extern int CONFIG_MODLIB_NSYMBOLS_VAR; +#ifdef CONFIG_LIBC_ELF_HAVE_SYMTAB +extern const struct symtab_s CONFIG_LIBC_ELF_SYMTAB_ARRAY[]; +extern int CONFIG_LIBC_ELF_NSYMBOLS_VAR; #endif /**************************************************************************** * Private Data ****************************************************************************/ -static FAR const struct symtab_s *g_modlib_symtab; -static int g_modlib_nsymbols; +static FAR const struct symtab_s *g_libelf_symtab; +static int g_libelf_nsymbols; /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: modlib_getsymtab + * Name: libelf_getsymtab * * Description: * Get the current kernel symbol table selection as an atomic operation. @@ -85,28 +85,28 @@ static int g_modlib_nsymbols; * ****************************************************************************/ -void modlib_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols) +void libelf_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols) { DEBUGASSERT(symtab != NULL && nsymbols != NULL); /* Borrow the registry lock to assure atomic access */ - modlib_registry_lock(); -#ifdef CONFIG_MODLIB_HAVE_SYMTAB - if (g_modlib_symtab == NULL) + libelf_registry_lock(); +#ifdef CONFIG_LIBC_ELF_HAVE_SYMTAB + if (g_libelf_symtab == NULL) { - g_modlib_symtab = CONFIG_MODLIB_SYMTAB_ARRAY; - g_modlib_nsymbols = CONFIG_MODLIB_NSYMBOLS_VAR; + g_libelf_symtab = CONFIG_LIBC_ELF_SYMTAB_ARRAY; + g_libelf_nsymbols = CONFIG_LIBC_ELF_NSYMBOLS_VAR; } #endif - *symtab = g_modlib_symtab; - *nsymbols = g_modlib_nsymbols; - modlib_registry_unlock(); + *symtab = g_libelf_symtab; + *nsymbols = g_libelf_nsymbols; + libelf_registry_unlock(); } /**************************************************************************** - * Name: modlib_setsymtab + * Name: libelf_setsymtab * * Description: * Select a new kernel symbol table selection as an atomic operation. @@ -120,12 +120,12 @@ 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) { /* Borrow the registry lock to assure atomic access */ - modlib_registry_lock(); - g_modlib_symtab = symtab; - g_modlib_nsymbols = nsymbols; - modlib_registry_unlock(); + libelf_registry_lock(); + g_libelf_symtab = symtab; + g_libelf_nsymbols = nsymbols; + libelf_registry_unlock(); } diff --git a/libs/libc/modlib/modlib_uninit.c b/libs/libc/elf/elf_uninit.c similarity index 86% rename from libs/libc/modlib/modlib_uninit.c rename to libs/libc/elf/elf_uninit.c index e6c22edf76..e496cdf979 100644 --- a/libs/libc/modlib/modlib_uninit.c +++ b/libs/libc/elf/elf_uninit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_uninit.c + * libs/libc/elf/elf_uninit.c * * SPDX-License-Identifier: Apache-2.0 * @@ -30,21 +30,21 @@ #include #include -#include +#include #include "libc.h" -#include "modlib/modlib.h" +#include "elf/elf.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * 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 @@ -52,11 +52,11 @@ * ****************************************************************************/ -int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo) +int libelf_uninitialize(FAR struct mod_loadinfo_s *loadinfo) { /* Free all working buffers */ - modlib_freebuffers(loadinfo); + libelf_freebuffers(loadinfo); /* Close the ELF file */ @@ -70,7 +70,7 @@ int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo) } /**************************************************************************** - * Name: modlib_freebuffers + * Name: libelf_freebuffers * * Description: * Release all working buffers. @@ -81,7 +81,7 @@ int modlib_uninitialize(FAR struct mod_loadinfo_s *loadinfo) * ****************************************************************************/ -int modlib_freebuffers(FAR struct mod_loadinfo_s *loadinfo) +int libelf_freebuffers(FAR struct mod_loadinfo_s *loadinfo) { /* Release all working allocations */ diff --git a/libs/libc/modlib/modlib_unload.c b/libs/libc/elf/elf_unload.c similarity index 92% rename from libs/libc/modlib/modlib_unload.c rename to libs/libc/elf/elf_unload.c index 252390b030..c151824041 100644 --- a/libs/libc/modlib/modlib_unload.c +++ b/libs/libc/elf/elf_unload.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_unload.c + * libs/libc/elf/elf_unload.c * * SPDX-License-Identifier: Apache-2.0 * @@ -30,21 +30,21 @@ #include #include -#include +#include #include "libc.h" -#include "modlib/modlib.h" +#include "elf/elf.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * 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. * * Returned Value: @@ -53,16 +53,16 @@ * ****************************************************************************/ -int modlib_unload(FAR struct mod_loadinfo_s *loadinfo) +int libelf_unload(FAR struct mod_loadinfo_s *loadinfo) { /* Free all working buffers */ - modlib_freebuffers(loadinfo); + libelf_freebuffers(loadinfo); #ifdef CONFIG_ARCH_ADDRENV if (loadinfo->addrenv != NULL) { - modlib_addrenv_free(loadinfo); + libelf_addrenv_free(loadinfo); } else #endif diff --git a/libs/libc/modlib/modlib_verify.c b/libs/libc/elf/elf_verify.c similarity index 95% rename from libs/libc/modlib/modlib_verify.c rename to libs/libc/elf/elf_verify.c index efd947bf3e..28c94f72c6 100644 --- a/libs/libc/modlib/modlib_verify.c +++ b/libs/libc/elf/elf_verify.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/modlib_verify.c + * libs/libc/elf/elf_verify.c * * SPDX-License-Identifier: Apache-2.0 * @@ -32,7 +32,7 @@ #include -#include "modlib/modlib.h" +#include "elf/elf.h" /**************************************************************************** * Private Constant Data @@ -45,7 +45,7 @@ static const char g_modmagic[EI_MAGIC_SIZE] = EI_MAGIC; ****************************************************************************/ /**************************************************************************** - * Name: modlib_verifyheader + * Name: libelf_verifyheader * * Description: * Given the header from a possible ELF executable, verify that it @@ -61,7 +61,7 @@ static const char g_modmagic[EI_MAGIC_SIZE] = EI_MAGIC; * ****************************************************************************/ -int modlib_verifyheader(FAR const Elf_Ehdr *ehdr) +int libelf_verifyheader(FAR const Elf_Ehdr *ehdr) { if (!ehdr) { diff --git a/libs/libc/modlib/gnu-elf.ld.in b/libs/libc/elf/gnu-elf.ld.in similarity index 98% rename from libs/libc/modlib/gnu-elf.ld.in rename to libs/libc/elf/gnu-elf.ld.in index 52287c7a49..340a91df5a 100644 --- a/libs/libc/modlib/gnu-elf.ld.in +++ b/libs/libc/elf/gnu-elf.ld.in @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/modlib/gnu-elf.ld.in + * libs/libc/elf/gnu-elf.ld.in * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/mm/kasan/Kconfig b/mm/kasan/Kconfig index 3c5fbf0599..075f1bf190 100644 --- a/mm/kasan/Kconfig +++ b/mm/kasan/Kconfig @@ -99,7 +99,7 @@ config MM_KASAN_DISABLE_WRITE_PANIC config MM_KASAN_SKIP_ZERO_TAGS bool "Enable skip check zero tags" - default LIBC_MODLIB + default LIBC_ELF ---help--- This option disables checking for zero tags. diff --git a/sched/Kconfig b/sched/Kconfig index 09a7b315a0..aa7a41c667 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -1732,7 +1732,7 @@ endmenu # POSIX Message Queue Options config MODULE bool "Enable loadable OS modules" default n - select LIBC_MODLIB + select LIBC_ELF ---help--- Enable support for loadable OS modules. Default: n diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c index ab17c38ba8..d8c37da15d 100644 --- a/sched/module/mod_insmod.c +++ b/sched/module/mod_insmod.c @@ -27,7 +27,7 @@ #include #include -#include +#include #ifdef CONFIG_MODULE @@ -42,7 +42,7 @@ * 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. @@ -63,7 +63,7 @@ FAR void *insmod(FAR const char *filename, FAR const char *modname) { - return modlib_insert(filename, modname); + return libelf_insert(filename, modname); } #endif /* CONFIG_MODULE */ diff --git a/sched/module/mod_modhandle.c b/sched/module/mod_modhandle.c index 006593feac..10806a8af7 100644 --- a/sched/module/mod_modhandle.c +++ b/sched/module/mod_modhandle.c @@ -27,7 +27,7 @@ #include #include -#include +#include #ifdef CONFIG_MODULE @@ -55,7 +55,7 @@ FAR void *modhandle(FAR const char *name) { - return modlib_gethandle(name); + return libelf_gethandle(name); } #endif /* CONFIG_MODULE */ diff --git a/sched/module/mod_modsym.c b/sched/module/mod_modsym.c index 3a839a2615..a6eb0cea2e 100644 --- a/sched/module/mod_modsym.c +++ b/sched/module/mod_modsym.c @@ -27,7 +27,7 @@ #include #include -#include +#include /**************************************************************************** * Public Functions @@ -64,5 +64,5 @@ FAR const void *modsym(FAR void *handle, FAR const char *name) { - return modlib_getsymbol(handle, name); + return libelf_getsymbol(handle, name); } diff --git a/sched/module/mod_procfs.c b/sched/module/mod_procfs.c index 0644ad3cb8..5394dc46f3 100644 --- a/sched/module/mod_procfs.c +++ b/sched/module/mod_procfs.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -240,7 +240,7 @@ static ssize_t modprocfs_read(FAR struct file *filep, FAR char *buffer, priv->buflen = buflen; priv->offset = filep->f_pos; - ret = modlib_registry_foreach(modprocfs_callback, priv); + ret = libelf_registry_foreach(modprocfs_callback, priv); if (ret >= 0) { filep->f_pos += priv->totalsize; diff --git a/sched/module/mod_rmmod.c b/sched/module/mod_rmmod.c index 933ac1a15c..0d80eb4ad4 100644 --- a/sched/module/mod_rmmod.c +++ b/sched/module/mod_rmmod.c @@ -27,7 +27,7 @@ #include #include -#include +#include #ifdef CONFIG_MODULE @@ -52,7 +52,7 @@ int rmmod(FAR void *handle) { - return modlib_remove(handle); + return libelf_remove(handle); } #endif /* CONFIG_MODULE */ diff --git a/tools/build-globals.sh b/tools/build-globals.sh index 843015a289..73aebd4f72 100755 --- a/tools/build-globals.sh +++ b/tools/build-globals.sh @@ -21,14 +21,14 @@ # ############################################################################ # -# Script to create modlib_global.S which contains a structure define +# Script to create elf_global.S which contains a structure define # the API names and addresses we will export for resolving symbols in # dynamic loaded shared objects. Typically these are libc APIs. # # Symbols to ignore within the NuttX libraries # -FILTER="^lib_low|^FUNCTION|^STUB|^__start|^_vect|^arm_|^arp_|^bch|^binfmt|^blake|^block_|^cdcacm|^chksum|^clock_|^close_|^crypto_|^devif_|^devnull|^devuran|^devzero|^emerg|^epoll_|^elf_|^_dbgR|^dq_|^env_|^file_|^files_|^fs_|^ftl_|^g_|^get_|^group_|^global|^hcom|^i2c_|^inode_|^iob_|^irq_|^kmm_|^lfs_|^lib_|^local_|^mm_|^modlib_|^mpu_|^mq_|^nglobals|^net_|^netdev_|^nx|^pipecommon|^posix_spawn_file|^psock_|^ramlog|^rammap|^readline_|^register_|^sched_|^sockfd|^spawn_|^sq_|^stm32|^symtab_|^syslog_|^syslogstream|^task_|^tcp_|^timer_|^uart_|^ub[12]|^udp_|^umm_|^umount|^unload_|^unregister|^up_|^usb|^usrsock_|^watchdog|^wd_|globalNames$|nglobals$|global_table$|^\.l" +FILTER="^lib_low|^FUNCTION|^STUB|^__start|^_vect|^arm_|^arp_|^bch|^binfmt|^blake|^block_|^cdcacm|^chksum|^clock_|^close_|^crypto_|^devif_|^devnull|^devuran|^devzero|^emerg|^epoll_|^elf_|^_dbgR|^dq_|^env_|^file_|^files_|^fs_|^ftl_|^g_|^get_|^group_|^global|^hcom|^i2c_|^inode_|^iob_|^irq_|^kmm_|^lfs_|^lib_|^local_|^mm_|^elf_|^mpu_|^mq_|^nglobals|^net_|^netdev_|^nx|^pipecommon|^posix_spawn_file|^psock_|^ramlog|^rammap|^readline_|^register_|^sched_|^sockfd|^spawn_|^sq_|^stm32|^symtab_|^syslog_|^syslogstream|^task_|^tcp_|^timer_|^uart_|^ub[12]|^udp_|^umm_|^umount|^unload_|^unregister|^up_|^usb|^usrsock_|^watchdog|^wd_|globalNames$|nglobals$|global_table$|^\.l" if [ -z "${NM}" ]; then NM="nm" @@ -39,10 +39,10 @@ fi # SYMS=`cat System.map | awk '{print $3}' | sort | grep -Ev ${FILTER}` SYM=(${SYMS}) -GLOBALS="libs/libc/modlib/modlib_globals.S" +GLOBALS="libs/libc/elf/elf_globals.S" # -# Generate the modlib_xxxx_globals.S file +# Generate the elf_xxxx_globals.S file # cat >${GLOBALS} <<__EOF__ #ifdef __CYGWIN__ diff --git a/tools/cfgdefine.c b/tools/cfgdefine.c index f50863aecf..674bf3c02f 100644 --- a/tools/cfgdefine.c +++ b/tools/cfgdefine.c @@ -57,8 +57,8 @@ static const char *dequote_list[] = "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 */ diff --git a/tools/mkexport.sh b/tools/mkexport.sh index a37a75e537..9d8c42d9c6 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -188,7 +188,7 @@ APPLD=gnu-elf.ld if [ -f "${BOARDDIR}/scripts/${APPLD}" ]; then cp -f "${BOARDDIR}/scripts/${APPLD}" "${EXPORTDIR}/scripts/." else - cp -f "${TOPDIR}/libs/libc/modlib/${APPLD}" "${EXPORTDIR}/scripts/." + cp -f "${TOPDIR}/libs/libc/elf/${APPLD}" "${EXPORTDIR}/scripts/." fi if [ "${NUTTX_BUILD}" = "kernel" ]; then @@ -231,7 +231,7 @@ if [ "X${USRONLY}" != "Xy" ]; then done fi -# Drop kernel folder modlib/gnu-elf.ld as the exported script shall suffice +# Drop kernel folder elf/gnu-elf.ld as the exported script shall suffice LDELFFLAGS=$(echo "$LDELFFLAGS" | sed -e 's:-T.*ld::')