casaroli opened a new pull request, #20551: URL: https://github.com/apache/nuttx/pull/20551
## Summary When `libelf_symvalue()` could not resolve an undefined symbol, it failed the load with `ENOENT`, also for a weak reference. A static link gives an unresolved weak symbol the value 0, and code tests it for that. So a module that only refers weakly to a symbol could not be loaded, for example a C++ program whose vtables refer to `__cxa_pure_virtual`. This PR gives an unresolved weak symbol the value 0, as the dynamic relocation path in `elf_bind.c` already does. ## Impact ELF loading of relocatable modules with an unresolved weak reference: they now load instead of failing. Other modules are unchanged. A weak reference that GCC makes through the GOT (`R_AARCH64_ADR_GOT_PAGE`, which it uses when the code tests the address of a weak function directly) still fails, because the arm64 loader does not support GOT relocations in relocatable modules. That is a separate change. ## Testing `qemu-armv8a:knsh` with `CONFIG_DRIVERS_VIRTIO`, `CONFIG_DRIVERS_VIRTIO_MMIO`, `CONFIG_FS_V9FS` and `CONFIG_V9FS_VIRTIO_9P`, QEMU 11 (`-m 512M`, a `virtio-9p-device` share). The test programs were built outside the tree against the export package. A program that refers weakly to an undefined function through data (`R_AARCH64_ABS64`, as in a C++ vtable): Before: ``` nsh> weak nsh: weak: command not found ``` (`posix_spawn()` failed with `ENOENT`.) After: ``` nsh> weak weak: maybe is NULL, as it should be ``` -- 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]
