nealef opened a new pull request, #7202: URL: https://github.com/apache/incubator-nuttx/pull/7202
**This is not a real PR**. It follows on from my [presentation](https://www.youtube.com/watch?v=qSvYHhM7hz0&t=4711s) at NuttX 2022 Workshop. It is my 1st attempt to take my changes to our backlevel NuttX repo and apply it to the current master. It is for information only as people expressed a desire to see what was done so I thought this was the best way to do it. #### Caveats * Created specifically for the Meadow project which uses an arm7m - not a general solution * Built using a custom configuration - Important bits: ``` CONFIG_BUILD_PROTECTED=y CONFIG_BUILD_2PASS=y CONFIG_PASS1_TARGET="all" CONFIG_PASS1_BUILDIR="boards/arm/stm32/olimex-stm32-p407/kernel" CONFIG_PASS1_OBJECT="" CONFIG_NUTTX_USERSPACE=0x08020000 : CONFIG_LIBC_DLFCN=y CONFIG_LIBC_MODLIB=y : # # Module library configuration # CONFIG_MODLIB_MAXDEPEND=2 CONFIG_MODLIB_ALIGN_LOG2=2 CONFIG_MODLIB_BUFFERSIZE=32 CONFIG_MODLIB_BUFFERINCR=32 CONFIG_MODLIB_RELOCATION_BUFFERCOUNT=256 CONFIG_MODLIB_SYMBOL_CACHECOUNT=256 ``` * Not tried in other modes other than PROTECTED * Does not handle `.so` objects having dependencies on other `.so` objects * Only armv7-m has its `arch_elf.c` updated with the additional relocation types * It builds cleanly but I have not run to verify functionality #### Change Descriptions * build-globals.sh - Build the modlib_globals.S file used to resolve symbols when dynamically loading - I have not looked at `mksymtab.c` to see if this will generate an architecture-independent of what I am attempting to create with this script * include/elf.h - Add definitions that may be found in shared objects * include/nuttx/lib/modlib.h - Add fields to mod_loadifno_s: - Program headers - Exported symbols - Data section address - Padding requirement - Section index for dynamic symbol table - Number of symbols exported - Add prottotype for modlib_freesymtab * libs/libc/dlfcn/lib_dlclose.c - Free the symbol table when the dll is closed * libs/libc/dlfcn/lib_dlopen.c - Add dump of program headers to debug routine - Differentiate between ET_REL and ET_DYN objects * libs/libc/machine/arm/armv7-m/arch_elf.c - Add handling of R_ARM_RELATIVE and R_ARM_JUMP slot relocation types * libs/libc/modlib/Make.defs - Include new file containing library APIs used when loading shared objects * libs/libc/modlib/modlib.h - Add parameter to modlib_readsym prototype - Add prototypes for: - modlib_insertsymtab - modlib_findglobal * libs/libc/modlib/modlib_loadshdrs.c - Rename modlib_loadshdrs.c to modlib_loadhdrs.c - Rename modlib_loadshdrs to modlib_loadhdrs - Add code to load program headers * libs/libc/modlib/modlib_bind.c - Call modlib_readsym with pointer to symbol table - Add modlib_relocatedyn to manage relocation of symbols with shared object (ET_DYN) - Differentiate between ET_REL and ET_DYN objects * libs/libc/modlib/modlib_load.c - Calculate sizes and text/data addresses based on program headers rather than section headers * libs/libc/modlib/modlib_symbols.c - Define entry point structure - Add offset parameter to modlib_symname() and use to find symbol names - Add symtab section header parameter to modlib_readsym() - Add offset parameter to modlib_symvalue() to locate symbol names - Add modlib_insertsyntab() to create a symbol table for exporting and resolution - Add findEP() to resolve a symbol in the modlib_global table - Add modlib_findglobal() to find symbol in the modlib_global table - Add modlib_freesymtab() to free the symbol table * libs/libc/modlib/modlib_uninit.c - Free header and sections from a module_loadinfo_s control block * libs/libc/modlib/modlib_verify.c - Handle ET_DYN shared objects * libs/libc/modlib/modlib_globals.S - Define library APIs that may be resolved when loading a shared object -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org