Skip to content

examples/fdpicxip: Build the module fixtures without nuttx/tools/fdpic. - #3762

Open
casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:fdpicxip-in-tree
Open

examples/fdpicxip: Build the module fixtures without nuttx/tools/fdpic.#3762
casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:fdpicxip-in-tree

Conversation

@casaroli

@casaroli casaroli commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

depends-on: [apache/nuttx/pull/19940]

Summary

The FDPIC modules this example and testing/fs/xipfs carry are built by an explicit make regen, which reached into nuttx/tools/fdpic for a makefile, a script that turned a module into a header, and two more that checked its imports.

Review of apache/nuttx#19940 asked that NuttX not carry a module build of its own, and it no longer does: with CONFIG_FDPIC an ordinary module is built by apps/Application.mk like any other. What these fixtures need comes here instead, and it is much less.

They keep a build at all because they are loader edge cases, not ordinary modules: a library with a SONAME, a module with more DT_NEEDED entries than the loader will follow, one whose imports stay in the lazy binding table, and one naming a symbol the firmware does not export, which exists to be refused. Application.mk cannot say -soname, or "no entry point", or "link against that other module".

What arrives is 145 changed lines in the makefile that was already here, plus a 24-line license template. What does not arrive is four files and 536 lines:

  • the generic module makefile, which existed to be included by anything and was only ever included here
  • fdpic-embed.py, because xxd -i does that and examples/elf already uses it that way
  • fdpic-verify.sh and nuttx-exports.sh, with no replacement: they checked at build time what the xipfs suite already asserts at run time

The fixtures also stop carrying a crt0 and a linker script. Both come from the tree named by NUTTX_DIR, which is where the in-tree build takes them. The crt0 source is compiled here rather than the built object taken, because these are deliberately built for cortex-m3 while the firmware is not: a v7-M module runs on both v7-M and v8-M targets, so one set of headers serves the RP2350 and mps2-an500 alike.

Impact

None on any build. make regen is not part of the application build and nothing else runs these files. The *_bin.h headers stay committed, so both apps still build with a plain toolchain and no FDPIC linker.

NUTTX_DIR now has to be configured with CONFIG_FDPIC, because that is what puts the FDPIC segments in the generated gnu-elf.ld.

The committed headers are unchanged here. They will change when next regenerated, because a fixture now carries the tree's crt0 rather than one of its own, and that is a change the xipfs suite should be run against rather than made blind.

Testing

Rebuilt three fixtures from clean against a tree configured with CONFIG_FDPIC, covering both kinds and both languages: qsorter (C module), libshape (C++ library) and cxxuser (C++ module linked against it).

$ readelf -h qsorter.fdpic
  OS/ABI:      ARM FDPIC
  Entry point: 0x1              <- _start, from the tree's crt0
$ readelf -A qsorter.fdpic
  Tag_CPU_arch: v7
$ readelf -d libshape.fdpic
  0x0e (SONAME)      Library soname: [libshape.so]
  0x19 (INIT_ARRAY)  0x1000

Two PT_LOAD segments, and v7-M as intended rather than the firmware's v8-M.

callback is the one fixture not rebuilt here: it uses SIGEV_THREAD, so it needs a tree with CONFIG_SIG_EVTHREAD.

tools/checkpatch.sh -c -u -m -g passes.

The modules this example and testing/fs/xipfs carry are built by an explicit
'make regen', which reached into nuttx/tools/fdpic for a makefile that builds
a module, a script that turns one into a header, and two more that checked
its imports.  Review of apache/nuttx#19940 asked that NuttX not carry a
module build of its own, and it no longer does: with CONFIG_FDPIC an
ordinary FDPIC module is built by apps/Application.mk like any other.

These are not ordinary modules, which is why they keep a build of their own.
They are fixtures for loader edge cases: a library with a SONAME, a module
with more DT_NEEDED entries than the loader will follow, one whose imports
stay in the lazy binding table, and one naming a symbol the firmware does
not export, which exists to be refused.  Application.mk cannot say any of
that.  So the build stays, and it is here beside them rather than in NuttX.

It is also much smaller.  The generic module makefile is gone: it existed to
be included by anything, and only this one directory ever did, so its dozen
useful lines are rules here.  fdpic-embed.py is gone: xxd does that, as
examples/elf already does it, and the license header it also wrote is a
template beside it.  fdpic-verify.sh and nuttx-exports.sh are gone with no
replacement; they checked at build time what the xipfs suite already asserts
at run time, for two hundred lines.

What the fixtures no longer carry is a crt0 and a linker script.  Both come
from the tree named by NUTTX_DIR, which is where the in-tree module build
takes them, so a fixture is built the way a module is.  The crt0 source is
compiled here rather than the built object taken, because these are
deliberately built for cortex-m3 while the firmware is not: a v7-M module
runs on both the v7-M and v8-M targets, so one set of headers serves the
RP2350 and mps2-an500 alike.

Regenerated qsorter, libshape and cxxuser against a tree configured with
CONFIG_FDPIC.  qsorter is ARM FDPIC, v7-M, two PT_LOAD segments, entering at
_start; libshape carries its SONAME and its DT_INIT_ARRAY.

The committed headers are left as they are.  They will change when they are
next regenerated, because a fixture now carries the tree's crt0 rather than
one of its own, and that is a change the xipfs suite should be run against
rather than made blind.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/33193062300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant