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

   ## Summary
   
   `libelf_relocateadd()` passes `sym` as NULL for a relocation against symbol 
index 0, such as `R_AARCH64_NONE`. The arm64 `up_relocateadd()` read 
`sym->st_value` before it looked at the relocation type, so loading a module 
with such a relocation faulted in the kernel.
   
   This PR accepts a NULL symbol for `R_AARCH64_NONE` and fails any other type 
with `-EINVAL`, as the other architectures do.
   
   ## Impact
   
   arm64 ELF loading only.
   
   ## 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 with an `R_AARCH64_NONE` relocation against symbol 0 (`.reloc ., 
R_AARCH64_NONE` in an assembly file).
   
   Before:
   ```
   nsh> none
   default_fatal_handler: (IFSC/DFSC) for Data/Instruction aborts: level 2 
translation fault
   arm64_exception_handler: FAR_ELn: 0x8
   ```
   
   After:
   ```
   nsh> none
   R_AARCH64_NONE test: nonefunc() returned 7
   ```
   


-- 
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