casaroli opened a new pull request, #20388: URL: https://github.com/apache/nuttx/pull/20388
## Summary Part of the FDPIC series. Two bugs stop an FDPIC module from starting when it is linked the way the tree's own module flags link it (`CMODULEFLAGS`, `LDMODULEFLAGS`, `gnu-elf.ld`): its text starts at file offset 0x1000, and it carries the tree's `crt0`. The modules the xipfs tests carry today are linked differently and do not hit either one. `DT_REL` and `DT_JMPREL` hold the link-time address of their table, and the loader read the table at that value as a file offset. The two are equal only when the segment starts at file offset 0. Otherwise the relocations were read from padding and none were applied, so `_start` called `main()` through an unrelocated pointer. The address is now translated through the `PT_LOAD` headers first. Under FDPIC an `.init_array` entry is a code address, but a C function pointer is a descriptor. `crt0` called each entry through a function pointer, so with `CONFIG_HAVE_CXXINITIALIZE` it read a constructor's first instructions as a descriptor. It now calls each entry through a descriptor built from the entry and the module's own `r9`. ## Impact Only FDPIC modules change. An object whose segments start at file offset 0 translates to the same offset as before, and without `__FDPIC__` `crt0` is unchanged. ## Testing `mps2-an500:xipfs` with `CONFIG_FDPIC` under QEMU, `xipfs_test fdpic`, with the module fixtures rebuilt by the tree's module flags (apache/nuttx-apps#3762): | nuttx | result | |---|---| | master | crash in the first test, `funcdesc` | | master + this PR | 28 passed, 6 failed: the six library tests, which need apache/nuttx#20368 | | master + this PR + #20368 | 34 passed, 0 failed | With the fixtures on apps master the result is unchanged by this PR. `qemu-armv7a:knsh` builds with `-Werror`, including `make export` (which builds `crt0.o`) and the apps import. `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]
