nuttx/include/nuttx
Marco Casaroli dcd93b0f67
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
libs/libc/elf: Load the libraries a module names in DT_NEEDED.
A module that names a shared library in DT_NEEDED now gets it loaded and
its imports bound against it, rather than being refused.

libelf_insert() does the loading, which is what dlopen() calls anyway: the
library lands in the module registry like anything else, its exports come
back through libelf_getsymbol() -- the same call dlsym() uses -- and a
library named by two modules is loaded once.  A bare name is looked for
along LD_LIBRARY_PATH, where dlopen() looks for it.  Undefined symbols
resolve against the globally registered symbols first, then the modules
this one depends on, then the table exec() supplied.  Nothing here calls
into dlfcn, because this loader is also the kernel's module loader, which
has none.

Each library becomes one of the module's dependencies[], and the dependency
holds it in place of the reference libelf_insert() took.  So a library
loaded only for DT_NEEDED is kept by the modules that depend on it, and
libelf_undepend() unloads it with the last of them; one that dlopen() or
insmod also opened stays until that reference goes too.
CONFIG_LIBC_ELF_MAXDEPEND bounds how many libraries a module may name,
which is what it already meant.

Six things had to be fixed to make it work, none of which a build shows.

reldata was a file-scope global.  Loading a library from inside
libelf_relocatedyn() makes that function reentrant, so the nested load
overwrote the outer one's relocation offsets and the module resumed binding
with the library's DT_REL.  It is now per call.

A cross-object call needs the callee's data base, not the caller's.  A
symbol resolved from an FDPIC library comes back as a descriptor, and
R_ARM_FUNCDESC_VALUE was treating it as a code address and pairing it with
the importing module's GOT.  It now copies both words, so the library runs
with its own.

An object with no imports has no PLT and so no DT_PLTGOT, but it still has
a GOT and still has to be entered with it.  Without the fallback its
descriptors carried a data base of zero and the library read its globals
through a null pointer.

R_ARM_FUNCDESC, a pointer to a descriptor, wrapped a library's descriptor
in a second one.  It now stores the library's descriptor as it is.

The flag that says a resolved value is a descriptor was set only for an
import and never cleared, so the next relocation against a symbol of the
module itself took that symbol for a descriptor too.  It is cleared there.

libelf_symname() was static, and reading a DT_NEEDED name needs it.

A module with DT_NEEDED is refused where CONFIG_LIBC_ELF_MAXDEPEND is zero,
since that is where the dependency logic is compiled out.

A DT_NEEDED library is one shared instance, its data included, because the
loader returns the object already in the registry.  A module started with
exec() is different: that path loads the module afresh each time, so two
running instances have separate data while sharing one copy of the text.

Built for mps3-an547:picostest with CONFIG_FDPIC both ways.  Run on
mps2-an500:xipfs under QEMU: fdpicxip solib loads libcounter.so by name out
of DT_NEEDED, two instances share one pinned copy of its text, and the
library is unloaded, and its pin given back, when the second one exits.  A
library also opened with dlopen() stays loaded after its DT_NEEDED user
exits, and dlclose() unloads it.

With CONFIG_ARCH_ADDRENV the program runs in its own address space, which
a library libelf_insert() loads cannot reach, so DT_NEEDED is refused
there as before.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-10-06 17:48:49 -03:00
..
1wire 1wire: Move onewire_valid_rom to 1wire_crc.h 2026-06-26 22:50:43 +08:00
aie Documentation,drivers/aie: align machine learning docs with current code 2026-09-19 15:16:18 -03:00
analog analog: add ANIOC_COMP_ENABLE and ANIOC_COMP_DISABLE commands 2026-09-19 22:41:17 +08:00
audio drivers/audio/i2s: Fix unsigned integers in function signatures 2026-07-05 15:06:04 +08:00
binfmt
can sja1000: replace enter_critical_section with spinlock 2026-01-08 09:15:04 -03:00
clk drivers/clk: use uintptr_t for register addresses 2026-06-18 21:52:33 +08:00
contactless
coresight
crypto drivers/crypto: add Microchip RNG90 driver 2026-06-14 18:41:09 +08:00
devfreq driver/devfreq: add procfs for devfreq 2026-08-08 15:23:54 -03:00
dma
drivers serial/uart_rpmsg: add _raw version of driver 2026-02-23 09:19:57 -03:00
eeprom drivers/eeprom: add 24CW160 support 2026-08-06 12:39:36 +02:00
efuse
fs fs/hostfs: add link, symlink, readlink and lstat support 2026-08-28 18:35:37 +08:00
himem
hwspinlock nuttx/hwspinlock: hwspinlock should based on irq instead of spinlock_irq 2026-08-27 11:13:29 +08:00
i2c drivers/i2c: add ioexpander-based lower-half implementation for I2C bit-bang 2026-01-01 17:08:47 +08:00
i3c
input drivers/input: support ST7123 touchscreen controller 2026-08-06 12:42:15 +02:00
ioexpander drivers/ioexpander: add an optional pin PWM operation 2026-09-24 20:16:12 +08:00
lcd style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
leds !drivers/pwm: remove PWM_MULTICHAN option 2026-05-18 11:35:25 -04:00
lib libs/libc/elf: Load the libraries a module names in DT_NEEDED. 2026-10-06 17:48:49 -03:00
linker zbus: Add linker support and documentation for the zbus port 2026-09-21 08:40:14 -03:00
math drivers/math: use small lock to replace enter_critical_section 2026-01-08 11:17:17 +08:00
mbox
mm net/socket: merge CONFIG_NET_TIMESTAMPING into CONFIG_NET_TIMESTAMP 2026-09-18 20:00:49 +08:00
modem style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
motor
mtd drivers/mtd: add MX25UW25645G support 2026-08-19 19:16:00 +02:00
net net/netdev: add NETDEV_TX_STAMP and handle SIOCETHTOOL ETHTOOL_GET_TS_INFO 2026-09-28 12:53:24 -03:00
note note/ram: support multiple noterams to dump data when panic occurs 2026-01-24 19:33:17 +08:00
nx nuttx/nx: compilation error occurs 2026-04-14 13:35:26 +08:00
pci drivers/pci:write legacy num to config space when enable legacy irq 2026-01-30 12:50:42 +08:00
pinctrl drivers/pinctrl: Add pad read-back and a procfs entry. 2026-08-21 20:04:59 +08:00
power drivers/power: Describe the regulators through procfs. 2026-08-18 17:28:02 +08:00
rc
regmap
reset drivers/reset: Add line read-back and a procfs entry. 2026-08-21 20:07:01 +08:00
rf
rpmsg drivers/rpmsg: use NuttX atomic_t API instead of C11 atomics 2026-05-21 06:28:36 +08:00
rptun rptun: add configuring the stack of rptun as static 2026-01-19 14:18:27 +08:00
segger
sensors sensors/adxl367: add I2C accelerometer support 2026-10-06 14:47:12 -03:00
serial drivers/serial: Modify serial/pty to allow NSH/Telnet line edit 2026-07-22 22:07:18 +08:00
spi drivers/mtd: add MX25UW25645G support 2026-08-19 19:16:00 +02:00
syslog driver/ramlog: Implement the rate limiting function for ramlog driver. 2026-01-27 03:17:05 +08:00
timers timers/clkcnt: Round-up when converting nsec to cnt 2026-09-07 10:17:46 -03:00
usb drivers/usbhost: Tell the host stack which controller a port belongs to. 2026-09-28 21:45:57 +08:00
usrsock
vhost drivers/vhost: Optimize vhost-net performance and robustness 2026-09-27 18:41:30 +08:00
video video/videomode: Fix EDID parsing and formatting of video mode dumps 2026-08-29 11:09:11 -03:00
virtio include/nuttx/virtio: allow common virtio helpers to be used by vhost 2026-02-04 02:32:02 +08:00
wireless wireless/lpwan: add SX1301 LoRa concentrator driver 2026-08-06 13:01:39 -03:00
.gitignore
addrenv.h !sched/arch/libc: Give fork() and vfork() their real, separate semantics. 2026-08-10 08:57:30 -03:00
allsyms.h
arch.h arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
ascii.h
atexit.h
atomic.h nuttx/atomic.h: use _Atomic define atomic_t. 2026-08-24 13:20:45 +08:00
bits.h
board.h drivers/usbhost/usbhost_enumerate.c: Allow selecting USB configuration 2026-05-06 06:20:03 +08:00
cache.h nuttx/cache.h: fix the compile warning in sim when enable OpenAMP 2025-12-31 02:36:29 +08:00
can.h
cancelpt.h sched/cancelpt: Fix MISRA C 2012 Rule 10.4 violations 2026-02-02 21:09:40 +08:00
circbuf.h
clock.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
clock_notifier.h fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
compiler.h nuttx/atomic.h: use _Atomic define atomic_t. 2026-08-24 13:20:45 +08:00
coredump.h
crc8.h libs/crc: implement AUTOSAR-compatible CRC algorithm 2026-01-30 17:32:15 +08:00
crc16.h libs/crc: implement AUTOSAR-compatible CRC algorithm 2026-01-30 17:32:15 +08:00
crc32.h libc/crc32: add IEEE-compatible crc32_ieee for Linux/zlib interop 2026-07-03 10:18:28 +08:00
crc64.h !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support 2026-05-19 16:21:28 +08:00
debug.h drivers/clk: Add debug output levels. 2026-08-16 23:23:04 +08:00
devfreq.h drivers/devfreq: Document the frequency table contract. 2026-08-18 09:46:47 -03:00
elf.h libs/libc/elf: Place an FDPIC object's segments independently. 2026-09-08 16:31:16 -03:00
environ.h
envpath.h
ethtool.h net/netdev: add NETDEV_TX_STAMP and handle SIOCETHTOOL ETHTOOL_GET_TS_INFO 2026-09-28 12:53:24 -03:00
event.h
fdcheck.h
fdpic.h binfmt/elf: Load FDPIC modules through the ELF loader. 2026-09-26 11:13:30 -03:00
fdt.h
gdbstub.h
hashtable.h
hrtimer.h sched/hrtimer: Update the comments. 2026-02-02 13:26:22 +08:00
idr.h
init.h sched: add trace points during system startup and board initialization 2026-01-27 03:18:11 +08:00
instrument.h
ipcc.h
irq.h sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
iterable_sections.h include/nuttx: Add link-time iterable sections infrastructure 2026-08-27 01:04:05 +08:00
kmalloc.h
kthread.h
lin.h LIN:adjust the LIN flag 2026-01-08 23:15:31 +08:00
lirc.h
list.h list: Fix the list conflicts. 2026-01-19 14:12:09 +08:00
list_type.h list: Fix the list conflicts. 2026-01-19 14:12:09 +08:00
macro.h include/nuttx/macro.h: Let FOREACH_ARG() paste the argument index 2026-09-01 17:55:52 -03:00
memoryregion.h
mmcsd.h
module.h
mqueue.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
mutex.h sched/semaphore: Correct the return value comment of nxsem_init/nxmutex_init 2026-09-25 10:37:43 +02:00
notifier.h include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
nuttx.h
page.h style: Fix "is is" typo across the codebase. 2026-03-24 09:39:26 +08:00
panic_notifier.h
pgalloc.h mm/pgalloc: support 32 KB and 64 KB page sizes 2026-09-10 23:28:43 +08:00
plist.h driver/devfreq: DVFS framework for devices 2026-08-08 15:23:54 -03:00
progmem.h
pthread.h pthread: move pthread_cond to userspace 2026-01-26 16:26:39 +08:00
queue.h
random.h
reboot_notifier.h
rwsem.h sched/sem_rw.c: Add downgrade_write API for sem_rw 2026-01-07 22:47:09 +08:00
sched.h sched: Fix deadlock cycle collection. 2026-10-01 23:19:43 +08:00
sched_note.h include/nuttx/macro.h: Let FOREACH_ARG() paste the argument index 2026-09-01 17:55:52 -03:00
scsi.h
sdio.h drivers/mmcsd: Switch SD cards into high speed. 2026-08-18 09:38:45 +08:00
sdio_slave.h
semaphore.h sched/semaphore: Correct the return value comment of nxsem_init/nxmutex_init 2026-09-25 10:37:43 +02:00
seqlock.h seqlock: Fix struct name and constants. 2025-12-22 10:22:06 -03:00
signal.h signal: Inline nxsig_addset(), nxsig_delset() and nxsig_ismember(). 2026-10-06 17:45:52 -03:00
spawn.h
spinlock.h arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
spinlock_type.h arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
streams.h
symtab.h
tee.h
thermal.h
tls.h pthread: remove tl_lock 2026-01-26 20:56:12 +08:00
trace.h trace: fix macro line continuation formatting 2026-01-25 10:45:26 -03:00
uorb.h drivers/sensors: Use sensor_data_t for the electrical quantities. 2026-09-20 09:23:37 -04:00
userspace.h protect: move us_heap to userspace_data_s 2026-02-02 11:06:53 +08:00
vt100.h Documentation: nsh: document the top command 2026-07-11 09:15:15 -03:00
wdog.h sched/wdog: Reject zero delay in wd_start_next. 2026-09-26 22:18:02 +08:00
wqueue.h libc/wqueue: support custom user work queues 2026-09-04 23:02:48 +08:00
zoneinfo.h