mirror of
https://github.com/apache/nuttx.git
synced 2026-09-09 10:26:37 +00:00
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> |
||
|---|---|---|
| .. | ||
| aio | ||
| assert | ||
| audio | ||
| builtin | ||
| ctype | ||
| dirent | ||
| dlfcn | ||
| elf | ||
| errno | ||
| eventfd | ||
| fdt | ||
| fixedmath | ||
| gdbstub | ||
| gnssutils | ||
| grp | ||
| hex2bin | ||
| inttypes | ||
| libgen | ||
| locale | ||
| lzf | ||
| machine | ||
| misc | ||
| net | ||
| netdb | ||
| obstack | ||
| pthread | ||
| pwd | ||
| queue | ||
| regex | ||
| sched | ||
| search | ||
| semaphore | ||
| signal | ||
| spawn | ||
| stdio | ||
| stdlib | ||
| stream | ||
| string | ||
| symtab | ||
| syslog | ||
| termios | ||
| time | ||
| tls | ||
| uio | ||
| unistd | ||
| userfs | ||
| uuid | ||
| wchar | ||
| wctype | ||
| wqueue | ||
| zoneinfo | ||
| .gitignore | ||
| CMakeLists.txt | ||
| Kconfig | ||
| libc.csv | ||
| libc.h | ||
| limits_check.c | ||
| Makefile | ||