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

   ## Summary
   
   apache/nuttx-apps#3762 builds the FDPIC test modules of `examples/fdpicxip` 
and `testing/fs/xipfs` the normal way, with `MODULE = m` and `DYNLIB = y`. That 
puts a stripped module, a CMake shared library and a lazy PLT through the FDPIC 
path for the first time, and four defects show. Each commit fixes one:
   
   - `mps2-an500` sets `LDELFFLAGS` to `-r -e main` after it includes 
`Toolchain.defs`, so a module links as a relocatable object, and a module that 
names a library does not link. dae3b8e5516 removed the same lines from 
`mps3-an547`.
   - `libelf_findsymtab()` accepts only `SHT_SYMTAB`. With 
`CONFIG_DEBUG_SYMBOLS` the application build strips each module, and a stripped 
shared object has only `SHT_DYNSYM`. Every module then fails to load with "No 
symbols in ELF file".
   - The CMake build gives a shared library neither `-mfdpic` nor the FDPIC 
link, only `-r`.
   - `gnu-elf.ld.in` names neither `.rel.plt` nor `.got.plt`. The linker merges 
`.rel.plt` into `.rel.dyn` but sets `DT_JMPREL` as if it came last, and puts 
`.got.plt` after `.got`. A module that calls its imports through a PLT jumps 
into data.
   
   ## Impact
   
   Only `CONFIG_FDPIC` changes, except in the first commit, which gives 
`mps2-an500` the common ELF link flags that the other boards use. Five boards 
still set their own `LDELFFLAGS` and so still cannot build an FDPIC module: 
`devebox-stm32h743`, `weact-stm32h750`, `weact-stm32h743`, `openh743i` and 
`linum-stm32h753bi`. They also name `binfmt/elf/gnu-elf.ld`, which no longer 
exists. I did not change them, because I cannot test them.
   
   ## Testing
   
   Host: macOS arm64, Arm GNU Toolchain 15.3.rel1, `arm-uclinuxfdpiceabi` 
binutils, QEMU 11.0.0.
   
   `mps2-an500:xipfs` with `CONFIG_FDPIC`, on master with apache/nuttx#20368 
and apache/nuttx-apps#3762:
   
   ```
   xipfs_test fdpic    ==== 34 passed, 0 failed ====
   xipfs_test reject   ==== 7 passed, 0 failed ====
   fdpicxip jmprel     [lazymod] called through a DT_JMPREL descriptor, seed 42
   ```
   
   Without each commit:
   
   1. `arm-uclinuxfdpiceabi-ld: attempted static link of dynamic object` when 
`cxxuser` links against `libshape.so`.
   2. `libelf_findsymtab: ERROR: No symbols in ELF file` for every module, and 
`14 passed, 20 failed`.
   3. CMake: `multiple definition` and `dangerous relocation` when a module 
links against a `DYNLIB` library.
   4. `fdpicxip jmprel` ends in a usage fault. With the `.got.plt` half only, 
it ends in a bus fault in `lib_realpath()`, which the PLT slot of `atoi()` was 
bound to.
   
   Under CMake, every module and library now links as an FDPIC shared object. 
The image itself does not link, because CMake does not generate the 
`CONFIG_EXECFUNCS_SYSTEM_SYMTAB` table. That is the same on master.
   
   `mps2-an500:xipfs` and `mps2-an521:xipfs`, which do not set `CONFIG_FDPIC`, 
build. `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