examples/fdpicxip, testing/fs/xipfs: A DT_NEEDED library is one instance - #3693
Conversation
| FDPICDIR = $(NUTTX_DIR)/tools/fdpic | ||
| MODULE_MK = $(FDPICDIR)/nuttx-fdpic.mk | ||
| EMBED = $(FDPICDIR)/fdpic-embed | ||
| EMBED = $(FDPICDIR)/fdpic-embed.py |
There was a problem hiding this comment.
could we integrate fdpic special process into the post link after you corporate fdpic into elf binfmt?
There was a problem hiding this comment.
for building fdpic modules, we can do with stock gcc, however for linking them we need upstream binutils rebuilt with arm-uclinuxfdpiceabi-ld, as stock arm ld does not ship with it:
$ arm-none-eabi-ld -V
GNU ld (Arm GNU Toolchain 15.2.Rel1) 2.45.1
Supported emulations:
armelf
What do you suggest? can we include the "custom" binutils in the CI image?
There was a problem hiding this comment.
we can change LD in Tooldefine.def to the special version if CONFIG_FDPIC is enabled.
What do you suggest? can we include the "custom" binutils in the CI image?
we can add the prebuilt tool to Dockfile directly:
https://github.com/apache/nuttx/blob/master/tools/ci/docker/linux/Dockerfile
if the tool doesn't have the official release binary, we can build from scratch like bloaty:
https://github.com/apache/nuttx/blob/master/tools/ci/docker/linux/Dockerfile
The two helper scripts this Makefile names gained a file extension when tools/fdpic came into the nuttx tree: checkpatch rejects an executable file that is not .sh, .py or .bat. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
…nce. Both the demo and the test asserted that each running instance of a module gets its own copy of a library named in DT_NEEDED: two instances adding their own seed each saw a total of seed*3. That was true of the loader that walked DT_NEEDED itself. The loader now hands the work to dlopen(), which returns the object already in the module registry rather than loading a second copy of it, so there is one library and one set of its globals, shared by every module that names it. The module's own data stays private per instance, because exec() loads the module afresh each time. What an instance can still assert on its own is that every add it made landed in the library, so that is what it checks; the totals interleave and the final one counts both. The test additionally checks the consequences: the library is pinned once rather than once per instance, and its destructor runs once, at the last close, holding what both instances built up. USER_FAIL_PRIVATE becomes USER_FAIL_SHARED rather than gaining a companion. The bit is a private protocol between cxxuser.cpp, which sets it, and testing/fs/xipfs, which reads it; nothing else names it, and the property it used to report no longer exists. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
Summary
examples/fdpicxipandtesting/fs/xipfsassert that each running instance of a module gets its own copy of a library named inDT_NEEDED: two instances adding their own seed each saw a total ofseed * 3.That was true of the loader that walked
DT_NEEDEDitself. The loader now hands the work todlopen(), which returns the object already in the module registry rather than loading a second copy, so there is one library and one set of its globals, shared by every module that names it. The module's own data stays private per instance, becauseexec()loads the module afresh each time.What an instance can still assert on its own is that every add it made landed in the library, so that is what it checks. The test additionally checks the consequences: the library is pinned once rather than once per instance, and its destructor runs once, at the last close, holding what both instances built up.
The embedded module blobs are regenerated from the sources beside them.
depends-on: [apache/nuttx/pull/19673]
Testing
Run in full on QEMU
mps2-an500and on a Pimoroni Pico Plus 2 (RP2350), against apache/nuttx#19673.