casaroli opened a new pull request, #20492:
URL: https://github.com/apache/nuttx/pull/20492

   ## Summary
   
   Each task group now has its own registry of the ELF objects that `dlopen()` 
loads, as suggested in #20132. The registry is in `struct task_info_s` and not 
in `struct tls_info_s`, because POSIX makes a `dlopen()` handle valid in the 
whole process, not only in the thread that opened it.
   
   Kernel modules from `insmod()` stay on one registry for the system, and 
`/proc/modules` shows only them.
   
   A library that a module names in `DT_NEEDED` goes on the registry of that 
module. In a flat build, `exec()` gives the libraries of the program to the new 
task group, so `dlopen()` in the program finds the same copy.
   
   When a task group exits, the libraries that it did not close are closed. A 
flat build does this in `group_release()`, after the last thread. A protected 
build does it in `exit()`, because the kernel cannot reach the user registry.
   
   ## Impact
   
   Two processes that use one library now each have their own copy of its data, 
and its constructors and destructors run once per process. An FDPIC library 
executed in place from xipfs still shares its text.
   
   A library that is not executed in place is now loaded once per process, so 
its text uses RAM in each process.
   
   A program loaded by `exec()` no longer resolves symbols from libraries that 
other processes loaded, or from `insmod()` modules.
   
   `dlopen()` handles that a process does not close are now freed when it 
exits. Before, they stayed loaded.
   
   The xipfs C++ test in apps checks the old shared behaviour. 
apache/nuttx-apps#APPS changes it.
   
   ## Testing
   
   Arm GNU Toolchain 13.2.rel1, QEMU `mps2-an500`.
   
   | test | master | this PR |
   |---|---|---|
   | `xipfs_test fdpic` (FDPIC, `mps2-an500:xipfs`) | 32 passed, 2 failed | 32 
passed, 2 failed, with the apps PR |
   | `fdpicxip solib` | library pinned once, totals 9 and 9 | pinned twice, 
totals 3 and 6, 0 pins after exit |
   | `fdpicxip cxx` | one library destructor | one destructor per process |
   | `sotest` (plain ELF) | same output | same output |
   | `sotest` that exits with its libraries open | the library destructor never 
runs | it runs at exit |
   | `mps2-an500:knsh` (protected) with ELF and dlfcn: `ostest` | exits 0 | 
exits 0 |
   | `qemu-armv7a:knsh` (kernel) with dlfcn | builds | builds |
   
   The 2 `xipfs_test` failures also occur on master. `tools/checkpatch.sh -c -u 
-m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to