nuttx/libs/libc
Marco Casaroli 4cdd3cdbda arch/arm, libs/libc/elf: Build FDPIC modules in the normal ELF build.
With CONFIG_FDPIC selected, a module built by apps/Application.mk is now an
FDPIC shared object.  Nothing about how a module is written or built
changes: the same MODULE = m in the same Makefile, the same crt0 and the
same linker script.

Two things differ from the position independent build beside it.  The
compiler is told -mfdpic -fPIC, and the link is done by an
arm-uclinuxfdpiceabi linker.  The stock arm-none-eabi compiler emits correct
FDPIC objects for both C and C++, so only the link needs it: the stock
linker carries the armelf emulation alone and would turn every import into
an R_ARM_JUMP_SLOT, one word, where the ABI wants an R_ARM_FUNCDESC_VALUE,
which is two, a code address and the data base that goes with it.  Such a
module links cleanly and then calls out of itself with the caller's data
base still in r9.  That linker is in the CI image.

gnu-elf.ld.in gains the two segments an FDPIC module needs, under
CONFIG_FDPIC, because the loader places its read-only and writable segments
independently, and names .dynamic, because a shared object is bound through
it.  The sections themselves are untouched and so are the symbols crt0.c
walks, so one script serves both and both build systems get it.

.bss moves to the end of the script, for every configuration and not only
FDPIC.  It held no file content but sat ahead of .got and .dynamic, which
do, so the writable segment's p_filesz had to span it and the module file
carried the whole of .bss.  A module with 16 KiB of .bss went from 26724 to
10340 bytes, and its writable segment from p_filesz 0x40ac to 0xac against
an unchanged p_memsz.  The loader reads p_filesz off the media, so it read
those bytes too.

Built for mps3-an547:picostest with apps/examples/elf, CONFIG_FDPIC both
ways.  With it on, every module in apps/bin is ARM FDPIC with two PT_LOAD
segments and enters at _start; hello++3, which has a static C++ object,
carries DT_INIT_ARRAY and DT_FINI_ARRAY.  With it off the generated script
has no PHDRS and the modules are what they were.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-09-09 10:21:21 +08:00
..
aio include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
assert lib_stackchk.c: a duplicate implementation error reported during compilation 2026-02-02 13:22:07 +08:00
audio include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
builtin libc/builtin: support per-application priority/stacksize under KERNEL build. 2026-07-13 15:23:39 -03:00
ctype style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
dirent libs/libc/dirent: preserve errno on readdir() end-of-directory 2026-06-02 23:34:25 +08:00
dlfcn libc/dlfcn: Count opens so a library can be shared. 2026-08-04 11:12:49 -03:00
elf arch/arm, libs/libc/elf: Build FDPIC modules in the normal ELF build. 2026-09-09 10:21:21 +08:00
errno libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
eventfd libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
fdt cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
fixedmath !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
gdbstub arch/arm64: fix backtrace register access and gdbstub config guard 2026-01-16 08:55:47 -03:00
gnssutils cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
grp libs/libc/grp: fix getgrbuf_r() pointer-alignment padding 2026-08-14 10:20:52 +08:00
hex2bin include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
inttypes !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
libgen libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
locale style/FAR: remove FAR qualifier 2025-11-10 10:56:29 +01:00
lzf !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
machine libs/libc/machine/arm: Fix the nxstyle errors in arch_elf.c. 2026-09-01 09:16:39 +08:00
misc nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
net include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
netdb libs/libc/netdb: Size an answer header by its header, not by its union. 2026-08-08 15:02:15 -03:00
obstack include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
pthread nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
pwd sched: add supplementary group IDs (setgroups/getgroups/initgroups) 2026-08-12 16:06:03 -03:00
queue libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
regex libs/libc/regex: remove logically dead code in regcomp.c 2026-01-24 19:28:56 +08:00
sched include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
search libc/search: add foreach api for hcreate_data 2025-12-25 09:39:03 +08:00
semaphore sched/semaphore: Keep a negative task id out of the mutex holder. 2026-08-09 10:05:30 +08:00
signal sched/signal: Add support for disabling all signal functions 2026-01-18 08:24:13 -03:00
spawn spawn: allow zero stacksize/priority to use binary loader defaults 2026-07-15 12:24:44 -03:00
stdio !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
stdlib fs: rename PSEUDOFS_SOFTLINKS to FS_LINKS 2026-08-27 01:12:33 +08:00
stream libc/stream: Check lowout bounds before access 2026-07-06 09:02:22 +02:00
string libs/libc/string: Copy and compare by words when pointers agree on alignment. 2026-08-24 12:02:02 +08:00
symtab libs/libc/symtab: fix bogus symbol size under SYMTAB_ORDEREDBYNAME 2026-08-05 21:51:25 +08:00
syslog drivers/syslog: Add RFC 5424 protocol support 2025-06-13 20:26:57 +08:00
termios drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00
time libc/time: Fix POSIX timezone string parsing. 2026-07-25 19:54:18 +08:00
tls libc/tls: update preprocessor condition comment to match implementation 2026-01-31 02:49:10 +08:00
uio move readv/writev to the kernel 2024-10-30 17:07:54 +08:00
unistd libc/limits: increase LINK_MAX to 128 and fix pathconf 2026-08-28 23:07:24 +08:00
userfs include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
uuid libc: Refine the arc4random_buf implementation 2024-10-26 18:04:21 -03:00
wchar style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
wctype libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
wqueue libc/wqueue: use the uninterruptible wait helper 2026-09-04 23:02:48 +08:00
zoneinfo tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
.gitignore libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
CMakeLists.txt libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
Kconfig libc/elf: rename modlib to libelf 2025-04-11 09:43:22 +08:00
libc.csv !sched/arch/libc: Give fork() and vfork() their real, separate semantics. 2026-08-10 08:57:30 -03:00
libc.h libs/libc/string: Copy and compare by words when pointers agree on alignment. 2026-08-24 12:02:02 +08:00
limits_check.c libs/libc: add limits checks 2026-07-02 09:02:21 -03:00
Makefile tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00