-
Notifications
You must be signed in to change notification settings - Fork 1.7k
libs/libc/elf: Load FDPIC modules through the ELF loader #19673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
casaroli
wants to merge
12
commits into
apache:master
Choose a base branch
from
casaroli:fdpic-libelf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,029
−71
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df030ba
libs/libc/elf: Translate link-time addresses through one place.
casaroli b0bc654
libs/libc/elf: Place an FDPIC object's segments independently.
casaroli 30949dc
libs/libc/elf: Read the dynamic tags an FDPIC object needs.
casaroli cfe76c3
libs/libc/machine/arm: Relocate FDPIC function descriptors.
casaroli c570026
libc, sched: Resolve FDPIC descriptors at module callback entry points.
casaroli b41981e
binfmt/elf: Load FDPIC modules through the ELF loader.
casaroli 5c09003
libs/libc/elf: Fix two ways an FDPIC module failed to relocate.
casaroli f827aad
libs/libc/elf: Publish FDPIC functions as descriptors for dlsym.
casaroli 34e87cb
libs/libc/elf: Load DT_NEEDED libraries with dlopen().
casaroli c628158
tools/fdpic: Add the module build helpers the demo apps use.
casaroli 026c9e6
Documentation: Describe the FDPIC module support.
casaroli 2c598c9
boards/rp23xx: Add an FDPIC configuration for the Pimoroni Pico Plus 2.
casaroli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| ===================================== | ||
| fdpic: FDPIC module build tooling | ||
| ===================================== | ||
|
|
||
| ``tools/fdpic`` is everything needed to build an FDPIC module out of tree. A | ||
| module is an ELF shared object whose read-only segment the target maps straight | ||
| out of flash and executes in place, while its writable segment is copied to RAM | ||
| once per running instance. It links against nothing: libc and everything else | ||
| are imported from the firmware's exported symbol table at load time. | ||
|
|
||
| The loader that consumes these modules is the ELF loader, enabled by | ||
| ``CONFIG_FDPIC``. The format, the toolchain and the load-time contract are | ||
| described in :doc:`/components/fdpic`. | ||
|
|
||
| Contents | ||
| ======== | ||
|
|
||
| ============================ ================================================== | ||
| File Purpose | ||
| ============================ ================================================== | ||
| ``nuttx-fdpic.mk`` The module build itself; include it from a | ||
| two-line makefile | ||
| ``fdpic-verify.sh`` Checks a built module's imports resolve against | ||
| the firmware | ||
| ``nuttx-exports.sh`` Turns ``libs/libc/exec_symtab.c`` into a symbol | ||
| list | ||
| ``fdpic-embed.py`` Turns a built module into a C header, for carrying | ||
| one inside an image | ||
| ``build-binutils.sh`` Builds the ``arm-uclinuxfdpiceabi`` binutils, the | ||
| one from-source dependency | ||
| ============================ ================================================== | ||
|
|
||
| Building a module | ||
| ================= | ||
|
|
||
| A whole module is three lines of makefile beside the source. Taking | ||
| ``apps/examples/fdpicxip/modules/qsorter.c``, which is a module in its own | ||
| right, as the source: | ||
|
|
||
| .. code:: makefile | ||
|
|
||
| MODULE = qsorter | ||
| SRCS = qsorter.c | ||
|
|
||
| include /path/to/nuttx/tools/fdpic/nuttx-fdpic.mk | ||
|
|
||
| Then: | ||
|
|
||
| .. code:: console | ||
|
|
||
| $ make NUTTX_DIR=/path/to/nuttx | ||
| CC qsorter.c | ||
| LD qsorter.fdpic | ||
| OK qsorter.fdpic: FDPIC, entry 0x2a1, 4 imports resolved | ||
|
|
||
| ``NUTTX_DIR`` has to be a configured, built tree: the compile needs its headers | ||
| and the verify step needs the export table generated into | ||
| ``libs/libc/exec_symtab.c``. | ||
|
|
||
| Toolchain | ||
| ========= | ||
|
|
||
| Two toolchains are involved. The stock ``arm-none-eabi`` compiler does the | ||
| compiling -- it emits perfectly good FDPIC objects for both C and C++ -- and | ||
| ``arm-uclinuxfdpiceabi`` **binutils** does the linking, because | ||
| ``arm-none-eabi-ld`` cannot produce an FDPIC object at all. So the | ||
| from-source dependency is binutils alone, which ``build-binutils.sh`` builds in | ||
| about a minute. | ||
|
|
||
| Verification runs as part of the default target on purpose: a module that | ||
| imports a symbol the firmware does not export links perfectly happily and fails | ||
| only once it is on the target, as a bare ``-ENOENT`` that names nothing. | ||
|
|
||
| Modules carried inside an image | ||
| =============================== | ||
|
|
||
| ``fdpic-embed.py`` exists for applications that have to load a module before | ||
| there is any way to put files on the target, so they embed one and write it out | ||
| at run time. ``apps/examples/fdpicxip/modules/`` uses it that way, and is the | ||
| worked example of driving this tooling for several modules at once. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to the firdt patch which add ELF_FDPIC