nuttx/include
Marco Casaroli d5b4edd761 binfmt/fdpic: Run constructors, and bind the PLT relocation table.
Two gaps that both fail quietly.

DT_INIT_ARRAY and DT_FINI_ARRAY were ignored entirely.  A C++ module with
any global object therefore loaded, resolved every symbol and ran, with all
of its globals left as .bss reading back zero -- no fault, no log, just
wrong answers.  Both arrays are now walked per object and in dependency
order: an object joins the load's list before the DT_NEEDED walk appends its
own dependencies, so walking that list backwards constructs a library before
the module that needs it, and destruction mirrors it.

Constructors run in whichever task called the loader, before the module's
own task exists, so the FDPIC register does not already hold the object's
data base the way it does once the module is running.  fdpic_callfn()
installs it around each call.  That is safe only because the firmware
reserves the register; being preempted mid-constructor is harmless, since
the register is part of the saved context.

DT_JMPREL was not parsed at all.  Which table an imported function's
descriptor lands in is a linker decision -- -z now puts it in DT_REL, and
without it the same entry goes to DT_JMPREL -- so a module linked the second
way loaded cleanly and then branched to an unrelocated address on its first
call into the firmware.  The symptom is an INVSTATE UsageFault escalated to
a HardFault: no console, no crash dump.  There is no lazy resolver here, so
an unwalked table is not deferred work; both are now bound eagerly, and
nothing is lost by that because a module carries a handful of relocations.

The two tables are not walked identically, which is the part worth
remembering.  In DT_REL the word being overwritten is the addend, and
dropping it breaks a static function reached through its section symbol.  In
DT_JMPREL that same word is the lazy-binding bootstrap -- the address of the
entry's own PLT resolution stub, with a GOT half of -1 -- and adding it to
the resolved symbol value produces an arbitrary address that faults exactly
like the bug this change fixes.  An eager binder overwrites the descriptor
outright.

The descriptor pool is sized from relsize + pltrelsz rather than relsize
alone, so an R_ARM_FUNCDESC in the PLT table cannot run off the end of the
allocation.  GNU ld does not appear to emit that combination -- an
address-taken function is not a call and so never becomes a PLT relocation
-- but the failure it would cause is heap corruption, and the guard is two
additions.

An object declaring RELA PLT relocations is refused rather than misread:
nothing here reads RELA, whose entries are twelve bytes rather than eight.

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-01 12:23:27 +02:00
..
android
arpa
crypto crypto: add CRYPTO_AES_CTR_SSH variant (128-bit big-endian counter) 2026-07-16 15:42:10 +08:00
cxx include/cxx/ctime: Add localtime to std namespace. 2026-06-09 11:33:40 -03:00
net forward: Add IFF_NOSRC_FORWARD and IFF_NODST_FORWARD flags. 2026-01-31 02:37:58 +08:00
netinet netinet/in.h: Rename imr_interface to imr_address in struct ip_mreqn. 2026-01-16 09:42:12 +08:00
netpacket net/packet: add PACKET_<ADD|DROP>_MEMBERSHIP support 2025-12-25 10:01:43 +08:00
nuttx binfmt/fdpic: Run constructors, and bind the PLT relocation table. 2026-08-01 12:23:27 +02:00
ssp
sys sched/group: add getresuid, getresgid, setreuid, and setregid 2026-07-30 09:48:10 +08:00
.gitignore ci: add stdbit.h test 2026-06-29 14:44:17 +02:00
aio.h
alloca.h
assert.h
byteswap.h
ctype.h
debug.h style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
dirent.h fs/dirent: add d_ino member to struct dirent 2026-06-26 10:45:33 -04:00
dlfcn.h
dsp.h libs/libdsp: Add Matrix operations 2026-07-11 14:55:59 -03:00
dspb16.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
elf.h include/elf.h: Add the DT_*_ARRAY dynamic tags. 2026-08-01 12:23:27 +02:00
elf32.h
elf64.h
endian.h
err.h
errno.h include/errno.h: skip set_errno in interrupt context 2026-05-03 17:23:40 -03:00
execinfo.h
fcntl.h !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
fixedmath.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
fnmatch.h
ftw.h
gcov.h gcov: Refactoring the implementation framework of gcov 2025-07-03 00:17:58 +08:00
getopt.h
glob.h
grp.h libc/grp: add getgrouplist() 2026-06-23 23:09:22 +08:00
hex2bin.h
iconv.h
ifaddrs.h
imx_container.h arch/arm64/imx9: Add ROMAPI and AHAB support for i.MX9 2025-05-09 19:21:17 +08:00
inttypes.h !sched/clock: remove CONFIG_SYSTEM_TIME64 and always use 64-bit time 2026-05-19 16:21:28 +08:00
iso646.h
langinfo.h
libgen.h
libintl.h
limits.h !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
locale.h style/FAR: remove FAR qualifier 2025-11-10 10:56:29 +01:00
lzf.h lzf: prevent lzf header struct optimization 2026-02-13 11:58:50 +01:00
malloc.h
mqueue.h [POSIX][Bug] mqueue.h: Include file does not conform the standard 2024-12-09 21:21:09 +08:00
netdb.h
nl_types.h
nxflat.h
obstack.h
poll.h
pthread.h include/pthread : initialize wait_count in PTHREAD_COND_INITIALIZER 2026-06-16 19:12:30 -03:00
pty.h
pwd.h
regex.h
resolv.h
sched.h sched: remove csection and reduce the interrupt disabling time in sched_[un]lock 2025-01-23 19:58:49 +08:00
search.h LICENSE: update NuttX-PublicDomain SPDX identifier 2025-12-26 19:46:12 +08:00
semaphore.h sched/semaphore: add support to customize semaphore max allowed value 2025-09-04 09:48:34 +08:00
shadow.h
signal.h sched/timer: Fix MISRA Rule 10.4 2026-01-22 22:14:00 +08:00
spawn.h sched/spawn: Fix MISRA C 2012 Rule 10.4 violations 2026-02-02 20:39:36 +08:00
stdbool.h
stddef.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
stdint.h arm64_head.S: fix the asm code build error 2026-01-13 21:20:52 +08:00
stdio.h stdio.h: Update TMP_MAX definition to match Linux. 2026-01-14 17:28:30 -08:00
stdlib.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
stdnoreturn.h
string.h include/string.h: mark memset and memcpy as used_code 2026-02-12 13:19:06 -05:00
strings.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
syscall.h
syslog.h drivers/syslog: Add RFC 5424 protocol support 2025-06-13 20:26:57 +08:00
termios.h include: modify for support socat, so need add some macro same as linux 2025-12-10 23:44:14 +08:00
threads.h include/threads.h: Replace thrd_ defines by actual function definitions 2024-12-19 21:56:02 +08:00
time.h
ulimit.h ulimit: add ulimit implementation 2026-01-16 10:03:53 +08:00
unistd.h sched/group: add getresuid, getresgid, setreuid, and setregid 2026-07-30 09:48:10 +08:00
utime.h
uuid.h
wait.h wait: add wait.h header file 2024-12-20 11:46:14 -03:00
wchar.h fix misspelled names in locally scoped code 2025-05-15 10:12:12 +08:00
wctype.h