[7.5/10] arch/arm: Build a loadable module and a shared library as FDPIC too. - #20360
Merged
Merged
Conversation
CONFIG_FDPIC teaches the ELF module path what an FDPIC object is, so an application built as a module gets -mfdpic -fPIC and the arm-uclinuxfdpiceabi linker. The loadable module path, which apps builds with DYNLIB = y and which apps/Library.mk uses for a shared library, was left as it was: a -r partial link with the stock linker. That leaves an object with no dynamic section, so the loader has nothing to bind an import to, and there is no way to build a library an FDPIC module can call. Give that path the same treatment. CMODULEFLAGS and CXXMODULEFLAGS gain the FDPIC compiler flags, and LDMODULEFLAGS links a shared object rather than a partial one. The entry point is left to the caller, because a module is entered at _start while a library is only ever called into. CXXMODULEFLAGS is also defined for the first time. apps/Library.mk compiles every C++ source of a shared library with it and no architecture defined it, so those sources were compiled with no architecture flags at all. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
fdpic-module-flags
branch
from
September 25, 2026 09:38
b40aced to
74d0b38
Compare
xiaoxiang781216
approved these changes
Sep 25, 2026
acassis
approved these changes
Sep 25, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Part of the FDPIC series.
[5.5/10]#19940 taught the ELF module path what an FDPIC object is, so an application built as a module gets-mfdpic -fPICand thearm-uclinuxfdpiceabilinker, and comes out a shared object the loader can bind.The loadable module path was left behind.
apps/Application.mkreaches it withDYNLIB = y,apps/Library.mkbuilds every shared library with it, and it is still a-rpartial link with the stock linker. Such an object has no dynamic section, so nothing can bind an import to it, and there is no way to build a library an FDPIC module can call.So
CMODULEFLAGSandCXXMODULEFLAGSgain the same compiler flags, andLDMODULEFLAGSlinks a shared object rather than a partial one. The entry point stays with the caller, because a module is entered at_startwhile a library is only ever called into.CXXMODULEFLAGSis defined here for the first time.apps/Library.mkcompiles every C++ source of a shared library with it and no architecture ever defined it, so those sources were compiled with no architecture flags at all.apache/nuttx-apps#3762 is the first user: its module fixtures stop hand-rolling the link and use these variables.
Impact
Everything else is under
CONFIG_FDPIC, which defaults off and is selectable only whereARCH_HAVE_ELF_FDPICis set.CXXMODULEFLAGSreplaces nothing, since it was empty.Testing
Compiled and linked a library with the variables this patch produces, taken from a
pimoroni-pico-2-plustree configured withCONFIG_FDPIC:Two
PT_LOADsegments,R EandRW, as an FDPIC object needs.tools/checkpatch.sh -c -u -m -gpasses.