mirror of
https://github.com/apache/nuttx.git
synced 2026-09-29 18:45:22 +00:00
exec() of an FDPIC module now works. The loader already places such an object and binds it; what was missing is everything binfmt has to carry across from the load to the running task. The task needs the module's data base in its PIC base register. binfmt builds a D-Space for any object with a GOT, taking the base from the .got section address; an FDPIC object names it in DT_PLTGOT instead, which the loader has already translated, so the two are the same idea reached by different routes and both are what up_initial_state() installs. Constructors are not binfmt's business. A module carries its own crt0, which walks .init_array on the task that runs the module and then calls main, so they run in the module's own context and with its own data base. For a module that arrives through dlopen(), libelf_insert() walks the array instead, and it enters each entry through fdpic_invoke() because a descriptor resolved on the calling task carries the wrong base. The read-only segment of a module that executes in place is held by a filesystem pin. The load takes it, and the module owns it from the point where nothing can fail any more; it is given back when the task that runs the module exits. The pin is held through a reference to the file rather than a descriptor, because the descriptor belongs to the task that called the loader and the release happens on another one. libelf_remove() and libelf_uninit() give back what an FDPIC module holds: the pin, and the writable segment, while the read-only one is media rather than an allocation and must not be freed. Built for mps3-an547:picostest with CONFIG_FDPIC both ways. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com> |
||
|---|---|---|
| .. | ||
| libnxflat | ||
| binfmt.h | ||
| binfmt_checkexec.c | ||
| binfmt_copyactions.c | ||
| binfmt_copyargv.c | ||
| binfmt_dumpmodule.c | ||
| binfmt_exec.c | ||
| binfmt_execmodule.c | ||
| binfmt_execsymtab.c | ||
| binfmt_exit.c | ||
| binfmt_globals.c | ||
| binfmt_initialize.c | ||
| binfmt_loadmodule.c | ||
| binfmt_register.c | ||
| binfmt_unloadmodule.c | ||
| binfmt_unregister.c | ||
| builtin.c | ||
| CMakeLists.txt | ||
| elf.c | ||
| Kconfig | ||
| Makefile | ||
| nxflat.c | ||