You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/10/07 14:45:20 UTC
(nuttx) 03/06: arch/arm/cmake: Link an FDPIC shared library as a shared object.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f26dbe787090fde0e41e0bafcd4751a12ea48f3c
Author: Marco Casaroli <ma...@gmail.com>
AuthorDate: Tue Oct 6 19:10:02 2026 +0200
arch/arm/cmake: Link an FDPIC shared library as a shared object.
With CONFIG_FDPIC, the CMake build gave the FDPIC options to a loadable
module only. A shared library (DYNLIB) got neither -mfdpic nor the FDPIC
link, but the "-r" link of the non-FDPIC case. So the library was a
relocatable object, and a module that named it in DT_NEEDED did not link:
"multiple definition" and "dangerous relocation".
Give a shared library the same options as a module, as LDMODULEFLAGS and
CMODULEFLAGS in common/Toolchain.defs already do for the make build.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <ma...@gmail.com>
---
arch/arm/src/cmake/elf.cmake | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm/src/cmake/elf.cmake b/arch/arm/src/cmake/elf.cmake
index ab09828847c..2a0b3f61ccb 100644
--- a/arch/arm/src/cmake/elf.cmake
+++ b/arch/arm/src/cmake/elf.cmake
@@ -60,6 +60,13 @@ if(CONFIG_FDPIC)
nuttx_elf_link_options(-m armelf_linux_fdpiceabi -shared -z now)
+ # A shared library is an FDPIC shared object too, as LDMODULEFLAGS makes it in
+ # common/Toolchain.defs
+
+ nuttx_mod_compile_options(-mfdpic -fPIC -Wa,--noexecstack)
+
+ nuttx_mod_link_options(-m armelf_linux_fdpiceabi -shared -z now)
+
elseif(CONFIG_PIC)
# An ELF module needs r9 as its PIC base, so it must not also have the
@@ -81,7 +88,9 @@ if(CONFIG_BINFMT_ELF_RELOCATABLE AND NOT CONFIG_PIC)
nuttx_elf_link_options(-r)
endif()
-nuttx_mod_link_options(-r)
+if(NOT CONFIG_FDPIC)
+ nuttx_mod_link_options(-r)
+endif()
nuttx_elf_link_options_ifdef(CONFIG_BUILD_KERNEL -Bstatic)